diff options
| author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2006-04-11 21:51:06 +0000 |
|---|---|---|
| committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2006-04-11 21:51:06 +0000 |
| commit | 921eb7103fce05bb55aaadc0bcd3527781a1b229 (patch) | |
| tree | 34e9d19e16167878c437ef27632c27d7d35508eb /gobject/pygobject.c | |
| parent | 2b30a70e7b7d2111910ebbf76750bdefe51381ff (diff) | |
| download | pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.tar.gz pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.tar.xz pygobject-921eb7103fce05bb55aaadc0bcd3527781a1b229.zip | |
Move GObjectMeta from C to python-land
Diffstat (limited to 'gobject/pygobject.c')
| -rw-r--r-- | gobject/pygobject.c | 92 |
1 files changed, 3 insertions, 89 deletions
diff --git a/gobject/pygobject.c b/gobject/pygobject.c index a4fb38a..b9a51b1 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -34,6 +34,8 @@ typedef struct { } SinkFunc; static GArray *sink_funcs = NULL; +PyTypeObject *PyGObject_MetaType = NULL; + /** * pygobject_sink: * @obj: a GObject @@ -514,7 +516,7 @@ pygobject_register_class(PyObject *dict, const gchar *type_name, } else bases = runtime_bases; - type->ob_type = &PyGObject_MetaType; + type->ob_type = PyGObject_MetaType; type->tp_bases = bases; if (G_LIKELY(bases)) { type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0); @@ -1726,91 +1728,3 @@ PyTypeObject PyGObject_Type = { }; -static int -pygobjectmeta_register(PyTypeObject *subtype) -{ - PyObject *pytype_name; - const char *type_name = NULL; - int retval = 0; - - /* Maybe the type doesn't really need to registered? */ - if (subtype->tp_dict == NULL) - goto out; - - if (!(PyDict_GetItemString(subtype->tp_dict, "__gtype_name__") - || PyDict_GetItemString(subtype->tp_dict, "__gproperties__") - || PyDict_GetItemString(subtype->tp_dict, "__gsignals__"))) - goto out; - - /* If it's already registered, skip registration */ - if (PyDict_GetItemString(subtype->tp_dict, "__gtype__")) - goto out; - - pytype_name = PyDict_GetItemString(subtype->tp_dict, "__gtype_name__"); - if (pytype_name) - type_name = PyString_AsString(pytype_name); - retval = pyg_type_register(subtype, type_name); - -out: - return retval; -} - -/* -------- GObject MetaClass -----------*/ -static int -pygobjectmeta_init(PyTypeObject *subtype, PyObject *args, PyObject *kwargs) -{ - if (PyType_Type.tp_init((PyObject *) subtype, args, kwargs)) - return -1; - - return pygobjectmeta_register(subtype); -} - - -PyTypeObject PyGObject_MetaType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "gobject.GObjectMeta", /* tp_name */ - 0, /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor)0, /* tp_dealloc */ - (printfunc)0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc)0, /* tp_getattro */ - (setattrofunc)0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE, /* tp_flags */ - "GObject Metaclass -- automatically registers GObject subclasses " - "as new GType's", /* Documentation string */ - (traverseproc)0, /* tp_traverse */ - (inquiry)0, /* tp_clear */ - (richcmpfunc)0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - NULL, /* tp_base */ - (PyObject *)0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)pygobjectmeta_init, /* tp_init */ - (allocfunc)0, /* tp_alloc */ - (newfunc)0, /* tp_new */ - 0, /* tp_free */ - (inquiry)0, /* tp_is_gc */ - NULL, /* tp_bases */ -}; - - |
