diff options
Diffstat (limited to 'dbus_bindings/int.c')
-rw-r--r-- | dbus_bindings/int.c | 71 |
1 files changed, 18 insertions, 53 deletions
diff --git a/dbus_bindings/int.c b/dbus_bindings/int.c index 5944314..47d8404 100644 --- a/dbus_bindings/int.c +++ b/dbus_bindings/int.c @@ -29,14 +29,6 @@ #include "types-internal.h" -#ifdef PY3 -#define INTBASE (DBusPyLongBase_Type) -#define LONG_TYPE_NAME "int" -#else -#define INTBASE (DBusPyIntBase_Type) -#define LONG_TYPE_NAME "long" -#endif - /* Specific types =================================================== */ /* Boolean, a subclass of DBusPythonInt ============================= */ @@ -75,7 +67,7 @@ Boolean_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) } tuple = Py_BuildValue("(i)", PyObject_IsTrue(value) ? 1 : 0); if (!tuple) return NULL; - self = (INTBASE.tp_new)(cls, tuple, kwargs); + self = (DBusPyLongBase_Type.tp_new)(cls, tuple, kwargs); Py_CLEAR(tuple); return self; } @@ -90,13 +82,9 @@ static PyObject * Boolean_tp_repr(PyObject *self) { int is_true = PyObject_IsTrue(self); -#ifdef PY3 long variant_level = dbus_py_variant_level_get(self); if (variant_level < 0) return NULL; -#else - long variant_level = ((DBusPyIntBase *)self)->variant_level; -#endif if (is_true == -1) return NULL; @@ -143,7 +131,7 @@ PyTypeObject DBusPyBoolean_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&INTBASE), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -192,7 +180,7 @@ dbus_py_int16_range_check(PyObject *obj) static PyObject * Int16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); + PyObject *self = (DBusPyLongBase_Type.tp_new)(cls, args, kwargs); if (self && dbus_py_int16_range_check(self) == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; @@ -231,7 +219,7 @@ PyTypeObject DBusPyInt16_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&INTBASE), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -280,7 +268,7 @@ dbus_py_uint16_range_check(PyObject *obj) static PyObject * UInt16_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); + PyObject *self = (DBusPyLongBase_Type.tp_new)(cls, args, kwargs); if (self && dbus_py_uint16_range_check(self) == (dbus_uint16_t)(-1) && PyErr_Occurred()) { @@ -321,7 +309,7 @@ PyTypeObject DBusPyUInt16_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&INTBASE), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -370,7 +358,7 @@ dbus_py_int32_range_check(PyObject *obj) static PyObject * Int32_tp_new(PyTypeObject *cls, PyObject *args, PyObject *kwargs) { - PyObject *self = (INTBASE.tp_new)(cls, args, kwargs); + PyObject *self = (DBusPyLongBase_Type.tp_new)(cls, args, kwargs); if (self && dbus_py_int32_range_check(self) == -1 && PyErr_Occurred()) { Py_CLEAR(self); return NULL; @@ -409,7 +397,7 @@ PyTypeObject DBusPyInt32_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&INTBASE), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -422,7 +410,7 @@ PyTypeObject DBusPyInt32_Type = { /* UInt32 =========================================================== */ PyDoc_STRVAR(UInt32_tp_doc, -"dbus.UInt32(value: " LONG_TYPE_NAME "[, variant_level: int])\n" +"dbus.UInt32(value: int[, variant_level: int])\n" "\n" "An unsigned 32-bit integer between 0 and 0xFFFF FFFF, represented as a\n" "subtype of ``long`` in Python 2 or ``int`` in Python 3.\n" @@ -505,7 +493,7 @@ PyTypeObject DBusPyUInt32_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -518,7 +506,7 @@ PyTypeObject DBusPyUInt32_Type = { /* Int64 =========================================================== */ PyDoc_STRVAR(Int64_tp_doc, -"dbus.Int64(value: " LONG_TYPE_NAME "[, variant_level: int])\n" +"dbus.Int64(value: int[, variant_level: int])\n" "\n" "A signed 64-bit integer between -0x8000 0000 0000 0000 and\n" "+0x7FFF FFFF FFFF FFFF, represented as a\n" @@ -611,7 +599,7 @@ PyTypeObject DBusPyInt64_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -624,7 +612,7 @@ PyTypeObject DBusPyInt64_Type = { /* UInt64 =========================================================== */ PyDoc_STRVAR(UInt64_tp_doc, -"dbus.UInt64(value: " LONG_TYPE_NAME "[, variant_level: int])\n" +"dbus.UInt64(value: int[, variant_level: int])\n" "\n" "An unsigned 64-bit integer between 0 and 0xFFFF FFFF FFFF FFFF,\n" "subtype of ``long`` in Python 2 or ``int`` in Python 3.\n" @@ -712,7 +700,7 @@ PyTypeObject DBusPyUInt64_Type = { 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ + DEFERRED_ADDRESS(&DBusPyLongBase_Type), /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -725,51 +713,28 @@ PyTypeObject DBusPyUInt64_Type = { dbus_bool_t dbus_py_init_int_types(void) { - DBusPyInt16_Type.tp_base = &INTBASE; + DBusPyInt16_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyInt16_Type) < 0) return 0; -#ifndef PY3 - /* disable the tp_print copied from PyInt_Type, so tp_repr gets called as - desired */ - DBusPyInt16_Type.tp_print = NULL; -#endif - DBusPyUInt16_Type.tp_base = &INTBASE; + DBusPyUInt16_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyUInt16_Type) < 0) return 0; -#ifndef PY3 - DBusPyUInt16_Type.tp_print = NULL; -#endif - DBusPyInt32_Type.tp_base = &INTBASE; + DBusPyInt32_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyInt32_Type) < 0) return 0; -#ifndef PY3 - DBusPyInt32_Type.tp_print = NULL; -#endif DBusPyUInt32_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyUInt32_Type) < 0) return 0; -#ifndef PY3 - DBusPyUInt32_Type.tp_print = NULL; -#endif #if defined(DBUS_HAVE_INT64) && defined(HAVE_LONG_LONG) DBusPyInt64_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyInt64_Type) < 0) return 0; -#ifndef PY3 - DBusPyInt64_Type.tp_print = NULL; -#endif DBusPyUInt64_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyUInt64_Type) < 0) return 0; -#ifndef PY3 - DBusPyUInt64_Type.tp_print = NULL; -#endif #endif - DBusPyBoolean_Type.tp_base = &INTBASE; + DBusPyBoolean_Type.tp_base = &DBusPyLongBase_Type; if (PyType_Ready(&DBusPyBoolean_Type) < 0) return 0; -#ifndef PY3 - DBusPyBoolean_Type.tp_print = NULL; -#endif return 1; } |