pygobject r884 - in trunk: . gobject



Author: johan
Date: Sun Jul 27 09:39:21 2008
New Revision: 884
URL: http://svn.gnome.org/viewvc/pygobject?rev=884&view=rev

Log:
2008-07-27  Johan Dahlin  <johan gnome org>

    * gobject/gobjectmodule.c (pyg_param_spec_from_object),
    (add_properties), (pyg_signal_new), (pyg_signal_list_ids),
    (pyg_signal_lookup), (pyg_signal_query):
    * gobject/pygenum.c (pyg_enum_richcompare), (pyg_enum_new),
    (pyg_enum_from_gtype), (pyg_enum_add), (pyg_enum_reduce),
    (pygobject_enum_register_types):
    * gobject/pygflags.c (pyg_flags_richcompare), (pyg_flags_new),
    (pyg_flags_from_gtype), (pyg_flags_add), (pyg_flags_and),
    (pyg_flags_or), (pyg_flags_xor), (pygobject_flags_register_types):
    * gobject/pygobject-private.h:
    * gobject/pygobject.c (pygobject_disconnect_by_func),
    (pygobject_handler_block_by_func),
    (pygobject_handler_unblock_by_func), (pygobject_get_refcount):
    * gobject/pygparamspec.c (pyg_param_spec_getattr):
    * gobject/pygtype.c (_wrap_g_type_wrapper__get_depth),
    (pyg_type_from_object), (pyg_enum_get_value),
    (pyg_flags_get_value), (pyg_value_from_pyobject),
    (pyg_value_as_pyobject):
    Use _PyLong macros.



Modified:
   trunk/ChangeLog
   trunk/gobject/gobjectmodule.c
   trunk/gobject/pygenum.c
   trunk/gobject/pygflags.c
   trunk/gobject/pygobject-private.h
   trunk/gobject/pygobject.c
   trunk/gobject/pygparamspec.c
   trunk/gobject/pygtype.c

Modified: trunk/gobject/gobjectmodule.c
==============================================================================
--- trunk/gobject/gobjectmodule.c	(original)
+++ trunk/gobject/gobjectmodule.c	Sun Jul 27 09:39:21 2008
@@ -784,7 +784,7 @@
     }
     
     item = PyTuple_GetItem(tuple, val_length-1);
-    if (!PyInt_Check(item)) {
+    if (!_PyLong_Check(item)) {
 	PyErr_SetString(PyExc_TypeError,
 			"last element in tuple must be an int");
 	return NULL;
@@ -794,7 +794,7 @@
     slice = PySequence_GetSlice(tuple, 4, val_length-1);
     pspec = create_property(prop_name, prop_type,
 			    nick, blurb, slice,
-			    PyInt_AsLong(item));
+			    _PyLong_AsLong(item));
 
     return pspec;
 }
@@ -858,13 +858,13 @@
 	    break;
 	}
 	item = PyTuple_GetItem(value, val_length-1);
-	if (!PyInt_Check(item)) {
+	if (!_PyLong_Check(item)) {
 	    PyErr_SetString(PyExc_TypeError,
 		"last element in __gproperties__ value tuple must be an int");
 	    ret = FALSE;
 	    break;
 	}
-	flags = PyInt_AsLong(item);
+	flags = _PyLong_AsLong(item);
 
 	/* slice is the extra items in the tuple */
 	slice = PySequence_GetSlice(value, 3, val_length-1);
@@ -1349,7 +1349,7 @@
 			      return_type, n_params, param_types);
     g_free(param_types);
     if (signal_id != 0)
-	return PyInt_FromLong(signal_id);
+	return _PyLong_FromLong(signal_id);
     PyErr_SetString(PyExc_RuntimeError, "could not create signal");
     return NULL;
 }
@@ -1450,7 +1450,7 @@
     }
 
     for (i = 0; i < n; i++)
-	PyTuple_SetItem(list, i, PyInt_FromLong(ids[i]));
+	PyTuple_SetItem(list, i, _PyLong_FromLong(ids[i]));
     g_free(ids);
     if (class)
         g_type_class_unref(class);
@@ -1498,7 +1498,7 @@
         g_type_class_unref(class);
     else
        g_type_default_interface_unref(iface);
-    return PyInt_FromLong(id);
+    return _PyLong_FromLong(id);
 }
 
 static PyObject *
@@ -1586,10 +1586,10 @@
         goto done;
     }
 
-    PyTuple_SET_ITEM(py_query, 0, PyInt_FromLong(query.signal_id));
+    PyTuple_SET_ITEM(py_query, 0, _PyLong_FromLong(query.signal_id));
     PyTuple_SET_ITEM(py_query, 1, _PyUnicode_FromString(query.signal_name));
     PyTuple_SET_ITEM(py_query, 2, pyg_type_wrapper_new(query.itype));
-    PyTuple_SET_ITEM(py_query, 3, PyInt_FromLong(query.signal_flags));
+    PyTuple_SET_ITEM(py_query, 3, _PyLong_FromLong(query.signal_flags));
     PyTuple_SET_ITEM(py_query, 4, pyg_type_wrapper_new(query.return_type));
     for (i = 0; i < query.n_params; i++) {
         PyTuple_SET_ITEM(params_list, i,
@@ -2306,7 +2306,7 @@
     g_type_set_qdata(type, pygobject_has_updated_constructor_key, GINT_TO_POINTER(1));
 }
 
-#define GET_INT(x) (((PyIntObject*)x)->ob_ival)
+#define GET_INT(x) (((_PyLongObject*)x)->ob_ival)
 PyObject *
 pyg_integer_richcompare(PyObject *v, PyObject *w, int op)
 {

Modified: trunk/gobject/pygenum.c
==============================================================================
--- trunk/gobject/pygenum.c	(original)
+++ trunk/gobject/pygenum.c	Sun Jul 27 09:39:21 2008
@@ -37,7 +37,7 @@
 {
     static char warning[256];
 
-    if (!PyInt_Check(other)) {
+    if (!_PyLong_Check(other)) {
 	Py_INCREF(Py_NotImplemented);
 	return Py_NotImplemented;
     }
@@ -132,7 +132,7 @@
 
     g_type_class_unref(eclass);
     
-    intvalue = PyInt_FromLong(value);
+    intvalue = _PyLong_FromLong(value);
     ret = PyDict_GetItem(values, intvalue);
     Py_DECREF(intvalue);
     Py_DECREF(values);
@@ -155,12 +155,12 @@
     if (pyclass == NULL) {
 	pyclass = pyg_enum_add(NULL, g_type_name(gtype), NULL, gtype);
 	if (!pyclass)
-	    return PyInt_FromLong(value);
+	    return _PyLong_FromLong(value);
     }
     
     values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
 				  "__enum_values__");
-    intvalue = PyInt_FromLong(value);
+    intvalue = _PyLong_FromLong(value);
     retval = PyDict_GetItem(values, intvalue);
     Py_DECREF(intvalue);
     if (!retval) {
@@ -168,9 +168,9 @@
 	retval = ((PyTypeObject *)pyclass)->tp_alloc((PyTypeObject *)pyclass, 0);
 	g_assert(retval != NULL);
 	
-	((PyIntObject*)retval)->ob_ival = value;
+	((_PyLongObject*)retval)->ob_ival = value;
 	((PyGFlags*)retval)->gtype = gtype;
-	//return PyInt_FromLong(value);
+	//return _PyLong_FromLong(value);
     }
     
     Py_INCREF(retval);
@@ -236,10 +236,10 @@
 	PyObject *item, *intval;
       
 	item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0);
-	((PyIntObject*)item)->ob_ival = eclass->values[i].value;
+	((_PyLongObject*)item)->ob_ival = eclass->values[i].value;
 	((PyGEnum*)item)->gtype = gtype;
 	
-        intval = PyInt_FromLong(eclass->values[i].value);
+        intval = _PyLong_FromLong(eclass->values[i].value);
 	PyDict_SetItem(values, intval, item);
         Py_DECREF(intval);
 	
@@ -270,7 +270,7 @@
     if (!PyArg_ParseTuple(args, ":GEnum.__reduce__"))
         return NULL;
 
-    return Py_BuildValue("(O(i)O)", self->ob_type, PyInt_AsLong(self),
+    return Py_BuildValue("(O(i)O)", self->ob_type, _PyLong_AsLong(self),
                          PyObject_GetAttrString(self, "__dict__"));
 }
 
@@ -327,7 +327,7 @@
 {
     pygenum_class_key        = g_quark_from_static_string("PyGEnum::class");
 
-    PyGEnum_Type.tp_base = &PyInt_Type;
+    PyGEnum_Type.tp_base = &_PyLong_Type;
     PyGEnum_Type.tp_repr = (reprfunc)pyg_enum_repr;
     PyGEnum_Type.tp_str = (reprfunc)pyg_enum_repr;
     PyGEnum_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;

Modified: trunk/gobject/pygflags.c
==============================================================================
--- trunk/gobject/pygflags.c	(original)
+++ trunk/gobject/pygflags.c	Sun Jul 27 09:39:21 2008
@@ -33,14 +33,14 @@
 
 PYGLIB_DEFINE_TYPE("gobject.GFlags", PyGFlags_Type, PyGFlags);
 
-#define GET_INT_VALUE(x) (((PyIntObject*)x)->ob_ival)
+#define GET_INT_VALUE(x) (((_PyLongObject*)x)->ob_ival)
 
 static PyObject *
 pyg_flags_richcompare(PyGFlags *self, PyObject *other, int op)
 {
     static char warning[256];
 
-    if (!PyInt_Check(other)) {
+    if (!_PyLong_Check(other)) {
         Py_INCREF(Py_NotImplemented);
         return Py_NotImplemented;
     }
@@ -153,7 +153,7 @@
 
     g_type_class_unref(eclass);
     
-    pyint = PyInt_FromLong(value);
+    pyint = _PyLong_FromLong(value);
     ret = PyDict_GetItem(values, pyint);
     Py_DECREF(pyint);
     Py_DECREF(values);
@@ -176,13 +176,13 @@
     if (pyclass == NULL) {
 	pyclass = pyg_flags_add(NULL, g_type_name(gtype), NULL, gtype);
 	if (!pyclass)
-	    return PyInt_FromLong(value);
+	    return _PyLong_FromLong(value);
     }
 
     
     values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
 				  "__flags_values__");
-    pyint = PyInt_FromLong(value);
+    pyint = _PyLong_FromLong(value);
     retval = PyDict_GetItem(values, pyint);
     Py_DECREF(pyint);
 
@@ -192,7 +192,7 @@
 	retval = ((PyTypeObject *)pyclass)->tp_alloc((PyTypeObject *)pyclass, 0);
 	g_assert(retval != NULL);
 	
-	((PyIntObject*)retval)->ob_ival = value;
+	((_PyLongObject*)retval)->ob_ival = value;
 	((PyGFlags*)retval)->gtype = gtype;
     } else {
 	Py_INCREF(retval);
@@ -257,10 +257,10 @@
       PyObject *item, *intval;
       
       item = ((PyTypeObject *)stub)->tp_alloc((PyTypeObject *)stub, 0);
-      ((PyIntObject*)item)->ob_ival = eclass->values[i].value;
+      ((_PyLongObject*)item)->ob_ival = eclass->values[i].value;
       ((PyGFlags*)item)->gtype = gtype;
             
-      intval = PyInt_FromLong(eclass->values[i].value);
+      intval = _PyLong_FromLong(eclass->values[i].value);
       PyDict_SetItem(values, intval, item);
       Py_DECREF(intval);
 
@@ -290,7 +290,7 @@
 pyg_flags_and(PyGFlags *a, PyGFlags *b)
 {
 	if (!PyGFlags_Check(a) || !PyGFlags_Check(b))
-		return PyInt_Type.tp_as_number->nb_and((PyObject*)a,
+		return _PyLong_Type.tp_as_number->nb_and((PyObject*)a,
 						       (PyObject*)b);
 	
 	return pyg_flags_from_gtype(a->gtype,
@@ -301,7 +301,7 @@
 pyg_flags_or(PyGFlags *a, PyGFlags *b)
 {
 	if (!PyGFlags_Check(a) || !PyGFlags_Check(b))
-		return PyInt_Type.tp_as_number->nb_or((PyObject*)a,
+		return _PyLong_Type.tp_as_number->nb_or((PyObject*)a,
 						      (PyObject*)b);
 
 	return pyg_flags_from_gtype(a->gtype, GET_INT_VALUE(a) | GET_INT_VALUE(b));
@@ -311,7 +311,7 @@
 pyg_flags_xor(PyGFlags *a, PyGFlags *b)
 {
 	if (!PyGFlags_Check(a) || !PyGFlags_Check(b))
-		return PyInt_Type.tp_as_number->nb_xor((PyObject*)a,
+		return _PyLong_Type.tp_as_number->nb_xor((PyObject*)a,
 						       (PyObject*)b);
 
 	return pyg_flags_from_gtype(a->gtype,
@@ -466,7 +466,7 @@
 {
     pygflags_class_key       = g_quark_from_static_string("PyGFlags::class");
 
-    PyGFlags_Type.tp_base = &PyInt_Type;
+    PyGFlags_Type.tp_base = &_PyLong_Type;
     PyGFlags_Type.tp_repr = 	(reprfunc)pyg_flags_repr;
     PyGFlags_Type.tp_as_number = &pyg_flags_as_number;
     PyGFlags_Type.tp_str = (reprfunc)pyg_flags_repr;

Modified: trunk/gobject/pygobject-private.h
==============================================================================
--- trunk/gobject/pygobject-private.h	(original)
+++ trunk/gobject/pygobject-private.h	Sun Jul 27 09:39:21 2008
@@ -194,7 +194,7 @@
 
 /* pygflags */
 typedef struct {
-    PyIntObject parent;
+    _PyLongObject parent;
     GType gtype;
 } PyGFlags;
 
@@ -213,7 +213,7 @@
 #define PyGEnum_Check(x) (g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_ENUM))
 
 typedef struct {
-    PyIntObject parent;
+    _PyLongObject parent;
     GType gtype;
 } PyGEnum;
 

Modified: trunk/gobject/pygobject.c
==============================================================================
--- trunk/gobject/pygobject.c	(original)
+++ trunk/gobject/pygobject.c	Sun Jul 27 09:39:21 2008
@@ -1827,7 +1827,7 @@
 						  0, 0,
 						  closure,
 						  NULL, NULL);
-    return PyInt_FromLong(retval);
+    return _PyLong_FromLong(retval);
 }
 
 static PyObject *
@@ -1859,7 +1859,7 @@
 					     0, 0,
 					     closure,
 					     NULL, NULL);
-    return PyInt_FromLong(retval);
+    return _PyLong_FromLong(retval);
 }
 
 static PyObject *
@@ -1891,7 +1891,7 @@
 					       0, 0,
 					       closure,
 					       NULL, NULL);
-    return PyInt_FromLong(retval);
+    return _PyLong_FromLong(retval);
 }
 
 static PyMethodDef pygobject_methods[] = {
@@ -1946,7 +1946,7 @@
 static PyObject *
 pygobject_get_refcount(PyGObject *self, void *closure)
 {
-    return PyInt_FromLong(self->obj->ref_count);
+    return _PyLong_FromLong(self->obj->ref_count);
 }
 
 static int

Modified: trunk/gobject/pygparamspec.c
==============================================================================
--- trunk/gobject/pygparamspec.c	(original)
+++ trunk/gobject/pygparamspec.c	Sun Jul 27 09:39:21 2008
@@ -121,7 +121,7 @@
     } else if (!strcmp(attr, "blurb") || !strcmp(attr, "__doc__")) {
 	return Py_BuildValue("s", g_param_spec_get_blurb(pspec));
     } else if (!strcmp(attr, "flags")) {
-	return PyInt_FromLong(pspec->flags);
+	return _PyLong_FromLong(pspec->flags);
     } else if (!strcmp(attr, "value_type")) {
 	return pyg_type_wrapper_new(pspec->value_type);
     } else if (!strcmp(attr, "owner_type")) {
@@ -138,9 +138,9 @@
 	    return _PyUnicode_FromFormat(
 		"%c", G_PARAM_SPEC_CHAR(pspec)->default_value);
 	} else if (!strcmp(attr, "minimum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->minimum);
 	} else if (!strcmp(attr, "maximum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_CHAR(pspec)->maximum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_CHAR(pspec)->maximum);
 	}
     } else if (G_IS_PARAM_SPEC_UCHAR(pspec)) {
 	if (!strcmp(attr, "__members__")) {
@@ -153,9 +153,9 @@
 	    return _PyUnicode_FromFormat(
 		"%c", G_PARAM_SPEC_UCHAR(pspec)->default_value);
 	} else if (!strcmp(attr, "minimum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->minimum);
 	} else if (!strcmp(attr, "maximum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_UCHAR(pspec)->maximum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_UCHAR(pspec)->maximum);
 	}
     } else if (G_IS_PARAM_SPEC_BOOLEAN(pspec)) {
 	if (!strcmp(attr, "__members__")) {
@@ -173,11 +173,11 @@
 				 "flags", "maximum", "minimum", "name",
 				 "nick", "owner_type", "value_type");
 	} else if (!strcmp(attr, "default_value")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_INT(pspec)->default_value);
+	    return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->default_value);
 	} else if (!strcmp(attr, "minimum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_INT(pspec)->minimum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->minimum);
 	} else if (!strcmp(attr, "maximum")) {
-	    return PyInt_FromLong(G_PARAM_SPEC_INT(pspec)->maximum);
+	    return _PyLong_FromLong(G_PARAM_SPEC_INT(pspec)->maximum);
 	}
     } else if (G_IS_PARAM_SPEC_UINT(pspec)) {
 	if (!strcmp(attr, "__members__")) {

Modified: trunk/gobject/pygtype.c
==============================================================================
--- trunk/gobject/pygtype.c	(original)
+++ trunk/gobject/pygtype.c	Sun Jul 27 09:39:21 2008
@@ -139,7 +139,7 @@
 static PyObject *
 _wrap_g_type_wrapper__get_depth(PyGTypeWrapper *self, void *closure)
 {
-  return PyInt_FromLong(g_type_depth(self->type));
+  return _PyLong_FromLong(g_type_depth(self->type));
 }
 
 static PyGetSetDef _PyGTypeWrapper_getsets[] = {
@@ -323,7 +323,7 @@
     if (PyType_Check(obj)) {
 	PyTypeObject *tp = (PyTypeObject *)obj;
 
-	if (tp == &PyInt_Type)
+	if (tp == &_PyLong_Type)
 	    return G_TYPE_INT;
 	else if (tp == &PyBool_Type)
 	    return G_TYPE_BOOLEAN;
@@ -393,8 +393,8 @@
     if (!obj) {
 	*val = 0;
 	res = 0;
-    } else if (PyInt_Check(obj)) {
-	*val = PyInt_AsLong(obj);
+    } else if (_PyLong_Check(obj)) {
+	*val = _PyLong_AsLong(obj);
 	res = 0;
 
 	if (PyObject_TypeCheck(obj, &PyGEnum_Type) && ((PyGEnum *) obj)->gtype != enum_type) {
@@ -456,8 +456,8 @@
     if (!obj) {
 	*val = 0;
 	res = 0;
-    } else if (PyInt_Check(obj)) {
-	*val = PyInt_AsLong(obj);
+    } else if (_PyLong_Check(obj)) {
+	*val = _PyLong_AsLong(obj);
 	res = 0;
     } else if (PyLong_Check(obj)) {
         *val = PyLong_AsLongLong(obj);
@@ -691,7 +691,7 @@
 	g_value_set_boolean(value, PyObject_IsTrue(obj));
 	break;
     case G_TYPE_INT:
-	g_value_set_int(value, PyInt_AsLong(obj));
+	g_value_set_int(value, _PyLong_AsLong(obj));
 	if (PyErr_Occurred()) {
 	    g_value_unset(value);
 	    PyErr_Clear();
@@ -700,10 +700,10 @@
 	break;
     case G_TYPE_UINT:
 	{
-	    if (PyInt_Check(obj)) {
+	    if (_PyLong_Check(obj)) {
 		glong val;
 
-		val = PyInt_AsLong(obj);
+		val = _PyLong_AsLong(obj);
 		if (val >= 0 && val <= G_MAXUINT)
 		    g_value_set_uint(value, (guint)val);
 		else
@@ -719,7 +719,7 @@
 	}
 	break;
     case G_TYPE_LONG:
-	g_value_set_long(value, PyInt_AsLong(obj));
+	g_value_set_long(value, _PyLong_AsLong(obj));
 	if (PyErr_Occurred()) {
 	    g_value_unset(value);
 	    PyErr_Clear();
@@ -728,10 +728,10 @@
 	break;
     case G_TYPE_ULONG:
 	{
-	    if (PyInt_Check(obj)) {
+	    if (_PyLong_Check(obj)) {
 		glong val;
 
-		val = PyInt_AsLong(obj);
+		val = _PyLong_AsLong(obj);
 		if (val >= 0)
 		    g_value_set_ulong(value, (gulong)val);
 		else
@@ -755,8 +755,8 @@
 	}
 	break;
     case G_TYPE_UINT64:
-        if (PyInt_Check(obj))
-            g_value_set_uint64(value, PyInt_AsLong(obj));
+        if (_PyLong_Check(obj))
+            g_value_set_uint64(value, _PyLong_AsLong(obj));
         else if (PyLong_Check(obj))
             g_value_set_uint64(value, PyLong_AsUnsignedLongLong(obj));
         else
@@ -926,7 +926,7 @@
 	return PyBool_FromLong(g_value_get_boolean(value));
     }
     case G_TYPE_INT:
-	return PyInt_FromLong(g_value_get_int(value));
+	return _PyLong_FromLong(g_value_get_int(value));
     case G_TYPE_UINT:
 	{
 	    /* in Python, the Int object is backed by a long.  If a
@@ -934,19 +934,19 @@
 	       an Int.  Otherwise, use a Long object to avoid overflow.
 	       This matches the ULongArg behavior in codegen/argtypes.h */
 #if (G_MAXUINT <= G_MAXLONG)
-	    return PyInt_FromLong((glong) g_value_get_uint(value));
+	    return _PyLong_FromLong((glong) g_value_get_uint(value));
 #else
 	    return PyLong_FromUnsignedLong((gulong) g_value_get_uint(value));
 #endif
 	}
     case G_TYPE_LONG:
-	return PyInt_FromLong(g_value_get_long(value));
+	return _PyLong_FromLong(g_value_get_long(value));
     case G_TYPE_ULONG:
 	{
 	    gulong val = g_value_get_ulong(value);
 
 	    if (val <= G_MAXLONG)
-		return PyInt_FromLong((glong) val);
+		return _PyLong_FromLong((glong) val);
 	    else
 		return PyLong_FromUnsignedLong(val);
 	}
@@ -955,7 +955,7 @@
 	    gint64 val = g_value_get_int64(value);
 
 	    if (G_MINLONG <= val && val <= G_MAXLONG)
-		return PyInt_FromLong((glong) val);
+		return _PyLong_FromLong((glong) val);
 	    else
 		return PyLong_FromLongLong(val);
 	}
@@ -964,7 +964,7 @@
 	    guint64 val = g_value_get_uint64(value);
 
 	    if (val <= G_MAXLONG)
-		return PyInt_FromLong((glong) val);
+		return _PyLong_FromLong((glong) val);
 	    else
 		return PyLong_FromUnsignedLongLong(val);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]