get rid of py-value.c:is_intlike (use is_integral_type instead)
authorJoel Brobecker <brobecker@adacore.com>
Tue, 19 Nov 2013 02:56:00 +0000 (06:56 +0400)
committerJoel Brobecker <brobecker@adacore.com>
Wed, 20 Nov 2013 17:20:11 +0000 (21:20 +0400)
is_intlike was mostly duplicating is_integral_type, with the exception
of the handling of TYPE_CODE_PTR when parameter PTR_OK is nonzero.
This patches deletes the is_intlike function, using is_integral_type
instead, and adjusting the two locations where this function gets
called.

The code should remain strictly equivalent.

gdb/ChangeLog:

        * python/py-value.c (is_intlike): Delete.
        (valpy_int): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type.
        (valpy_long): Replace use of CHECK_TYPEDEF and is_intlike
        by use of is_integral_type and check for TYPE_CODE_PTR.

gdb/ChangeLog
gdb/python/py-value.c

index 94e9e1b79b5a18cb46f1467e87366c4b980f292e..f989f1621702049a093691ab89616a286f5e3d83 100644 (file)
@@ -1,3 +1,11 @@
+2013-11-20  Joel Brobecker  <brobecker@adacore.com>
+
+       * python/py-value.c (is_intlike): Delete.
+       (valpy_int): Replace use of CHECK_TYPEDEF and is_intlike
+       by use of is_integral_type.
+       (valpy_long): Replace use of CHECK_TYPEDEF and is_intlike
+       by use of is_integral_type and check for TYPE_CODE_PTR.
+
 2013-11-20  Tom Tromey  <tromey@redhat.com>
 
        * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Remove
index 451bfaf2b83cb6ad3922b0fe7ed63ebd8c29b278..4054808d537ba16b41bf55ece73e87708558436c 100644 (file)
@@ -1129,18 +1129,6 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
   Py_RETURN_FALSE;
 }
 
-/* Helper function to determine if a type is "int-like".  */
-static int
-is_intlike (struct type *type, int ptr_ok)
-{
-  return (TYPE_CODE (type) == TYPE_CODE_INT
-         || TYPE_CODE (type) == TYPE_CODE_ENUM
-         || TYPE_CODE (type) == TYPE_CODE_BOOL
-         || TYPE_CODE (type) == TYPE_CODE_CHAR
-         || TYPE_CODE (type) == TYPE_CODE_RANGE
-         || (ptr_ok && TYPE_CODE (type) == TYPE_CODE_PTR));
-}
-
 #ifndef IS_PY3K
 /* Implements conversion to int.  */
 static PyObject *
@@ -1153,8 +1141,7 @@ valpy_int (PyObject *self)
 
   TRY_CATCH (except, RETURN_MASK_ALL)
     {
-      CHECK_TYPEDEF (type);
-      if (!is_intlike (type, 0))
+      if (!is_integral_type (type))
        error (_("Cannot convert value to int."));
 
       l = value_as_long (value);
@@ -1178,7 +1165,8 @@ valpy_long (PyObject *self)
     {
       CHECK_TYPEDEF (type);
 
-      if (!is_intlike (type, 1))
+      if (!is_integral_type (type)
+         && TYPE_CODE (type) != TYPE_CODE_PTR)
        error (_("Cannot convert value to long."));
 
       l = value_as_long (value);
This page took 0.029318 seconds and 4 git commands to generate.