aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2008-10-19 20:25:00 +0000
committerPedro Alves <palves@redhat.com>2008-10-19 20:25:00 +0000
commitf9176c46a1571258f658b178bd26e72d6a042ec1 (patch)
tree587cdfd8cb0ab9399ff9dc79bcc7cac8a1c6b4d6
parentf177e35094c597497602a558fd6f056bb3e48e92 (diff)
downloadgdb-f9176c46a1571258f658b178bd26e72d6a042ec1.zip
gdb-f9176c46a1571258f658b178bd26e72d6a042ec1.tar.gz
gdb-f9176c46a1571258f658b178bd26e72d6a042ec1.tar.bz2
* python/python-value.c (value_object_methods)
(value_object_as_number, value_object_as_mapping): Move to bottom of file. (valpy_dealloc, valpy_new, valpy_length, valpy_getitem) (valpy_setitem, valpy_str, valpy_add, valpy_subtract) (valpy_multiply, valpy_divide, valpy_remainder, valpy_power) (valpy_negative, valpy_positive, valpy_absolute, valpy_nonzero) (valpy_richcompare, valpy_dereference): Don't forward-declare. (valpy_length) [HAVE_LIBPYTHON2_4]: Change return type to `int'.
-rw-r--r--gdb/ChangeLog12
-rw-r--r--gdb/python/python-value.c139
2 files changed, 73 insertions, 78 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7490ff3..8de31e9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,15 @@
+2008-10-19 Pedro Alves <pedro@codesourcery.com>
+
+ * python/python-value.c (value_object_methods)
+ (value_object_as_number, value_object_as_mapping): Move to bottom
+ of file.
+ (valpy_dealloc, valpy_new, valpy_length, valpy_getitem)
+ (valpy_setitem, valpy_str, valpy_add, valpy_subtract)
+ (valpy_multiply, valpy_divide, valpy_remainder, valpy_power)
+ (valpy_negative, valpy_positive, valpy_absolute, valpy_nonzero)
+ (valpy_richcompare, valpy_dereference): Don't forward-declare.
+ (valpy_length) [HAVE_LIBPYTHON2_4]: Change return type to `int'.
+
2008-10-18 Pedro Alves <pedro@codesourcery.com>
* infrun.c (adjust_pc_after_break): Do nothing if executing in
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index f53219f..6c4be54 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -57,84 +57,6 @@ typedef struct {
int owned_by_gdb;
} value_object;
-static void valpy_dealloc (PyObject *obj);
-static PyObject *valpy_new (PyTypeObject *subtype, PyObject *args,
- PyObject *keywords);
-static Py_ssize_t valpy_length (PyObject *self);
-static PyObject *valpy_getitem (PyObject *self, PyObject *key);
-static int valpy_setitem (PyObject *self, PyObject *key, PyObject *value);
-static PyObject *valpy_str (PyObject *self);
-static PyObject *valpy_add (PyObject *self, PyObject *other);
-static PyObject *valpy_subtract (PyObject *self, PyObject *other);
-static PyObject *valpy_multiply (PyObject *self, PyObject *other);
-static PyObject *valpy_divide (PyObject *self, PyObject *other);
-static PyObject *valpy_remainder (PyObject *self, PyObject *other);
-static PyObject *valpy_power (PyObject *self, PyObject *other, PyObject *unused);
-static PyObject *valpy_negative (PyObject *self);
-static PyObject *valpy_positive (PyObject *self);
-static PyObject *valpy_absolute (PyObject *self);
-static int valpy_nonzero (PyObject *self);
-static PyObject *valpy_richcompare (PyObject *self, PyObject *other, int op);
-static PyObject *valpy_dereference (PyObject *self, PyObject *args);
-
-static PyMethodDef value_object_methods[] = {
- { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
- {NULL} /* Sentinel */
-};
-
-static PyNumberMethods value_object_as_number = {
- valpy_add,
- valpy_subtract,
- valpy_multiply,
- valpy_divide,
- valpy_remainder,
- NULL, /* nb_divmod */
- valpy_power, /* nb_power */
- valpy_negative, /* nb_negative */
- valpy_positive, /* nb_positive */
- valpy_absolute, /* nb_absolute */
- valpy_nonzero /* nb_nonzero */
-};
-
-static PyMappingMethods value_object_as_mapping = {
- valpy_length,
- valpy_getitem,
- valpy_setitem
-};
-
-PyTypeObject value_object_type = {
- PyObject_HEAD_INIT (NULL)
- 0, /*ob_size*/
- "gdb.Value", /*tp_name*/
- sizeof (value_object), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- valpy_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &value_object_as_number, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- &value_object_as_mapping, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- valpy_str, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "GDB value object", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- valpy_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- value_object_methods /* tp_methods */
-};
-
-
/* Called by the Python interpreter when deallocating a value object. */
static void
valpy_dealloc (PyObject *obj)
@@ -206,7 +128,11 @@ valpy_dereference (PyObject *self, PyObject *args)
return value_to_value_object (res_val);
}
+#ifdef HAVE_LIBPYTHON2_4
+static int
+#else
static Py_ssize_t
+#endif
valpy_length (PyObject *self)
{
/* We don't support getting the number of elements in a struct / class. */
@@ -686,4 +612,61 @@ gdbpy_initialize_values (void)
values_in_python = NULL;
}
+static PyMethodDef value_object_methods[] = {
+ { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods value_object_as_number = {
+ valpy_add,
+ valpy_subtract,
+ valpy_multiply,
+ valpy_divide,
+ valpy_remainder,
+ NULL, /* nb_divmod */
+ valpy_power, /* nb_power */
+ valpy_negative, /* nb_negative */
+ valpy_positive, /* nb_positive */
+ valpy_absolute, /* nb_absolute */
+ valpy_nonzero /* nb_nonzero */
+};
+
+static PyMappingMethods value_object_as_mapping = {
+ valpy_length,
+ valpy_getitem,
+ valpy_setitem
+};
+
+PyTypeObject value_object_type = {
+ PyObject_HEAD_INIT (NULL)
+ 0, /*ob_size*/
+ "gdb.Value", /*tp_name*/
+ sizeof (value_object), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ valpy_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ &value_object_as_number, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ &value_object_as_mapping, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ valpy_str, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+ "GDB value object", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ valpy_richcompare, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ value_object_methods /* tp_methods */
+};
+
#endif /* HAVE_PYTHON */