1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * vim: tabstop=4 shiftwidth=4 expandtab
4 #ifndef __PYGI_PRIVATE_H__
5 #define __PYGI_PRIVATE_H__
8 # error "Import pygi.h or pygi-private.h, but not both"
19 #include "pygobject-external.h"
21 #include "pygi-repository.h"
22 #include "pygi-info.h"
23 #include "pygi-struct.h"
24 #include "pygi-boxed.h"
25 #include "pygi-argument.h"
26 #include "pygi-type.h"
27 #include "pygi-foreign.h"
28 #include "pygi-closure.h"
29 #include "pygi-callbacks.h"
30 #include "pygi-invoke.h"
31 #include "pygi-property.h"
32 #include "pygi-signal-closure.h"
35 #if PY_VERSION_HEX >= 0x03000000
37 #define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
38 PyObject *py_error_prefix; \
39 py_error_prefix = PyUnicode_FromFormat(format, ## __VA_ARGS__); \
40 if (py_error_prefix != NULL) { \
41 PyObject *py_error_type, *py_error_value, *py_error_traceback; \
42 PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
43 if (PyUnicode_Check(py_error_value)) { \
45 new = PyUnicode_Concat(py_error_prefix, py_error_value); \
46 Py_DECREF(py_error_value); \
48 py_error_value = new; \
51 PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
57 #define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
58 PyObject *py_error_prefix; \
59 py_error_prefix = PyString_FromFormat(format, ## __VA_ARGS__); \
60 if (py_error_prefix != NULL) { \
61 PyObject *py_error_type, *py_error_value, *py_error_traceback; \
62 PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
63 if (PyString_Check(py_error_value)) { \
64 PyString_ConcatAndDel(&py_error_prefix, py_error_value); \
65 if (py_error_prefix != NULL) { \
66 py_error_value = py_error_prefix; \
69 PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
75 /* Redefine g_array_index because we want it to return the i-th element, casted
76 * to the type t, of the array a, and not the i-th element of the array a
77 * casted to the type t. */
78 #define _g_array_index(a,t,i) \
79 *(t *)((a)->data + g_array_get_element_size(a) * (i))
84 #endif /* __PYGI_PRIVATE_H__ */