Commit 9f96325e authored by Martin Pitt's avatar Martin Pitt
Browse files

Drop static G_MININT8 and related constants

Use the introspected constants from GLib instead.
parent 3354c4ed
......@@ -140,18 +140,6 @@ G_MAXUINT = constants.G_MAXUINT
G_MINLONG = constants.G_MINLONG
G_MAXLONG = constants.G_MAXLONG
G_MAXULONG = constants.G_MAXULONG
G_MININT8 = constants.G_MININT8
G_MAXINT8 = constants.G_MAXINT8
G_MAXUINT8 = constants.G_MAXUINT8
G_MININT16 = constants.G_MININT16
G_MAXINT16 = constants.G_MAXINT16
G_MAXUINT16 = constants.G_MAXUINT16
G_MININT32 = constants.G_MININT32
G_MAXINT32 = constants.G_MAXINT32
G_MAXUINT32 = constants.G_MAXUINT32
G_MININT64 = constants.G_MININT64
G_MAXINT64 = constants.G_MAXINT64
G_MAXUINT64 = constants.G_MAXUINT64
G_MAXSIZE = constants.G_MAXSIZE
G_MAXSSIZE = constants.G_MAXSSIZE
G_MINOFFSET = constants.G_MINOFFSET
......
......@@ -64,18 +64,6 @@ G_MAXUINT = _gobject.G_MAXUINT
G_MINLONG = _gobject.G_MINLONG
G_MAXLONG = _gobject.G_MAXLONG
G_MAXULONG = _gobject.G_MAXULONG
G_MININT8 = _gobject.G_MININT8
G_MAXINT8 = _gobject.G_MAXINT8
G_MAXUINT8 = _gobject.G_MAXUINT8
G_MININT16 = _gobject.G_MININT16
G_MAXINT16 = _gobject.G_MAXINT16
G_MAXUINT16 = _gobject.G_MAXUINT16
G_MININT32 = _gobject.G_MININT32
G_MAXINT32 = _gobject.G_MAXINT32
G_MAXUINT32 = _gobject.G_MAXUINT32
G_MININT64 = _gobject.G_MININT64
G_MAXINT64 = _gobject.G_MAXINT64
G_MAXUINT64 = _gobject.G_MAXUINT64
G_MAXSIZE = _gobject.G_MAXSIZE
G_MAXSSIZE = _gobject.G_MAXSSIZE
G_MINOFFSET = _gobject.G_MINOFFSET
......
......@@ -2431,31 +2431,15 @@ pygobject_register_constants(PyObject *m)
PyModule_AddIntConstant(m, "G_MAXUSHORT", G_MAXUSHORT);
PyModule_AddIntConstant(m, "G_MININT", G_MININT);
PyModule_AddIntConstant(m, "G_MAXINT", G_MAXINT);
PyModule_AddObject(m, "G_MAXUINT", PyLong_FromUnsignedLong(G_MAXUINT));
PyModule_AddObject(m, "G_MINLONG", PyLong_FromLong(G_MINLONG));
PyModule_AddObject(m, "G_MAXLONG", PyLong_FromLong(G_MAXLONG));
PyModule_AddObject(m, "G_MAXULONG", PyLong_FromUnsignedLong(G_MAXULONG));
PyModule_AddIntConstant(m, "G_MININT8", G_MININT8);
PyModule_AddIntConstant(m, "G_MAXINT8", G_MAXINT8);
PyModule_AddIntConstant(m, "G_MAXUINT8", G_MAXUINT8);
PyModule_AddIntConstant(m, "G_MININT16", G_MININT16);
PyModule_AddIntConstant(m, "G_MAXINT16", G_MAXINT16);
PyModule_AddIntConstant(m, "G_MAXUINT16", G_MAXUINT16);
PyModule_AddIntConstant(m, "G_MININT32", G_MININT32);
PyModule_AddIntConstant(m, "G_MAXINT32", G_MAXINT32);
PyModule_AddObject(m, "G_MININT64", PyLong_FromLongLong(G_MININT64));
PyModule_AddObject(m, "G_MAXINT64", PyLong_FromLongLong(G_MAXINT64));
PyModule_AddObject(m, "G_MAXUINT64", PyLong_FromUnsignedLongLong(G_MAXUINT64));
PyModule_AddObject(m, "G_MAXSIZE", PyLong_FromSize_t(G_MAXSIZE));
PyModule_AddObject(m, "G_MAXSSIZE", PyLong_FromSsize_t(G_MAXSSIZE));
PyModule_AddObject(m, "G_MINOFFSET", PyLong_FromLongLong(G_MINOFFSET));
PyModule_AddObject(m, "G_MAXOFFSET", PyLong_FromLongLong(G_MAXOFFSET));
/* in order for test_properties to pass, G_MAXUINT must be initialized using
PyLong_FromUnsignedLong, despite AFAICT it is unecessary for 32bit int types.
In the interests of consistancy I did the same for MAXUINT32 */
PyModule_AddObject(m, "G_MAXUINT32", PyLong_FromUnsignedLong(G_MAXUINT32));
PyModule_AddObject(m, "G_MAXUINT", PyLong_FromUnsignedLong(G_MAXUINT));
PyModule_AddIntConstant(m, "SIGNAL_RUN_FIRST", G_SIGNAL_RUN_FIRST);
PyModule_AddIntConstant(m, "SIGNAL_RUN_LAST", G_SIGNAL_RUN_LAST);
PyModule_AddIntConstant(m, "SIGNAL_RUN_CLEANUP", G_SIGNAL_RUN_CLEANUP);
......
......@@ -51,3 +51,20 @@ for name in ['PRIORITY_DEFAULT', 'PRIORITY_DEFAULT_IDLE', 'PRIORITY_HIGH',
'SPAWN_FILE_AND_ARGV_ZERO']:
globals()[name] = getattr(GLib, name)
__all__.append(name)
G_MININT8 = GLib.MININT8
G_MAXINT8 = GLib.MAXINT8
G_MAXUINT8 = GLib.MAXUINT8
G_MININT16 = GLib.MININT16
G_MAXINT16 = GLib.MAXINT16
G_MAXUINT16 = GLib.MAXUINT16
G_MININT32 = GLib.MININT32
G_MAXINT32 = GLib.MAXINT32
G_MAXUINT32 = GLib.MAXUINT32
G_MININT64 = GLib.MININT64
G_MAXINT64 = GLib.MAXINT64
G_MAXUINT64 = GLib.MAXUINT64
__all__ += ['G_MININT8', 'G_MAXINT8', 'G_MAXUINT8', 'G_MININT16',
'G_MAXINT16', 'G_MAXUINT16', 'G_MININT32', 'G_MAXINT32',
'G_MAXUINT32', 'G_MININT64', 'G_MAXINT64', 'G_MAXUINT64']
......@@ -38,6 +38,10 @@ class TestGObjectAPI(unittest.TestCase):
self.assertLess(GObject.PRIORITY_HIGH, GObject.PRIORITY_DEFAULT)
def test_min_max_int(self):
self.assertEqual(GObject.G_MAXINT16, 2 ** 15 - 1)
self.assertEqual(GObject.G_MININT16, -2 ** 15)
self.assertEqual(GObject.G_MAXUINT16, 2 ** 16 - 1)
self.assertEqual(GObject.G_MAXINT32, 2 ** 31 - 1)
self.assertEqual(GObject.G_MININT32, -2 ** 31)
self.assertEqual(GObject.G_MAXUINT32, 2 ** 32 - 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment