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-ccallback.h"
30 #include "pygi-property.h"
31 #include "pygi-signal-closure.h"
32 #include "pygi-invoke.h"
33 #include "pygi-cache.h"
34 #include "pygi-source.h"
37 #if PY_VERSION_HEX >= 0x03000000
39 #define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
40 PyObject *py_error_prefix; \
41 py_error_prefix = PyUnicode_FromFormat(format, ## __VA_ARGS__); \
42 if (py_error_prefix != NULL) { \
43 PyObject *py_error_type, *py_error_value, *py_error_traceback; \
44 PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
45 if (PyUnicode_Check(py_error_value)) { \
47 new = PyUnicode_Concat(py_error_prefix, py_error_value); \
48 Py_DECREF(py_error_value); \
50 py_error_value = new; \
53 PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
54 Py_DECREF(py_error_prefix); \
60 #define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
61 PyObject *py_error_prefix; \
62 py_error_prefix = PyString_FromFormat(format, ## __VA_ARGS__); \
63 if (py_error_prefix != NULL) { \
64 PyObject *py_error_type, *py_error_value, *py_error_traceback; \
65 PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
66 if (PyString_Check(py_error_value)) { \
67 PyString_ConcatAndDel(&py_error_prefix, py_error_value); \
68 if (py_error_prefix != NULL) { \
69 py_error_value = py_error_prefix; \
72 PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
78 /* Redefine g_array_index because we want it to return the i-th element, casted
79 * to the type t, of the array a, and not the i-th element of the array a
80 * casted to the type t. */
81 #define _g_array_index(a,t,i) \
82 *(t *)((a)->data + g_array_get_element_size(a) * (i))
87 #endif /* __PYGI_PRIVATE_H__ */