diff options
| author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-05-28 15:26:59 +0000 |
|---|---|---|
| committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-05-28 15:26:59 +0000 |
| commit | f1b1ae700dd247b387d8b22f36e50bf40e936eba (patch) | |
| tree | 401d6ac81f271db868d3711649234f9328d482cf /gobject | |
| parent | bc6b796d83f1022c6335c6360fc557d531ac0415 (diff) | |
| download | pygobject-f1b1ae700dd247b387d8b22f36e50bf40e936eba.tar.gz pygobject-f1b1ae700dd247b387d8b22f36e50bf40e936eba.tar.xz pygobject-f1b1ae700dd247b387d8b22f36e50bf40e936eba.zip | |
gquark initialization cleanup
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/gobjectmodule.c | 35 | ||||
| -rw-r--r-- | gobject/pygboxed.c | 8 | ||||
| -rw-r--r-- | gobject/pygenum.c | 5 | ||||
| -rw-r--r-- | gobject/pygflags.c | 6 | ||||
| -rw-r--r-- | gobject/pygobject-private.h | 12 | ||||
| -rw-r--r-- | gobject/pygobject.c | 16 | ||||
| -rw-r--r-- | gobject/pygparamspec.c | 8 | ||||
| -rw-r--r-- | gobject/pygpointer.c | 9 | ||||
| -rw-r--r-- | gobject/pygtype.c | 4 |
9 files changed, 41 insertions, 62 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index bdfc945..ce6dc56 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -28,18 +28,22 @@ #include "pythread.h" static PyObject *gerror_exc = NULL; -static const gchar *pyginterface_type_id = "PyGInterface::type"; -GQuark pyginterface_type_key = 0; -static const gchar *pygobject_class_init_id = "PyGObject::class-init"; -GQuark pygobject_class_init_key = 0; -static const gchar *pyginterface_info_id = "PyGInterface::info"; -GQuark pyginterface_info_key = 0; +static gboolean use_gil_state_api = FALSE; +GQuark pyginterface_type_key; +GQuark pygobject_class_init_key; +GQuark pyginterface_info_key; +GQuark pygboxed_type_key; +GQuark pygobject_class_key; +GQuark pygobject_wrapper_key; +GQuark pyg_boxed_marshal_key; +GQuark pygenum_class_key; +GQuark pygflags_class_key; +GQuark pygpointer_class_key; static void pyg_flags_add_constants(PyObject *module, GType flags_type, const gchar *strip_prefix); -static gboolean use_gil_state_api = FALSE; /* -------------- GDK threading hooks ---------------------------- */ @@ -2480,6 +2484,19 @@ initgobject(void) g_type_init(); + pyginterface_type_key = g_quark_from_static_string("PyGInterface::type"); + pygobject_wrapper_key = g_quark_from_static_string("PyGObject::wrapper"); + pygobject_class_key = g_quark_from_static_string("PyGObject::class"); + pygboxed_type_key = g_quark_from_static_string("PyGBoxed::class"); + pyginterface_type_key = g_quark_from_static_string("PyGInterface::type"); + pyginterface_info_key = g_quark_from_static_string("PyGInterface::info"); + pygobject_class_init_key = g_quark_from_static_string("PyGObject::class-init"); + pyg_boxed_marshal_key = g_quark_from_static_string("PyGBoxed::marshal"); + pygenum_class_key = g_quark_from_static_string("PyGEnum::class"); + pygflags_class_key = g_quark_from_static_string("PyGFlags::class"); + pygpointer_class_key = g_quark_from_static_string("PyGPointer::class"); + + PY_TYPE_OBJECT = g_boxed_type_register_static("PyObject", pyobject_copy, pyobject_free); @@ -2505,10 +2522,6 @@ initgobject(void) pyg_object_descr_doc_get()); PyDict_SetItemString(PyGInterface_Type.tp_dict, "__gdoc__", pyg_object_descr_doc_get()); - pyginterface_type_key = g_quark_from_static_string(pyginterface_type_id); - pyginterface_info_key = g_quark_from_static_string(pyginterface_info_id); - - pygobject_class_init_key = g_quark_from_static_string(pygobject_class_init_id); REGISTER_GTYPE(d, PyGBoxed_Type, "GBoxed", G_TYPE_BOXED); REGISTER_GTYPE(d, PyGPointer_Type, "GPointer", G_TYPE_POINTER); diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c index cb7636c..93c86ad 100644 --- a/gobject/pygboxed.c +++ b/gobject/pygboxed.c @@ -146,7 +146,6 @@ PyTypeObject PyGBoxed_Type = { (PyObject *)0, /* tp_bases */ }; -static GQuark boxed_type_id = 0; /** * pyg_register_boxed: @@ -169,9 +168,6 @@ pyg_register_boxed(PyObject *dict, const gchar *class_name, g_return_if_fail(class_name != NULL); g_return_if_fail(boxed_type != 0); - if (!boxed_type_id) - boxed_type_id = g_quark_from_static_string("PyGBoxed::class"); - if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_boxed_dealloc; type->ob_type = &PyType_Type; @@ -186,7 +182,7 @@ pyg_register_boxed(PyObject *dict, const gchar *class_name, o=pyg_type_wrapper_new(boxed_type)); Py_DECREF(o); - g_type_set_qdata(boxed_type, boxed_type_id, type); + g_type_set_qdata(boxed_type, pygboxed_type_key, type); PyDict_SetItemString(dict, (char *)class_name, (PyObject *)type); } @@ -225,7 +221,7 @@ pyg_boxed_new(GType boxed_type, gpointer boxed, gboolean copy_boxed, return Py_None; } - tp = g_type_get_qdata(boxed_type, boxed_type_id); + tp = g_type_get_qdata(boxed_type, pygboxed_type_key); if (!tp) tp = (PyTypeObject *)&PyGBoxed_Type; /* fallback */ self = PyObject_NEW(PyGBoxed, tp); diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 9f32c66..aceba9d 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -27,8 +27,6 @@ #include "pygobject-private.h" -static const gchar *pygenum_class_id = "PyGEnum::class"; -static GQuark pygenum_class_key = 0; #define GET_INT(x) (((PyIntObject*)x)->ob_ival) static int @@ -198,9 +196,6 @@ pyg_enum_add (PyObject * module, "__module__", PyString_FromString(PyModule_GetName(module))); - if (!pygenum_class_key) - pygenum_class_key = g_quark_from_static_string(pygenum_class_id); - g_type_set_qdata(gtype, pygenum_class_key, stub); o = pyg_type_wrapper_new(gtype); diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 7f052a4..2f12324 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -27,9 +27,6 @@ #include "pygobject-private.h" -static const gchar *pygflags_class_id = "PyGFlags::class"; -static GQuark pygflags_class_key = 0; - #define GET_INT_VALUE(x) (((PyIntObject*)x)->ob_ival) static int pyg_flags_compare(PyGFlags *self, PyObject *other) @@ -225,9 +222,6 @@ pyg_flags_add (PyObject * module, PyModule_AddObject(module, (char*)typename, stub); Py_INCREF(stub); - if (!pygflags_class_key) - pygflags_class_key = g_quark_from_static_string(pygflags_class_id); - g_type_set_qdata(gtype, pygflags_class_key, stub); o = pyg_type_wrapper_new(gtype); diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h index 7710acd..18d05af 100644 --- a/gobject/pygobject-private.h +++ b/gobject/pygobject-private.h @@ -41,6 +41,17 @@ extern struct _PyGObject_Functions pygobject_api_functions; extern GType PY_TYPE_OBJECT; +extern GQuark pyginterface_type_key; +extern GQuark pygobject_class_init_key; +extern GQuark pyginterface_info_key; +extern GQuark pygboxed_type_key; +extern GQuark pygobject_class_key; +extern GQuark pygobject_wrapper_key; +extern GQuark pyg_boxed_marshal_key; +extern GQuark pygenum_class_key; +extern GQuark pygflags_class_key; +extern GQuark pygpointer_class_key; + void pyg_destroy_notify (gpointer user_data); gboolean pyg_error_check(GError **error); @@ -82,7 +93,6 @@ extern PyTypeObject PyGObject_MetaType; /* from pygobject.h */ extern PyTypeObject PyGObject_Type; extern PyTypeObject PyGInterface_Type; -extern GQuark pyginterface_type_key; void pygobject_register_class (PyObject *dict, const gchar *type_name, diff --git a/gobject/pygobject.c b/gobject/pygobject.c index fdc9026..691b1f1 100644 --- a/gobject/pygobject.c +++ b/gobject/pygobject.c @@ -21,11 +21,6 @@ */ #include "pygobject-private.h" -static const gchar *pygobject_class_id = "PyGObject::class"; -static GQuark pygobject_class_key = 0; -static const gchar *pygobject_wrapper_id = "PyGObject::wrapper"; -static GQuark pygobject_wrapper_key = 0; - static void pygobject_dealloc(PyGObject *self); static int pygobject_traverse(PyGObject *self, visitproc visit, void *arg); static int pygobject_clear(PyGObject *self); @@ -106,8 +101,6 @@ pygobject_register_class(PyObject *dict, const gchar *type_name, PyObject *o; const char *class_name, *s; - if (!pygobject_class_key) - pygobject_class_key = g_quark_from_static_string(pygobject_class_id); class_name = type->tp_name; s = strrchr(class_name, '.'); @@ -158,9 +151,6 @@ pygobject_register_wrapper(PyObject *self) { GObject *obj = ((PyGObject *)self)->obj; - if (!pygobject_wrapper_key) - pygobject_wrapper_key=g_quark_from_static_string(pygobject_wrapper_id); - sink_object(obj); Py_INCREF(self); g_object_set_qdata_full(obj, pygobject_wrapper_key, self, @@ -283,9 +273,6 @@ pygobject_new_with_interfaces(GType gtype) PyDict_SetItemString(mod_dict, gtype_name, (PyObject *)type); } - if (!pygobject_class_key) - pygobject_class_key = g_quark_from_static_string(pygobject_class_id); - /* stash a pointer to the python class with the GType */ Py_INCREF(type); g_type_set_qdata(gtype, pygobject_class_key, type); @@ -341,9 +328,6 @@ pygobject_new(GObject *obj) { PyGObject *self; - if (!pygobject_wrapper_key) - pygobject_wrapper_key = g_quark_from_static_string(pygobject_wrapper_id); - if (obj == NULL) { Py_INCREF(Py_None); return Py_None; diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c index eb4b108..28f9f47 100644 --- a/gobject/pygparamspec.c +++ b/gobject/pygparamspec.c @@ -63,15 +63,13 @@ pyg_param_spec_dealloc(PyGParamSpec *self) static PyObject * pygenum_from_pspec(GParamSpec *pspec) { - GQuark quark; PyObject *pyclass; GParamSpecEnum *enum_pspec; GType enum_type; - quark = g_quark_from_static_string("PyGEnum::class"); enum_pspec = G_PARAM_SPEC_ENUM(pspec); enum_type = G_ENUM_CLASS_TYPE(enum_pspec->enum_class); - pyclass = (PyObject*)g_type_get_qdata(enum_type, quark); + pyclass = (PyObject*)g_type_get_qdata(enum_type, pygenum_class_key); if (pyclass == NULL) { pyclass = Py_None; } @@ -83,15 +81,13 @@ pygenum_from_pspec(GParamSpec *pspec) static PyObject * pygflags_from_pspec(GParamSpec *pspec) { - GQuark quark; PyObject *pyclass; GParamSpecFlags *flag_pspec; GType flag_type; - quark = g_quark_from_static_string("PyGFlags::class"); flag_pspec = G_PARAM_SPEC_FLAGS(pspec); flag_type = G_FLAGS_CLASS_TYPE(flag_pspec->flags_class); - pyclass = (PyObject*)g_type_get_qdata(flag_type, quark); + pyclass = (PyObject*)g_type_get_qdata(flag_type, pygflags_class_key); if (pyclass == NULL) { pyclass = Py_None; } diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c index c05ece7..33caea2 100644 --- a/gobject/pygpointer.c +++ b/gobject/pygpointer.c @@ -124,8 +124,6 @@ PyTypeObject PyGPointer_Type = { (PyObject *)0, /* tp_bases */ }; -static GQuark pointer_type_id = 0; - /** * pyg_register_pointer: * @dict: the module dictionary to store the wrapper class. @@ -147,9 +145,6 @@ pyg_register_pointer(PyObject *dict, const gchar *class_name, g_return_if_fail(class_name != NULL); g_return_if_fail(pointer_type != 0); - if (!pointer_type_id) - pointer_type_id = g_quark_from_static_string("PyGPointer::class"); - if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_pointer_dealloc; type->ob_type = &PyType_Type; @@ -164,7 +159,7 @@ pyg_register_pointer(PyObject *dict, const gchar *class_name, o=pyg_type_wrapper_new(pointer_type)); Py_DECREF(o); - g_type_set_qdata(pointer_type, pointer_type_id, type); + g_type_set_qdata(pointer_type, pygpointer_class_key, type); PyDict_SetItemString(dict, (char *)class_name, (PyObject *)type); } @@ -198,7 +193,7 @@ pyg_pointer_new(GType pointer_type, gpointer pointer) return Py_None; } - tp = g_type_get_qdata(pointer_type, pointer_type_id); + tp = g_type_get_qdata(pointer_type, pygpointer_class_key); if (!tp) tp = (PyTypeObject *)&PyGPointer_Type; /* fallback */ self = PyObject_NEW(PyGPointer, tp); diff --git a/gobject/pygtype.c b/gobject/pygtype.c index 92b9ec4..9679cfa 100644 --- a/gobject/pygtype.c +++ b/gobject/pygtype.c @@ -322,7 +322,6 @@ typedef struct { fromvaluefunc fromvalue; tovaluefunc tovalue; } PyGBoxedMarshal; -static GQuark pyg_boxed_marshal_key = 0; #define pyg_boxed_lookup(boxed_type) \ ((PyGBoxedMarshal *)g_type_get_qdata((boxed_type), pyg_boxed_marshal_key)) @@ -347,9 +346,6 @@ pyg_register_boxed_custom(GType boxed_type, { PyGBoxedMarshal *bm; - if (!pyg_boxed_marshal_key) - pyg_boxed_marshal_key = g_quark_from_static_string("PyGBoxed::marshal"); - bm = g_new(PyGBoxedMarshal, 1); bm->fromvalue = from_func; bm->tovalue = to_func; |
