Imported Upstream version 3.21.91
[platform/upstream/python-gobject.git] / gi / pyglib.h
1 /* -*- Mode: C; c-basic-offset: 4 -*-
2  * pyglib - Python bindings for GLib toolkit.
3  * Copyright (C) 1998-2003  James Henstridge
4  *               2004-2008  Johan Dahlin
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __PYGLIB_H__
21 #define __PYGLIB_H__
22
23 #include <Python.h>
24
25 #include <glib.h>
26
27 #include <pyglib-python-compat.h>
28
29 G_BEGIN_DECLS
30
31 typedef void (*PyGLibThreadsEnabledFunc) (void);
32 typedef void (*PyGLibThreadBlockFunc) (void);
33
34 #ifdef DISABLE_THREADING
35 #    define pyglib_gil_state_ensure()        PyGILState_LOCKED
36 #    define pyglib_gil_state_release(state)  state
37 #else
38 #    define pyglib_gil_state_ensure          PyGILState_Ensure
39 #    define pyglib_gil_state_release         PyGILState_Release
40 #endif
41
42 GOptionGroup * pyglib_option_group_transfer_group(PyObject *self);
43
44 /* Private: for gobject <-> glib interaction only. */
45 PyObject* _pyglib_generic_ptr_richcompare(void* a, void *b, int op);
46 PyObject* _pyglib_generic_long_richcompare(long a, long b, int op);
47
48
49 #define PYGLIB_REGISTER_TYPE(d, type, name)             \
50     if (!type.tp_alloc)                                 \
51         type.tp_alloc = PyType_GenericAlloc;            \
52     if (!type.tp_new)                                   \
53         type.tp_new = PyType_GenericNew;                \
54     if (PyType_Ready(&type))                            \
55         return;                                         \
56     PyDict_SetItemString(d, name, (PyObject *)&type);
57
58 gboolean _pyglib_handler_marshal(gpointer user_data);
59 void _pyglib_destroy_notify(gpointer user_data);
60
61 extern PyObject *pyglib__glib_module_create (void);
62
63 G_END_DECLS
64
65 #endif /* __PYGLIB_H__ */
66