diff options
author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-01-09 17:35:01 +0000 |
---|---|---|
committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2005-01-09 17:35:01 +0000 |
commit | cdbddaa4d040be8b71d0e3b4790da4aaf6b87ab6 (patch) | |
tree | 1d604c60dd3df41d5807b5d29fb92949696d3e03 | |
parent | d953b545f6fa8f0e24b265044bc52ab5896702eb (diff) | |
download | pygobject-cdbddaa4d040be8b71d0e3b4790da4aaf6b87ab6.tar.gz |
misc API additions, threading
-rw-r--r-- | gobject/gobjectmodule.c | 4 | ||||
-rw-r--r-- | gobject/pygobject-private.h | 24 | ||||
-rw-r--r-- | gobject/pygobject.h | 22 |
3 files changed, 22 insertions, 28 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 5ed9d644..5f3918e6 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1055,8 +1055,8 @@ pyg_type_register(PyObject *self, PyObject *args) } else g_warning("type has no tp_bases"); - Py_INCREF(Py_None); - return Py_None; + Py_INCREF(class); + return class; } static PyObject * diff --git a/gobject/pygobject-private.h b/gobject/pygobject-private.h index d826f92e..a9d8bd90 100644 --- a/gobject/pygobject-private.h +++ b/gobject/pygobject-private.h @@ -19,24 +19,20 @@ extern struct _PyGObject_Functions pygobject_api_functions; (* pygobject_api_functions.unblock_threads)(); \ } G_STMT_END -#define pyg_threads_enabled (pygobject_api_functions.threads_enabled) - +#if PY_VERSION_HEX < 0x020400F0 +# define pyg_threads_enabled (pygobject_api_functions.threads_enabled) +#else +# define pyg_threads_enabled (PyEval_ThreadsInitialized()) +#endif -#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0) -#define pyg_gil_state_release(state) G_STMT_START { \ - if (pygobject_api_functions.threads_enabled) \ +#define pyg_gil_state_ensure() (pyg_threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0) +#define pyg_gil_state_release(state) G_STMT_START { \ + if (pyg_threads_enabled) \ pygobject_api_functions.gil_state_release(state); \ } G_STMT_END -#define pyg_begin_allow_threads \ - G_STMT_START { \ - PyThreadState *_save = NULL; \ - if (pygobject_api_functions.threads_enabled) \ - _save = PyEval_SaveThread(); -#define pyg_end_allow_threads \ - if (pygobject_api_functions.threads_enabled) \ - PyEval_RestoreThread(_save); \ - } G_STMT_END +#define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS +#define pyg_end_allow_threads Py_END_ALLOW_THREADS extern GType PY_TYPE_OBJECT; diff --git a/gobject/pygobject.h b/gobject/pygobject.h index 22e488c2..a44f7afb 100644 --- a/gobject/pygobject.h +++ b/gobject/pygobject.h @@ -223,23 +223,21 @@ struct _PyGObject_Functions *_PyGObject_API; (* _PyGObject_API->unblock_threads)(); \ } G_STMT_END -#define pyg_threads_enabled (_PyGObject_API->threads_enabled) -#define pyg_gil_state_ensure() (_PyGObject_API->threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0) +#if PY_VERSION_HEX < 0x020400F0 +# define pyg_threads_enabled (_PyGObject_API->threads_enabled) +#else +# define pyg_threads_enabled (PyEval_ThreadsInitialized()) +#endif + +#define pyg_gil_state_ensure() (pyg_threads_enabled? (_PyGObject_API->gil_state_ensure()) : 0) #define pyg_gil_state_release(state) G_STMT_START { \ - if (_PyGObject_API->threads_enabled) \ + if (pyg_threads_enabled) \ _PyGObject_API->gil_state_release(state); \ } G_STMT_END -#define pyg_begin_allow_threads \ - G_STMT_START { \ - PyThreadState *_save = NULL; \ - if (_PyGObject_API->threads_enabled) \ - _save = PyEval_SaveThread(); -#define pyg_end_allow_threads \ - if (_PyGObject_API->threads_enabled) \ - PyEval_RestoreThread(_save); \ - } G_STMT_END +#define pyg_begin_allow_threads Py_BEGIN_ALLOW_THREADS +#define pyg_end_allow_threads Py_END_ALLOW_THREADS #define init_pygobject() { \ PyObject *gobject = PyImport_ImportModule("gobject"); \ |