pygobject r886 - in trunk: . glib gobject



Author: johan
Date: Sun Jul 27 10:07:55 2008
New Revision: 886
URL: http://svn.gnome.org/viewvc/pygobject?rev=886&view=rev

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

    * glib/pyglib-python-compat.h:
    * gobject/gobjectmodule.c (pyg_object_new),
    (pyg__install_metaclass):
    * gobject/pygboxed.c (pyg_boxed_dealloc), (pyg_boxed_init),
    (pyg_register_boxed):
    * gobject/pygenum.c (pyg_enum_reduce):
    * gobject/pyginterface.c (pyg_interface_init),
    (pyg_register_interface):
    * gobject/pygobject.c (pygobject_get_inst_data),
    (pygobject_register_class), (pygobject_new_with_interfaces),
    (pygobject_dealloc), (pygobject_repr), (pygobject_emit),
    (pygobject_chain_from_overridden), (pygobject_weak_ref_notify):
    * gobject/pygparamspec.c (pygobject_paramspec_register_types):
    * gobject/pygpointer.c (pyg_pointer_dealloc), (pyg_pointer_init),
    (pyg_register_pointer):
    * gobject/pygtype.c (pyg_type_from_object),
    (pyg_value_array_from_pyobject), (pyg_value_from_pyobject),
    (pyg_object_descr_doc_get):
    Use the Py_TYPE macro everywhere.



Modified:
   trunk/ChangeLog
   trunk/glib/pyglib-python-compat.h
   trunk/gobject/gobjectmodule.c
   trunk/gobject/pygboxed.c
   trunk/gobject/pygenum.c
   trunk/gobject/pyginterface.c
   trunk/gobject/pygobject.c
   trunk/gobject/pygparamspec.c
   trunk/gobject/pygpointer.c
   trunk/gobject/pygtype.c

Modified: trunk/glib/pyglib-python-compat.h
==============================================================================
--- trunk/glib/pyglib-python-compat.h	(original)
+++ trunk/glib/pyglib-python-compat.h	Sun Jul 27 10:07:55 2008
@@ -45,7 +45,7 @@
 #define _PyLongObject PyIntObject
 #define _PyLong_Type PyInt_Type
 #define _PyLong_AS_LONG PyInt_AS_LONG
-#define Py_TYPE(ob) (ob->ob_type)
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
 #else
 #undef PYGLIB_MODULE_START
 #undef PYGLIB_MODULE_END

Modified: trunk/gobject/gobjectmodule.c
==============================================================================
--- trunk/gobject/gobjectmodule.c	(original)
+++ trunk/gobject/gobjectmodule.c	Sun Jul 27 10:07:55 2008
@@ -1715,7 +1715,7 @@
 					       value, pspec) < 0) {
 		PyErr_Format(PyExc_TypeError,
 			     "could not convert value for property `%s' from %s to %s",
-			     key_str, value->ob_type->tp_name,
+			     key_str, Py_TYPE(value)->tp_name,
 			     g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec)));
 		goto cleanup;
 	    }
@@ -1944,7 +1944,9 @@
     Py_INCREF(metaclass);
     PyGObject_MetaType = metaclass;
     Py_INCREF(metaclass);
-    PyGObject_Type.ob_type = metaclass;
+
+    Py_TYPE(&PyGObject_Type) = metaclass;
+
     Py_INCREF(Py_None);
     return Py_None;
 }

Modified: trunk/gobject/pygboxed.c
==============================================================================
--- trunk/gobject/pygboxed.c	(original)
+++ trunk/gobject/pygboxed.c	Sun Jul 27 10:07:55 2008
@@ -42,7 +42,7 @@
 	pyglib_gil_state_release(state);
     }
 
-    self->ob_type->tp_free((PyObject *)self);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static int
@@ -81,7 +81,8 @@
     self->gtype = 0;
     self->free_on_dealloc = FALSE;
 
-    g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+    g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+	       Py_TYPE(self)->tp_name);
     PyErr_SetString(PyExc_NotImplementedError, buf);
     return -1;
 }
@@ -129,7 +130,7 @@
 
     if (!type->tp_dealloc)  type->tp_dealloc  = (destructor)pyg_boxed_dealloc;
 
-    type->ob_type = &PyType_Type;
+    Py_TYPE(type) = &PyType_Type;
     type->tp_base = &PyGBoxed_Type;
 
     if (PyType_Ready(type) < 0) {

Modified: trunk/gobject/pygenum.c
==============================================================================
--- trunk/gobject/pygenum.c	(original)
+++ trunk/gobject/pygenum.c	Sun Jul 27 10:07:55 2008
@@ -278,7 +278,7 @@
     if (!PyArg_ParseTuple(args, ":GEnum.__reduce__"))
         return NULL;
 
-    return Py_BuildValue("(O(i)O)", self->ob_type, _PyLong_AsLong(self),
+    return Py_BuildValue("(O(i)O)", Py_TYPE(self), _PyLong_AsLong(self),
                          PyObject_GetAttrString(self, "__dict__"));
 }
 

Modified: trunk/gobject/pyginterface.c
==============================================================================
--- trunk/gobject/pyginterface.c	(original)
+++ trunk/gobject/pyginterface.c	Sun Jul 27 10:07:55 2008
@@ -41,7 +41,8 @@
     if (!PyArg_ParseTuple(args, ":GInterface.__init__"))
 	return -1;
 
-    g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+    g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+	       Py_TYPE(self)->tp_name);
     PyErr_SetString(PyExc_NotImplementedError, buf);
     return -1;
 }
@@ -69,7 +70,7 @@
 {
     PyObject *o;
 
-    type->ob_type = &PyType_Type;
+    Py_TYPE(type) = &PyType_Type;
     type->tp_base = &PyGInterface_Type;
 
     if (PyType_Ready(type) < 0) {

Modified: trunk/gobject/pygobject.c
==============================================================================
--- trunk/gobject/pygobject.c	(original)
+++ trunk/gobject/pygobject.c	Sun Jul 27 10:07:55 2008
@@ -97,7 +97,7 @@
     {
         inst_data = pygobject_data_new();
 
-        inst_data->type = ((PyObject *)self)->ob_type;
+        inst_data->type = Py_TYPE(self);
         Py_INCREF((PyObject *) inst_data->type);
 
         g_object_set_qdata_full(self->obj, pygobject_instance_data_key,
@@ -497,7 +497,7 @@
     } else
         bases = runtime_bases;
 
-    type->ob_type = PyGObject_MetaType;
+    Py_TYPE(type) = PyGObject_MetaType;
     type->tp_bases = bases;
     if (G_LIKELY(bases)) {
         type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0);
@@ -694,7 +694,7 @@
 	type_name = g_strconcat(mod_name, ".", gtype_name, NULL);
     }
 
-    type = (PyTypeObject*)PyObject_CallFunction((PyObject *) py_parent_type->ob_type,
+    type = (PyTypeObject*)PyObject_CallFunction((PyObject *) Py_TYPE(py_parent_type),
                                                 "sNN", type_name, bases, dict);
     g_free(type_name);
 
@@ -897,7 +897,7 @@
     pygobject_get_inst_data(self);
     pygobject_clear(self);
     /* the following causes problems with subclassed types */
-    /* self->ob_type->tp_free((PyObject *)self); */
+    /* Py_TYPE(self)->tp_free((PyObject *)self); */
     PyObject_GC_Del(self);
 }
 
@@ -922,7 +922,7 @@
 
     g_snprintf(buf, sizeof(buf),
 	       "<%s object at 0x%lx (%s at 0x%lx)>",
-	       self->ob_type->tp_name,
+	       Py_TYPE(self)->tp_name,
 	       (long)self,
 	       self->obj ? G_OBJECT_TYPE_NAME(self->obj) : "uninitialized",
                (long)self->obj);
@@ -1066,7 +1066,7 @@
     if (!G_IS_OBJECT(self->obj)) {                                           \
 	PyErr_Format(PyExc_TypeError,                                        \
                      "object at %p of type %s is not initialized",	     \
-                     self, self->ob_type->tp_name);                          \
+                     self, Py_TYPE(self)->tp_name);			     \
 	return NULL;                                                         \
     }
 
@@ -1622,8 +1622,8 @@
 	if (pyg_value_from_pyobject(&params[i+1], item) < 0) {
 	    gchar buf[128];
 	    g_snprintf(buf, sizeof(buf),
-		"could not convert type %s to %s required for parameter %d",
-		item->ob_type->tp_name,
+		       "could not convert type %s to %s required for parameter %d",
+		       Py_TYPE(item)->tp_name,
 		g_type_name(G_VALUE_TYPE(&params[i+1])), i);
 	    PyErr_SetString(PyExc_TypeError, buf);
 
@@ -1734,9 +1734,9 @@
 	    gchar buf[128];
 
 	    g_snprintf(buf, sizeof(buf),
-		"could not convert type %s to %s required for parameter %d",
-		item->ob_type->tp_name,
-		g_type_name(G_VALUE_TYPE(&params[i+1])), i);
+		       "could not convert type %s to %s required for parameter %d",
+		       Py_TYPE(item)->tp_name,
+		       g_type_name(G_VALUE_TYPE(&params[i+1])), i);
 	    PyErr_SetString(PyExc_TypeError, buf);
 	    for (i = 0; i < query.n_params + 1; i++)
 		g_value_unset(&params[i]);
@@ -2007,7 +2007,7 @@
                 PyErr_Format(PyExc_TypeError,
                              "GObject weak notify callback returned a value"
                              " of type %s, should return None",
-                             retval->ob_type->tp_name);
+                             Py_TYPE(retval)->tp_name);
             Py_DECREF(retval);
             PyErr_Print();
         } else

Modified: trunk/gobject/pygparamspec.c
==============================================================================
--- trunk/gobject/pygparamspec.c	(original)
+++ trunk/gobject/pygparamspec.c	Sun Jul 27 10:07:55 2008
@@ -384,7 +384,7 @@
 void
 pygobject_paramspec_register_types(PyObject *d)
 {
-    PyGParamSpec_Type.ob_type = &PyType_Type;
+    Py_TYPE(&PyGParamSpec_Type) = &PyType_Type;
     PyGParamSpec_Type.tp_dealloc = (destructor)pyg_param_spec_dealloc;
     PyGParamSpec_Type.tp_getattr = (getattrfunc)pyg_param_spec_getattr;
     PyGParamSpec_Type.tp_compare = (cmpfunc)pyg_param_spec_compare;

Modified: trunk/gobject/pygpointer.c
==============================================================================
--- trunk/gobject/pygpointer.c	(original)
+++ trunk/gobject/pygpointer.c	Sun Jul 27 10:07:55 2008
@@ -35,7 +35,7 @@
 static void
 pyg_pointer_dealloc(PyGPointer *self)
 {
-    self->ob_type->tp_free((PyObject *)self);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static int
@@ -73,7 +73,8 @@
     self->pointer = NULL;
     self->gtype = 0;
 
-    g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+    g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+	       Py_TYPE(self)->tp_name);
     PyErr_SetString(PyExc_NotImplementedError, buf);
     return -1;
 }
@@ -107,7 +108,7 @@
 
     if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_pointer_dealloc;
 
-    type->ob_type = &PyType_Type;
+    Py_TYPE(&type) = &PyType_Type;
     type->tp_base = &PyGPointer_Type;
 
     if (PyType_Ready(type) < 0) {

Modified: trunk/gobject/pygtype.c
==============================================================================
--- trunk/gobject/pygtype.c	(original)
+++ trunk/gobject/pygtype.c	Sun Jul 27 10:07:55 2008
@@ -337,7 +337,7 @@
 	    return PY_TYPE_OBJECT;
     }
 
-    if (obj->ob_type == &PyGTypeWrapper_Type) {
+    if (Py_TYPE(obj) == &PyGTypeWrapper_Type) {
 	return ((PyGTypeWrapper *)obj)->type;
     }
 
@@ -355,7 +355,7 @@
     gtype = PyObject_GetAttrString(obj, "__gtype__");
 
     if (gtype) {
-	if (gtype->ob_type == &PyGTypeWrapper_Type) {
+	if (Py_TYPE(gtype) == &PyGTypeWrapper_Type) {
 	    type = ((PyGTypeWrapper *)gtype)->type;
 	    Py_DECREF(gtype);
 	    return type;
@@ -607,7 +607,7 @@
 	else if (item == Py_None)
 	    type = G_TYPE_POINTER; /* store None as NULL */
 	else {
-	    type = pyg_type_from_object((PyObject *) item->ob_type);
+	    type = pyg_type_from_object((PyObject*)Py_TYPE(item));
 	    if (! type) {
 		PyErr_Clear();
 		g_value_array_free(value_array);
@@ -834,7 +834,7 @@
             GType type;
             GValue *n_value; 
             
-            type = pyg_type_from_object((PyObject *)obj->ob_type);
+            type = pyg_type_from_object((PyObject*)Py_TYPE(obj));
             if (G_UNLIKELY (! type)) {
                 PyErr_Clear();
                 return -1;
@@ -1507,7 +1507,7 @@
     static PyObject *doc_descr = NULL;
 
     if (!doc_descr) {
-	PyGObjectDoc_Type.ob_type = &PyType_Type;
+	Py_TYPE(&PyGObjectDoc_Type) = &PyType_Type;
 	if (PyType_Ready(&PyGObjectDoc_Type))
 	    return NULL;
 



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