[pygobject/py3k: 3/20] Make pyglib-python-compat.h a public header and include in pygobject.h Also #define PyVarObject_HEAD



commit f6f2ed44c84aff3c38fc3eb5961b28621a14fc51
Author: John Ehresman <jpe wingware com>
Date:   Mon Apr 12 23:21:24 2010 -0400

    Make pyglib-python-compat.h a public header and include in pygobject.h Also #define PyVarObject_HEAD_INIT if not defined (in < python 2.6)

 codegen/codegen.py          |    2 +-
 glib/Makefile.am            |    4 +++-
 glib/pyglib-private.h       |    2 --
 glib/pyglib-python-compat.h |    7 +++++++
 glib/pyglib.h               |    2 ++
 gobject/pygobject.h         |    2 ++
 tests/Makefile.am           |    1 +
 7 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/codegen/codegen.py b/codegen/codegen.py
index 7a1f7e6..aef93ae 100755
--- a/codegen/codegen.py
+++ b/codegen/codegen.py
@@ -96,7 +96,7 @@ class FileOutput:
 class Wrapper:
     type_tmpl = (
         'PyTypeObject G_GNUC_INTERNAL Py%(typename)s_Type = {\n'
-        '    PyVarObject_HEAD_INIT(NULL, 0)'
+        '    PyVarObject_HEAD_INIT(NULL, 0)\n'
         '    "%(classname)s",                   /* tp_name */\n'
         '    sizeof(%(tp_basicsize)s),          /* tp_basicsize */\n'
         '    0,                                 /* tp_itemsize */\n'
diff --git a/glib/Makefile.am b/glib/Makefile.am
index d230da4..b249332 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -2,7 +2,9 @@ AUTOMAKE_OPTIONS = 1.7
 INCLUDES = $(PYTHON_INCLUDES) $(GLIB_CFLAGS) -DPY_SSIZE_T_CLEAN
 
 pkgincludedir = $(includedir)/pygtk-2.0
-pkginclude_HEADERS = pyglib.h
+pkginclude_HEADERS = \
+	pyglib.h \
+	pyglib-python-compat.h
 
 lib_LTLIBRARIES = libpyglib-2 0- PYTHON_BASENAME@.la
 
diff --git a/glib/pyglib-private.h b/glib/pyglib-private.h
index 8b033e1..c535fee 100644
--- a/glib/pyglib-private.h
+++ b/glib/pyglib-private.h
@@ -25,8 +25,6 @@
 #include <Python.h>
 #include <glib.h>
 
-#include <pyglib-python-compat.h>
-
 G_BEGIN_DECLS
 
 struct _PyGLib_Functions {
diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h
index 915a912..c2523ff 100644
--- a/glib/pyglib-python-compat.h
+++ b/glib/pyglib-python-compat.h
@@ -61,6 +61,13 @@ typedef inquiry lenfunc;
 #define _PyLong_Type PyInt_Type
 #define _PyLong_AS_LONG PyInt_AS_LONG
 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
+
+#ifndef PyVarObject_HEAD_INIT
+#define PyVarObject_HEAD_INIT(base, size) \
+  PyObject_HEAD_INIT(base) \
+  size,
+#endif
+
 #else
 #undef PYGLIB_MODULE_START
 #undef PYGLIB_MODULE_END
diff --git a/glib/pyglib.h b/glib/pyglib.h
index 24e1ed2..62561e9 100644
--- a/glib/pyglib.h
+++ b/glib/pyglib.h
@@ -26,6 +26,8 @@
 
 #include <glib.h>
 
+#include <pyglib-python-compat.h>
+
 G_BEGIN_DECLS
 
 typedef void (*PyGLibThreadsEnabledFunc) (void);
diff --git a/gobject/pygobject.h b/gobject/pygobject.h
index d7eba07..aaab860 100644
--- a/gobject/pygobject.h
+++ b/gobject/pygobject.h
@@ -7,6 +7,8 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <pyglib.h>
+
 G_BEGIN_DECLS
 
 /* This is deprecated, don't use */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e546f50..70eeb5e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,6 @@
 INCLUDES = \
 	-I$(top_srcdir)/gobject \
+	-I$(top_srcdir)/glib \
 	$(PYTHON_INCLUDES) \
 	$(GLIB_CFLAGS)
 



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