[pygobject] Remove pygi.h and pygi-private.h



commit e1e05fb027c328ef41be0ba6d99883d2d7983f70
Author: Christoph Reiter <creiter src gnome org>
Date:   Tue May 31 15:31:38 2016 +0200

    Remove pygi.h and pygi-private.h
    
    Instead include things where needed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767084

 gi/Makefile.am            |    3 +-
 gi/gimodule.c             |   11 +++++-
 gi/pygboxed.c             |    1 -
 gi/pygenum.c              |    2 +-
 gi/pygflags.c             |    4 +--
 gi/pygi-argument.c        |   17 +++++++--
 gi/pygi-array.c           |    3 +-
 gi/pygi-basictype.c       |    2 +-
 gi/pygi-boxed.c           |    3 +-
 gi/pygi-boxed.h           |    8 ++++
 gi/pygi-cache.c           |    2 +
 gi/pygi-ccallback.c       |    2 +-
 gi/pygi-ccallback.h       |   11 ++++++
 gi/pygi-closure.c         |    5 ++-
 gi/pygi-enum-marshal.c    |    3 +-
 gi/pygi-error.c           |    2 +-
 gi/pygi-hashtable.c       |    2 +-
 gi/pygi-info.c            |    6 +++-
 gi/pygi-info.h            |   22 +++++++++++
 gi/pygi-invoke.c          |    5 +++
 gi/pygi-invoke.h          |    2 +-
 gi/pygi-list.c            |    2 +-
 gi/pygi-marshal-cleanup.c |    8 +++--
 gi/pygi-marshal-cleanup.h |    4 ++-
 gi/pygi-object.c          |    2 +-
 gi/pygi-private.h         |   88 ---------------------------------------------
 gi/pygi-property.c        |    3 +-
 gi/pygi-property.h        |    2 +-
 gi/pygi-repository.c      |    3 +-
 gi/pygi-repository.h      |    6 +++
 gi/pygi-signal-closure.c  |    4 ++-
 gi/pygi-signal-closure.h  |    3 +-
 gi/pygi-source.c          |    4 ++-
 gi/pygi-struct-marshal.c  |    6 +++-
 gi/pygi-struct.c          |    5 ++-
 gi/pygi-struct.h          |    6 +++
 gi/pygi-type.c            |    3 +-
 gi/pygi-util.h            |   49 +++++++++++++++++++++++++
 gi/pygi.h                 |   82 -----------------------------------------
 gi/pygobject.c            |    3 +-
 gi/pygpointer.c           |    1 -
 41 files changed, 191 insertions(+), 209 deletions(-)
---
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 314fd41..5e73d70 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -88,8 +88,7 @@ _gi_la_SOURCES = \
        pygi-closure.h \
        pygi-ccallback.c \
        pygi-ccallback.h \
-       pygi.h \
-       pygi-private.h \
+       pygi-util.h \
        pygi-property.c \
        pygi-property.h \
        pygi-signal-closure.c \
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 44f0901..aa1b8a7 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -24,11 +24,18 @@
 #include "pyglib-private.h"
 #include "pygobject-private.h"
 #include "pyginterface.h"
-#include "pygi-private.h"
-#include "pygi.h"
+#include "pygi-repository.h"
 #include "pyglib.h"
 #include "pygi-error.h"
 #include "pygi-foreign.h"
+#include "pygi-resulttuple.h"
+#include "pygi-source.h"
+#include "pygi-ccallback.h"
+#include "pygi-closure.h"
+#include "pygi-type.h"
+#include "pygi-boxed.h"
+#include "pygi-info.h"
+#include "pygi-struct.h"
 
 #include <pyglib-python-compat.h>
 
diff --git a/gi/pygboxed.c b/gi/pygboxed.c
index cdb766c..814cdb9 100644
--- a/gi/pygboxed.c
+++ b/gi/pygboxed.c
@@ -26,7 +26,6 @@
 #include "pygobject-private.h"
 #include "pygboxed.h"
 
-#include "pygi.h"
 #include "pygi-type.h"
 
 GQuark pygboxed_type_key;
diff --git a/gi/pygenum.c b/gi/pygenum.c
index fe78fb9..fb0873d 100644
--- a/gi/pygenum.c
+++ b/gi/pygenum.c
@@ -24,8 +24,8 @@
 #endif
 
 #include <pyglib.h>
+#include "pyglib-python-compat.h"
 #include "pygobject-private.h"
-#include "pygi.h"
 #include "pygi-type.h"
 
 #include "pygenum.h"
diff --git a/gi/pygflags.c b/gi/pygflags.c
index ce146ae..0be3097 100644
--- a/gi/pygflags.c
+++ b/gi/pygflags.c
@@ -24,12 +24,10 @@
 #endif
 
 #include <pyglib.h>
+#include "pygi-type.h"
 #include "pygobject-private.h"
 #include "pygflags.h"
 
-#include "pygi.h"
-#include "pygi-type.h"
-
 GQuark pygflags_class_key;
 
 PYGLIB_DEFINE_TYPE("gobject.GFlags", PyGFlags_Type, PyGFlags);
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index fdd461a..2e4dd40 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -19,20 +19,31 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
-#include "pygobject-private.h"
-
 #include <string.h>
 #include <time.h>
 
+#include "pygobject-private.h"
+
 #include <pyglib-python-compat.h>
 #include <pyglib.h>
 
+#include "pygi-argument.h"
+#include "pygi-info.h"
 #include "pygi-value.h"
 #include "pygi-basictype.h"
 #include "pygi-object.h"
 #include "pygi-struct-marshal.h"
 #include "pygi-error.h"
+#include "pygi-foreign.h"
+#include "pygi-type.h"
+#include "pygi-util.h"
+
+/* Redefine g_array_index because we want it to return the i-th element, casted
+ * to the type t, of the array a, and not the i-th element of the array a
+ * casted to the type t. */
+#define _g_array_index(a,t,i) \
+    *(t *)((a)->data + g_array_get_element_size(a) * (i))
+
 
 gboolean
 pygi_argument_to_gssize (GIArgument *arg_in,
diff --git a/gi/pygi-array.c b/gi/pygi-array.c
index 5c34467..61d0617 100644
--- a/gi/pygi-array.c
+++ b/gi/pygi-array.c
@@ -23,9 +23,10 @@
 #include <pyglib-python-compat.h>
 
 #include "pygi-array.h"
-#include "pygi-private.h"
+#include "pygi-info.h"
 #include "pygi-marshal-cleanup.h"
 #include "pygi-basictype.h"
+#include "pygi-util.h"
 
 /* Needed for _pygi_marshal_cleanup_from_py_interface_struct_gvalue hack */
 #include "pygi-struct-marshal.h"
diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c
index 432559d..470547d 100644
--- a/gi/pygi-basictype.c
+++ b/gi/pygi-basictype.c
@@ -23,7 +23,7 @@
 
 #include "pygi-basictype.h"
 #include "pygi-argument.h"
-#include "pygi-private.h"
+#include "pygobject-private.h"
 
 #ifdef G_OS_WIN32
 #include <math.h>
diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c
index d5faeb1..c1e4b0e 100644
--- a/gi/pygi-boxed.c
+++ b/gi/pygi-boxed.c
@@ -19,7 +19,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygi-boxed.h"
+#include "pygi-info.h"
 #include "pygobject-private.h"
 
 #include <girepository.h>
diff --git a/gi/pygi-boxed.h b/gi/pygi-boxed.h
index c8f40b7..89942d0 100644
--- a/gi/pygi-boxed.h
+++ b/gi/pygi-boxed.h
@@ -21,9 +21,17 @@
 #define __PYGI_BOXED_H__
 
 #include <Python.h>
+#include <girepository.h>
+#include "pygobject-private.h"
 
 G_BEGIN_DECLS
 
+typedef struct {
+    PyGBoxed base;
+    gboolean slice_allocated;
+    gsize size;
+} PyGIBoxed;
+
 extern PyTypeObject PyGIBoxed_Type;
 
 PyObject * _pygi_boxed_new (PyTypeObject *pytype,
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 62b0961..263dc8e 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -35,6 +35,8 @@
 #include "pygi-object.h"
 #include "pygi-struct-marshal.h"
 #include "pygi-enum-marshal.h"
+#include "pygi-resulttuple.h"
+#include "pygi-invoke.h"
 
 
 /* _arg_info_default_value
diff --git a/gi/pygi-ccallback.c b/gi/pygi-ccallback.c
index 9c6e47e..c7f3ecf 100644
--- a/gi/pygi-ccallback.c
+++ b/gi/pygi-ccallback.c
@@ -19,8 +19,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
 #include "pygobject-private.h"
+#include "pygi-ccallback.h"
 
 #include <girepository.h>
 #include <pyglib-python-compat.h>
diff --git a/gi/pygi-ccallback.h b/gi/pygi-ccallback.h
index f286171..dcd9e6b 100644
--- a/gi/pygi-ccallback.h
+++ b/gi/pygi-ccallback.h
@@ -21,9 +21,20 @@
 #define __PYGI_CCLOSURE_H__
 
 #include <Python.h>
+#include "pygi-cache.h"
 
 G_BEGIN_DECLS
 
+typedef struct {
+    PyObject_HEAD
+    GCallback callback;
+    GIFunctionInfo *info;
+    gpointer user_data;
+    GIScopeType scope;
+    GDestroyNotify destroy_notify_func;
+    PyGICCallbackCache *cache;
+} PyGICCallback;
+
 extern PyTypeObject PyGICCallback_Type;
 
 PyObject * _pygi_ccallback_new (GCallback       callback,
diff --git a/gi/pygi-closure.c b/gi/pygi-closure.c
index 6a68e2b..a75e358 100644
--- a/gi/pygi-closure.c
+++ b/gi/pygi-closure.c
@@ -17,11 +17,14 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
 #include "pygi-closure.h"
 #include "pygi-error.h"
 #include "pygi-marshal-cleanup.h"
+#include "pygi-invoke.h"
+#include "pygi-ccallback.h"
+#include "pygi-info.h"
 
+extern PyObject *_PyGIDefaultArgPlaceholder;
 
 typedef struct _PyGICallbackCache
 {
diff --git a/gi/pygi-enum-marshal.c b/gi/pygi-enum-marshal.c
index e1a7028..945a8e0 100644
--- a/gi/pygi-enum-marshal.c
+++ b/gi/pygi-enum-marshal.c
@@ -23,7 +23,8 @@
 #include <pyglib-python-compat.h>
 
 #include "pygi-enum-marshal.h"
-#include "pygi-private.h"
+#include "pygobject-private.h"
+#include "pygi-type.h"
 
 static gboolean
 gi_argument_from_c_long (GIArgument *arg_out,
diff --git a/gi/pygi-error.c b/gi/pygi-error.c
index d86021c..45ca2eb 100644
--- a/gi/pygi-error.c
+++ b/gi/pygi-error.c
@@ -21,9 +21,9 @@
  */
 
 #include "pyglib.h"
-#include "pygi-private.h"
 #include "pygi-error.h"
 #include "pygtype.h"
+#include <pyglib-python-compat.h>
 
 
 PyObject *PyGError = NULL;
diff --git a/gi/pygi-hashtable.c b/gi/pygi-hashtable.c
index d785daa..84155d7 100644
--- a/gi/pygi-hashtable.c
+++ b/gi/pygi-hashtable.c
@@ -21,7 +21,7 @@
 #include <Python.h>
 #include "pygi-hashtable.h"
 #include "pygi-argument.h"
-#include "pygi-private.h"
+#include "pygi-util.h"
 
 typedef struct _PyGIHashCache
 {
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index cc8656b..3422ea9 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -20,8 +20,12 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygi-info.h"
 #include "pygi-cache.h"
+#include "pygi-invoke.h"
+#include "pygi-type.h"
+#include "pygi-argument.h"
+#include "pygi-util.h"
 #include "pygobject-private.h"
 
 #include <pyglib-python-compat.h>
diff --git a/gi/pygi-info.h b/gi/pygi-info.h
index a0c6680..16371c8 100644
--- a/gi/pygi-info.h
+++ b/gi/pygi-info.h
@@ -23,9 +23,31 @@
 #include <Python.h>
 
 #include <girepository.h>
+#include "pygi-cache.h"
 
 G_BEGIN_DECLS
 
+typedef struct {
+    PyObject_HEAD
+    GIBaseInfo *info;
+    PyObject *inst_weakreflist;
+    PyGICallableCache *cache;
+} PyGIBaseInfo;
+
+typedef struct {
+    PyGIBaseInfo base;
+
+    /* Reference the unbound version of this struct.
+     * We use this for the actual call to invoke because it manages the cache.
+     */
+    struct PyGICallableInfo *py_unbound_info;
+
+    /* Holds bound argument for instance, class, and vfunc methods. */
+    PyObject *py_bound_arg;
+
+} PyGICallableInfo;
+
+
 gboolean pygi_g_struct_info_is_simple (GIStructInfo *struct_info);
 
 
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index 02de46e..619fe40 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -24,6 +24,11 @@
 #include "pygi-invoke.h"
 #include "pygi-marshal-cleanup.h"
 #include "pygi-error.h"
+#include "pygi-resulttuple.h"
+#include "pygi-foreign.h"
+#include "pygi-boxed.h"
+
+extern PyObject *_PyGIDefaultArgPlaceholder;
 
 static gboolean
 _check_for_unexpected_kwargs (PyGICallableCache *cache,
diff --git a/gi/pygi-invoke.h b/gi/pygi-invoke.h
index dfed2e0..aa51f3f 100644
--- a/gi/pygi-invoke.h
+++ b/gi/pygi-invoke.h
@@ -24,7 +24,7 @@
 
 #include <girepository.h>
 
-#include "pygi-private.h"
+#include "pygi-info.h"
 #include "pygi-invoke-state-struct.h"
 
 G_BEGIN_DECLS
diff --git a/gi/pygi-list.c b/gi/pygi-list.c
index 41a3d32..3eee849 100644
--- a/gi/pygi-list.c
+++ b/gi/pygi-list.c
@@ -21,7 +21,7 @@
 #include <Python.h>
 #include "pygi-list.h"
 #include "pygi-argument.h"
-#include "pygi-private.h"
+#include "pygi-util.h"
 
 typedef PyGISequenceCache PyGIArgGList;
 
diff --git a/gi/pygi-marshal-cleanup.c b/gi/pygi-marshal-cleanup.c
index b2e91eb..b4d04bc 100644
--- a/gi/pygi-marshal-cleanup.c
+++ b/gi/pygi-marshal-cleanup.c
@@ -16,9 +16,11 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
- 
- #include "pygi-marshal-cleanup.h"
- #include <glib.h>
+
+#include "pygi-marshal-cleanup.h"
+#include "pygi-foreign.h"
+#include <glib.h>
+
 static inline void
 _cleanup_caller_allocates (PyGIInvokeState    *state,
                            PyGIArgCache       *cache,
diff --git a/gi/pygi-marshal-cleanup.h b/gi/pygi-marshal-cleanup.h
index 56bf383..18ba007 100644
--- a/gi/pygi-marshal-cleanup.h
+++ b/gi/pygi-marshal-cleanup.h
@@ -20,7 +20,9 @@
 #ifndef __PYGI_MARSHAL_CLEANUP_H__
 #define __PYGI_MARSHAL_CLEANUP_H__
 
-#include "pygi-private.h"
+#include "pygi-struct.h"
+#include "pygi-invoke-state-struct.h"
+#include "pygi-cache.h"
 
 G_BEGIN_DECLS
 
diff --git a/gi/pygi-object.c b/gi/pygi-object.c
index a082992..11ea226 100644
--- a/gi/pygi-object.c
+++ b/gi/pygi-object.c
@@ -23,7 +23,7 @@
 #include <pyglib-python-compat.h>
 
 #include "pygi-object.h"
-#include "pygi-private.h"
+#include "pygobject-private.h"
 #include "pygparamspec.h"
 
 /*
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index cc4e839..4eb9ca8 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -21,8 +21,9 @@
  * IN THE SOFTWARE.
  */
 
-#include "pygi-private.h"
+#include "pygi-property.h"
 #include "pygi-value.h"
+#include "pygi-argument.h"
 #include "pygparamspec.h"
 
 #include <girepository.h>
diff --git a/gi/pygi-property.h b/gi/pygi-property.h
index 064a062..19c720f 100644
--- a/gi/pygi-property.h
+++ b/gi/pygi-property.h
@@ -27,7 +27,7 @@
 #include <Python.h>
 #include <girepository.h>
 
-#include "pygobject.h"
+#include "pygobject-private.h"
 
 PyObject *
 pygi_get_property_value (PyGObject *instance,
diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c
index 16356f9..62ef3b6 100644
--- a/gi/pygi-repository.c
+++ b/gi/pygi-repository.c
@@ -19,7 +19,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygi-repository.h"
+#include "pygi-info.h"
 
 #include <pyglib-python-compat.h>
 
diff --git a/gi/pygi-repository.h b/gi/pygi-repository.h
index 6f0928b..6199712 100644
--- a/gi/pygi-repository.h
+++ b/gi/pygi-repository.h
@@ -21,9 +21,15 @@
 #define __PYGI_REPOSITORY_H__
 
 #include <Python.h>
+#include <girepository.h>
 
 G_BEGIN_DECLS
 
+typedef struct {
+    PyObject_HEAD
+    GIRepository *repository;
+} PyGIRepository;
+
 /* Private */
 
 extern PyTypeObject PyGIRepository_Type;
diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c
index 652ac99..bd9b402 100644
--- a/gi/pygi-signal-closure.c
+++ b/gi/pygi-signal-closure.c
@@ -16,8 +16,10 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygi-signal-closure.h"
 #include "pygi-value.h"
+#include "pygi-argument.h"
+#include "pygi-boxed.h"
 
 static GISignalInfo *
 _pygi_lookup_signal_from_g_type (GType g_type,
diff --git a/gi/pygi-signal-closure.h b/gi/pygi-signal-closure.h
index 5cc191b..80bc58c 100644
--- a/gi/pygi-signal-closure.h
+++ b/gi/pygi-signal-closure.h
@@ -24,7 +24,8 @@
 #ifndef __PYGI_SIGNAL_CLOSURE_H__
 #define __PYGI_SIGNAL_CLOSURE_H__
 
-#include "pygobject.h"
+#include <girepository.h>
+#include "pygobject-private.h"
 
 G_BEGIN_DECLS
 
diff --git a/gi/pygi-source.c b/gi/pygi-source.c
index afc43e6..c1d318c 100644
--- a/gi/pygi-source.c
+++ b/gi/pygi-source.c
@@ -25,7 +25,9 @@
 
 #include "pygobject-private.h"
 
-#include "pygi-private.h"
+#include "pygi-info.h"
+#include "pygi-boxed.h"
+#include "pygi-type.h"
 #include "pyglib.h"
 #include "pyglib-private.h"
 #include "pygi-source.h"
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c
index 353a2d1..0d36521 100644
--- a/gi/pygi-struct-marshal.c
+++ b/gi/pygi-struct-marshal.c
@@ -23,8 +23,12 @@
 #include <pyglib-python-compat.h>
 
 #include "pygi-struct-marshal.h"
-#include "pygi-private.h"
+#include "pygi-struct.h"
+#include "pygi-foreign.h"
 #include "pygi-value.h"
+#include "pygi-type.h"
+#include "pygi-boxed.h"
+#include "pygi-info.h"
 
 /*
  * _is_union_member - check to see if the py_arg is actually a member of the
diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c
index c379a88..5bbb789 100644
--- a/gi/pygi-struct.c
+++ b/gi/pygi-struct.c
@@ -19,7 +19,10 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygi-struct.h"
+#include "pygi-foreign.h"
+#include "pygi-info.h"
+#include "pygi-type.h"
 #include "pygobject-private.h"
 
 #include <girepository.h>
diff --git a/gi/pygi-struct.h b/gi/pygi-struct.h
index 347c55f..dde42dd 100644
--- a/gi/pygi-struct.h
+++ b/gi/pygi-struct.h
@@ -21,9 +21,15 @@
 #define __PYGI_STRUCT_H__
 
 #include <Python.h>
+#include <pygobject-private.h>
 
 G_BEGIN_DECLS
 
+typedef struct {
+    PyGPointer base;
+    gboolean free_on_dealloc;
+} PyGIStruct;
+
 extern PyTypeObject PyGIStruct_Type;
 
 PyObject *
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index 924e0b8..a1213f7 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -19,7 +19,8 @@
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "pygi-private.h"
+#include "pygobject-private.h"
+#include "pygi-type.h"
 
 #include <pyglib-python-compat.h>
 
diff --git a/gi/pygi-util.h b/gi/pygi-util.h
new file mode 100644
index 0000000..3144d6e
--- /dev/null
+++ b/gi/pygi-util.h
@@ -0,0 +1,49 @@
+#ifndef __PYGI_UTIL_H__
+#define __PYGI_UTIL_H__
+
+G_BEGIN_DECLS
+
+#if PY_VERSION_HEX >= 0x03000000
+
+#define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
+    PyObject *py_error_prefix; \
+    py_error_prefix = PyUnicode_FromFormat(format, ## __VA_ARGS__); \
+    if (py_error_prefix != NULL) { \
+        PyObject *py_error_type, *py_error_value, *py_error_traceback; \
+        PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
+        if (PyUnicode_Check(py_error_value)) { \
+            PyObject *new; \
+            new = PyUnicode_Concat(py_error_prefix, py_error_value); \
+            Py_DECREF(py_error_value); \
+            if (new != NULL) { \
+                py_error_value = new; \
+            } \
+        } \
+        PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
+        Py_DECREF(py_error_prefix); \
+    } \
+} G_STMT_END
+
+#else
+
+#define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
+    PyObject *py_error_prefix; \
+    py_error_prefix = PyString_FromFormat(format, ## __VA_ARGS__); \
+    if (py_error_prefix != NULL) { \
+        PyObject *py_error_type, *py_error_value, *py_error_traceback; \
+        PyErr_Fetch(&py_error_type, &py_error_value, &py_error_traceback); \
+        if (PyString_Check(py_error_value)) { \
+            PyString_ConcatAndDel(&py_error_prefix, py_error_value); \
+            if (py_error_prefix != NULL) { \
+                py_error_value = py_error_prefix; \
+            } \
+        } \
+        PyErr_Restore(py_error_type, py_error_value, py_error_traceback); \
+    } \
+} G_STMT_END
+
+#endif
+
+G_END_DECLS
+
+#endif /* __PYGI_UTIL_H__ */
diff --git a/gi/pygobject.c b/gi/pygobject.c
index a09ae36..e7ea5ed 100644
--- a/gi/pygobject.c
+++ b/gi/pygobject.c
@@ -27,12 +27,13 @@
 #include "pyginterface.h"
 #include "pygparamspec.h"
 
-#include "pygi.h"
 #include "pygi-value.h"
 #include "pygi-type.h"
 #include "pygi-property.h"
 #include "pygi-signal-closure.h"
 
+extern PyObject *PyGIDeprecationWarning;
+
 static void pygobject_dealloc(PyGObject *self);
 static int  pygobject_traverse(PyGObject *self, visitproc visit, void *arg);
 static int  pygobject_clear(PyGObject *self);
diff --git a/gi/pygpointer.c b/gi/pygpointer.c
index d728a40..d160fff 100644
--- a/gi/pygpointer.c
+++ b/gi/pygpointer.c
@@ -26,7 +26,6 @@
 #include "pygobject-private.h"
 #include "pygpointer.h"
 
-#include "pygi.h"
 #include "pygi-type.h"
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]