diff options
author | Johan Dahlin <johan@src.gnome.org> | 2005-07-05 20:38:56 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2005-07-05 20:38:56 +0000 |
commit | 8914f109dc0515d8927c76b29ec5b46317965b68 (patch) | |
tree | 682f2eb1919ba86d87a98d14a22616e201a12552 /gobject/gobjectmodule.c | |
parent | 4dd8caf2aae815a22e07f035839bf43739d03feb (diff) | |
download | pygobject-8914f109dc0515d8927c76b29ec5b46317965b68.tar.gz pygobject-8914f109dc0515d8927c76b29ec5b46317965b68.tar.xz pygobject-8914f109dc0515d8927c76b29ec5b46317965b68.zip |
Add GType.is_a and deprecate gobject.type_* Update tests and make
* gobject/gobjectmodule.c: (pyg_type_name), (pyg_type_from_name),
(pyg_type_parent), (pyg_type_is_a), (pyg_type_children),
(pyg_type_interfaces), (get_type_name_for_class), (initgobject):
* gobject/pygtype.c: (_wrap_g_type_is_a), (pyg_type_wrapper_init):
* tests/test_enum.py:
* tests/test_gtype.py:
* tests/test_unknown.py:
Add GType.is_a and deprecate gobject.type_*
Update tests
and make GType.is_a/gobject.type_is_a return a bool instead of int
Diffstat (limited to 'gobject/gobjectmodule.c')
-rw-r--r-- | gobject/gobjectmodule.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index e24313e..d054635 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -238,6 +238,11 @@ pyg_type_name (PyObject *self, PyObject *args) GType type; const gchar *name; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_name is deprecated; " + "use GType.name instead")) + return NULL; + if (!PyArg_ParseTuple(args, "O:gobject.type_name", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -255,6 +260,11 @@ pyg_type_from_name (PyObject *self, PyObject *args) const gchar *name; GType type; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_from_name is deprecated; " + "use GType.from_name instead")) + return NULL; + if (!PyArg_ParseTuple(args, "s:gobject.type_from_name", &name)) return NULL; type = g_type_from_name(name); @@ -270,6 +280,11 @@ pyg_type_parent (PyObject *self, PyObject *args) PyObject *gtype; GType type, parent; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_parent is deprecated; " + "use GType.parent instead")) + return NULL; + if (!PyArg_ParseTuple(args, "O:gobject.type_parent", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -287,13 +302,18 @@ pyg_type_is_a (PyObject *self, PyObject *args) PyObject *gtype, *gparent; GType type, parent; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_is_a is deprecated; " + "use GType.is_a instead")) + return NULL; + if (!PyArg_ParseTuple(args, "OO:gobject.type_is_a", >ype, &gparent)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) return NULL; if ((parent = pyg_type_from_object(gparent)) == 0) return NULL; - return PyInt_FromLong(g_type_is_a(type, parent)); + return PyBool_FromLong(g_type_is_a(type, parent)); } static PyObject * @@ -303,6 +323,11 @@ pyg_type_children (PyObject *self, PyObject *args) GType type, *children; guint n_children, i; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_children is deprecated; " + "use GType.children instead")) + return NULL; + if (!PyArg_ParseTuple(args, "O:gobject.type_children", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -329,6 +354,11 @@ pyg_type_interfaces (PyObject *self, PyObject *args) GType type, *interfaces; guint n_interfaces, i; + if (PyErr_Warn(PyExc_DeprecationWarning, + "gobject.type_interfaces is deprecated; " + "use GType.interfaces instead")) + return NULL; + if (!PyArg_ParseTuple(args, "O:gobject.type_interfaces", >ype)) return NULL; if ((type = pyg_type_from_object(gtype)) == 0) @@ -962,7 +992,7 @@ get_type_name_for_class(PyTypeObject *class) gint i, name_serial; char name_serial_str[16]; PyObject *module; - char *type_name = NULL; + char *type_name; /* make name for new GType */ name_serial = 1; @@ -2512,8 +2542,6 @@ DL_EXPORT(void) initgobject(void) { PyObject *m, *d, *o, *tuple; - - PyGTypeWrapper_Type.ob_type = &PyType_Type; PyGParamSpec_Type.ob_type = &PyType_Type; m = Py_InitModule("gobject", pygobject_functions); @@ -2532,8 +2560,7 @@ initgobject(void) pyginterface_info_key = g_quark_from_static_string("PyGInterface::info"); pygpointer_class_key = g_quark_from_static_string("PyGPointer::class"); - PyType_Ready(&PyGTypeWrapper_Type); - PyDict_SetItemString(d, "GType", (PyObject *)&PyGTypeWrapper_Type); + REGISTER_TYPE(d, PyGTypeWrapper_Type, "GType"); PY_TYPE_OBJECT = g_boxed_type_register_static("PyObject", pyobject_copy, |