summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <creiter@src.gnome.org>2016-05-31 18:47:54 +0200
committerChristoph Reiter <creiter@src.gnome.org>2016-06-01 21:21:42 +0200
commitf5dd1551371308d33df9627bc8cc0e34fa68a2a8 (patch)
treed798ae4ab89ebd24fc9c4bc13c46d8e1d317296d
parentef7a6dad8cea6a3b9547cfae00bf15ebb9eb756e (diff)
downloadpygobject-f5dd1551371308d33df9627bc8cc0e34fa68a2a8.tar.gz
Remove pygobject-private.h and rename pygobject.c to pygobject-object.c
Move all the random declarations in pygobject-private.h to their respective header files. Rename pygobject.c to pygobject-object.c so it's clearer that it's not the implementation of pygobject.h. Add a new pygobject-internal.h which includes pygobject.h with _INSIDE_PYGOBJECT_ defined like pygobject-private.h did. In case you are looking at the git log and end up here due to the rename try: git log --follow pygobject-object.c or on the web interface go to the history of the old file name: https://git.gnome.org/browse/pygobject/log/gi/pygobject.c?id=6b702c052e9f26e809cff494f0c896d17a514c64 https://bugzilla.gnome.org/show_bug.cgi?id=767084
-rw-r--r--gi/Makefile.am7
-rw-r--r--gi/gimodule.c10
-rw-r--r--gi/gobjectmodule.c56
-rw-r--r--gi/gobjectmodule.h11
-rw-r--r--gi/pygboxed.c4
-rw-r--r--gi/pygboxed.h11
-rw-r--r--gi/pygenum.c4
-rw-r--r--gi/pygenum.h22
-rw-r--r--gi/pygflags.c4
-rw-r--r--gi/pygflags.h21
-rw-r--r--gi/pygi-argument.c4
-rw-r--r--gi/pygi-basictype.c2
-rw-r--r--gi/pygi-boxed.c3
-rw-r--r--gi/pygi-boxed.h2
-rw-r--r--gi/pygi-cache.c1
-rw-r--r--gi/pygi-ccallback.c1
-rw-r--r--gi/pygi-enum-marshal.c3
-rw-r--r--gi/pygi-foreign.c2
-rw-r--r--gi/pygi-info.c2
-rw-r--r--gi/pygi-object.c2
-rw-r--r--gi/pygi-property.c1
-rw-r--r--gi/pygi-property.h2
-rw-r--r--gi/pygi-signal-closure.h2
-rw-r--r--gi/pygi-source.c3
-rw-r--r--gi/pygi-struct-marshal.c3
-rw-r--r--gi/pygi-struct.c3
-rw-r--r--gi/pygi-struct.h2
-rw-r--r--gi/pygi-type.c2
-rw-r--r--gi/pygi-util.c42
-rw-r--r--gi/pygi-util.h6
-rw-r--r--gi/pygi-value.c6
-rw-r--r--gi/pyginterface.c3
-rw-r--r--gi/pygobject-internal.h7
-rw-r--r--gi/pygobject-object.c (renamed from gi/pygobject.c)27
-rw-r--r--gi/pygobject-object.h56
-rw-r--r--gi/pygobject-private.h186
-rw-r--r--gi/pygparamspec.c5
-rw-r--r--gi/pygpointer.c3
-rw-r--r--gi/pygpointer.h8
-rw-r--r--gi/pygtype.c27
-rw-r--r--gi/pygtype.h25
41 files changed, 305 insertions, 286 deletions
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 3dee5042..defe77e9 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -36,6 +36,7 @@ pygi_LTLIBRARIES = _gi.la
_gi_la_SOURCES = \
gobjectmodule.c \
+ gobjectmodule.h \
pygboxed.c \
pygboxed.h \
pygenum.c \
@@ -44,9 +45,10 @@ _gi_la_SOURCES = \
pygflags.h \
pyginterface.c \
pyginterface.h \
- pygobject.c \
pygobject.h \
- pygobject-private.h \
+ pygobject-internal.h \
+ pygobject-object.c \
+ pygobject-object.h \
pygparamspec.c \
pygparamspec.h \
pygpointer.c \
@@ -87,6 +89,7 @@ _gi_la_SOURCES = \
pygi-closure.h \
pygi-ccallback.c \
pygi-ccallback.h \
+ pygi-util.c \
pygi-util.h \
pygi-property.c \
pygi-property.h \
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 9206a508..d60a6a56 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -21,11 +21,16 @@
* USA
*/
+#include <glib-object.h>
+
#include "pyglib.h"
-#include "pygobject-private.h"
#include "pyginterface.h"
#include "pygi-repository.h"
#include "pyglib.h"
+#include "pygtype.h"
+#include "pygenum.h"
+#include "pygboxed.h"
+#include "pygflags.h"
#include "pygi-error.h"
#include "pygi-foreign.h"
#include "pygi-resulttuple.h"
@@ -44,6 +49,9 @@ PyObject *PyGIDeprecationWarning;
PyObject *_PyGIDefaultArgPlaceholder;
+/* Defined by PYGLIB_MODULE_START */
+extern PyObject *pyglib__gobject_module_create (void);
+
/* Returns a new flag/enum type or %NULL */
static PyObject *
flags_enum_from_gtype (GType g_type,
diff --git a/gi/gobjectmodule.c b/gi/gobjectmodule.c
index 726216dd..0dc26707 100644
--- a/gi/gobjectmodule.c
+++ b/gi/gobjectmodule.c
@@ -27,7 +27,7 @@
#include <girepository.h>
#include <pyglib.h>
#include <pythread.h>
-#include "pygobject-private.h"
+#include "gobjectmodule.h"
#include "pygboxed.h"
#include "pygenum.h"
#include "pygflags.h"
@@ -36,6 +36,7 @@
#include "pygpointer.h"
#include "pygtype.h"
#include "pygoptiongroup.h"
+#include "pygobject-object.h"
#include "pygi-value.h"
#include "pygi-error.h"
@@ -47,6 +48,7 @@ static gboolean log_handlers_disabled = FALSE;
static void pyg_flags_add_constants(PyObject *module, GType flags_type,
const gchar *strip_prefix);
+static int pyg_type_register(PyTypeObject *class, const char *type_name);
/* -------------- GDK threading hooks ---------------------------- */
@@ -72,7 +74,7 @@ _pyg_set_thread_block_funcs (PyGThreadBlockFunc block_threads_func,
* A function that can be used as a GDestroyNotify callback that will
* call Py_DECREF on the data.
*/
-void
+static void
pyg_destroy_notify(gpointer user_data)
{
PyObject *obj = (PyObject *)user_data;
@@ -1098,7 +1100,7 @@ pyg_type_add_interfaces(PyTypeObject *class, GType instance_type,
}
}
-int
+static int
pyg_type_register(PyTypeObject *class, const char *type_name)
{
PyObject *gtype;
@@ -1390,33 +1392,6 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs)
return (PyObject *) self;
}
-gboolean
-pyg_handler_marshal(gpointer user_data)
-{
- PyObject *tuple, *ret;
- gboolean res;
- PyGILState_STATE state;
-
- g_return_val_if_fail(user_data != NULL, FALSE);
-
- state = pyglib_gil_state_ensure();
-
- tuple = (PyObject *)user_data;
- ret = PyObject_CallObject(PyTuple_GetItem(tuple, 0),
- PyTuple_GetItem(tuple, 1));
- if (!ret) {
- PyErr_Print();
- res = FALSE;
- } else {
- res = PyObject_IsTrue(ret);
- Py_DECREF(ret);
- }
-
- pyglib_gil_state_release(state);
-
- return res;
-}
-
static int
pygobject_gil_state_ensure (void)
{
@@ -1797,27 +1772,6 @@ pyg_parse_constructor_args(GType obj_type,
return TRUE;
}
-PyObject *
-pyg_integer_richcompare(PyObject *v, PyObject *w, int op)
-{
- PyObject *result;
- gboolean t;
-
- switch (op) {
- case Py_EQ: t = PYGLIB_PyLong_AS_LONG(v) == PYGLIB_PyLong_AS_LONG(w); break;
- case Py_NE: t = PYGLIB_PyLong_AS_LONG(v) != PYGLIB_PyLong_AS_LONG(w); break;
- case Py_LE: t = PYGLIB_PyLong_AS_LONG(v) <= PYGLIB_PyLong_AS_LONG(w); break;
- case Py_GE: t = PYGLIB_PyLong_AS_LONG(v) >= PYGLIB_PyLong_AS_LONG(w); break;
- case Py_LT: t = PYGLIB_PyLong_AS_LONG(v) < PYGLIB_PyLong_AS_LONG(w); break;
- case Py_GT: t = PYGLIB_PyLong_AS_LONG(v) > PYGLIB_PyLong_AS_LONG(w); break;
- default: g_assert_not_reached();
- }
-
- result = t ? Py_True : Py_False;
- Py_INCREF(result);
- return result;
-}
-
static void
_log_func(const gchar *log_domain,
GLogLevelFlags log_level,
diff --git a/gi/gobjectmodule.h b/gi/gobjectmodule.h
new file mode 100644
index 00000000..11f99cf3
--- /dev/null
+++ b/gi/gobjectmodule.h
@@ -0,0 +1,11 @@
+#ifndef _PYGOBJECT_GOBJECTMODULE_H_
+#define _PYGOBJECT_GOBJECTMODULE_H_
+
+
+#include "pygobject-internal.h"
+
+int pygobject_constructv (PyGObject *self,
+ guint n_parameters,
+ GParameter *parameters);
+
+#endif /*_PYGOBJECT_GOBJECTMODULE_H_*/
diff --git a/gi/pygboxed.c b/gi/pygboxed.c
index 814cdb95..2eaff851 100644
--- a/gi/pygboxed.c
+++ b/gi/pygboxed.c
@@ -22,9 +22,11 @@
# include <config.h>
#endif
+#include <glib-object.h>
+
#include <pyglib.h>
-#include "pygobject-private.h"
#include "pygboxed.h"
+#include "pygtype.h"
#include "pygi-type.h"
diff --git a/gi/pygboxed.h b/gi/pygboxed.h
index 86f72d59..93b3de65 100644
--- a/gi/pygboxed.h
+++ b/gi/pygboxed.h
@@ -20,6 +20,17 @@
#ifndef __PYGOBJECT_BOXED_H__
#define __PYGOBJECT_BOXED_H__
+extern GQuark pygboxed_type_key;
+
+extern PyTypeObject PyGBoxed_Type;
+
+void pyg_register_boxed (PyObject *dict, const gchar *class_name,
+ GType boxed_type, PyTypeObject *type);
+PyObject * pyg_boxed_new (GType boxed_type, gpointer boxed,
+ gboolean copy_boxed, gboolean own_ref);
+
+const gchar * pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix);
+
void pygobject_boxed_register_types(PyObject *d);
#endif /* __PYGOBJECT_BOXED_H__ */
diff --git a/gi/pygenum.c b/gi/pygenum.c
index fb0873de..cea9c0fe 100644
--- a/gi/pygenum.c
+++ b/gi/pygenum.c
@@ -25,10 +25,12 @@
#include <pyglib.h>
#include "pyglib-python-compat.h"
-#include "pygobject-private.h"
#include "pygi-type.h"
+#include "pygi-util.h"
+#include "pygtype.h"
#include "pygenum.h"
+#include "pygboxed.h"
GQuark pygenum_class_key;
diff --git a/gi/pygenum.h b/gi/pygenum.h
index 6c01ec97..0625a949 100644
--- a/gi/pygenum.h
+++ b/gi/pygenum.h
@@ -20,6 +20,28 @@
#ifndef __PYGOBJECT_ENUM_H__
#define __PYGOBJECT_ENUM_H__
+extern GQuark pygenum_class_key;
+
+#define PyGEnum_Check(x) (PyObject_IsInstance((PyObject *)x, (PyObject *)&PyGEnum_Type) && g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_ENUM))
+
+typedef struct {
+ PYGLIB_PyLongObject parent;
+ int zero_pad; /* must always be 0 */
+ GType gtype;
+} PyGEnum;
+
+extern PyTypeObject PyGEnum_Type;
+
+PyObject * pyg_enum_add (PyObject * module,
+ const char * type_name,
+ const char * strip_prefix,
+ GType gtype);
+
+PyObject * pyg_enum_from_gtype (GType gtype,
+ int value);
+
+gint pyg_enum_get_value (GType enum_type, PyObject *obj, gint *val);
+
void pygobject_enum_register_types(PyObject *d);
#endif /* __PYGOBJECT_ENUM_H__ */
diff --git a/gi/pygflags.c b/gi/pygflags.c
index 0be3097e..693fca07 100644
--- a/gi/pygflags.c
+++ b/gi/pygflags.c
@@ -25,8 +25,10 @@
#include <pyglib.h>
#include "pygi-type.h"
-#include "pygobject-private.h"
+#include "pygi-util.h"
+#include "pygtype.h"
#include "pygflags.h"
+#include "pygboxed.h"
GQuark pygflags_class_key;
diff --git a/gi/pygflags.h b/gi/pygflags.h
index 3c7b0e82..9555b945 100644
--- a/gi/pygflags.h
+++ b/gi/pygflags.h
@@ -20,6 +20,27 @@
#ifndef __PYGOBJECT_FLAGS_H__
#define __PYGOBJECT_FLAGS_H__
+extern GQuark pygflags_class_key;
+
+typedef struct {
+ PYGLIB_PyLongObject parent;
+ int zero_pad; /* must always be 0 */
+ GType gtype;
+} PyGFlags;
+
+extern PyTypeObject PyGFlags_Type;
+
+#define PyGFlags_Check(x) (PyObject_IsInstance((PyObject *)x, (PyObject *)&PyGFlags_Type) && g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_FLAGS))
+
+extern PyObject * pyg_flags_add (PyObject * module,
+ const char * type_name,
+ const char * strip_prefix,
+ GType gtype);
+extern PyObject * pyg_flags_from_gtype (GType gtype,
+ guint value);
+
+gint pyg_flags_get_value (GType flag_type, PyObject *obj, guint *val);
+
void pygobject_flags_register_types(PyObject *d);
#endif /* __PYGOBJECT_FLAGS_H__ */
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 2e4dd400..e9bfe3b3 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -22,10 +22,12 @@
#include <string.h>
#include <time.h>
-#include "pygobject-private.h"
+#include "pygobject-internal.h"
#include <pyglib-python-compat.h>
#include <pyglib.h>
+#include <pygenum.h>
+#include <pygflags.h>
#include "pygi-argument.h"
#include "pygi-info.h"
diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c
index 470547d4..b6515c31 100644
--- a/gi/pygi-basictype.c
+++ b/gi/pygi-basictype.c
@@ -21,9 +21,9 @@
#include <Python.h>
#include <pyglib-python-compat.h>
+#include "pygtype.h"
#include "pygi-basictype.h"
#include "pygi-argument.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 c1e4b0ea..e9014f20 100644
--- a/gi/pygi-boxed.c
+++ b/gi/pygi-boxed.c
@@ -21,7 +21,8 @@
#include "pygi-boxed.h"
#include "pygi-info.h"
-#include "pygobject-private.h"
+#include "pygboxed.h"
+#include "pygtype.h"
#include <girepository.h>
#include <pyglib-python-compat.h>
diff --git a/gi/pygi-boxed.h b/gi/pygi-boxed.h
index 89942d07..86793224 100644
--- a/gi/pygi-boxed.h
+++ b/gi/pygi-boxed.h
@@ -22,7 +22,7 @@
#include <Python.h>
#include <girepository.h>
-#include "pygobject-private.h"
+#include "pygobject-internal.h"
G_BEGIN_DECLS
diff --git a/gi/pygi-cache.c b/gi/pygi-cache.c
index 263dc8ef..5080b666 100644
--- a/gi/pygi-cache.c
+++ b/gi/pygi-cache.c
@@ -22,6 +22,7 @@
#include <girepository.h>
#include "pyglib.h"
+#include "pygtype.h"
#include "pygi-info.h"
#include "pygi-cache.h"
#include "pygi-marshal-cleanup.h"
diff --git a/gi/pygi-ccallback.c b/gi/pygi-ccallback.c
index c7f3ecfe..3fe5366a 100644
--- a/gi/pygi-ccallback.c
+++ b/gi/pygi-ccallback.c
@@ -19,7 +19,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "pygobject-private.h"
#include "pygi-ccallback.h"
#include <girepository.h>
diff --git a/gi/pygi-enum-marshal.c b/gi/pygi-enum-marshal.c
index 945a8e0b..11c20499 100644
--- a/gi/pygi-enum-marshal.c
+++ b/gi/pygi-enum-marshal.c
@@ -23,8 +23,9 @@
#include <pyglib-python-compat.h>
#include "pygi-enum-marshal.h"
-#include "pygobject-private.h"
#include "pygi-type.h"
+#include "pygenum.h"
+#include "pygflags.h"
static gboolean
gi_argument_from_c_long (GIArgument *arg_out,
diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c
index 82392be1..f74b1e7c 100644
--- a/gi/pygi-foreign.c
+++ b/gi/pygi-foreign.c
@@ -26,7 +26,7 @@
# include <config.h>
#endif
-#include "pygobject-private.h"
+#include "pygobject-internal.h"
#include "pygi-foreign.h"
#include <girepository.h>
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 3422ea96..09c513b3 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -26,7 +26,7 @@
#include "pygi-type.h"
#include "pygi-argument.h"
#include "pygi-util.h"
-#include "pygobject-private.h"
+#include "pygtype.h"
#include <pyglib-python-compat.h>
diff --git a/gi/pygi-object.c b/gi/pygi-object.c
index 11ea2261..35a27908 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 "pygobject-private.h"
+#include "pygobject-object.h"
#include "pygparamspec.h"
/*
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index 4eb9ca8a..19cdb440 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -25,6 +25,7 @@
#include "pygi-value.h"
#include "pygi-argument.h"
#include "pygparamspec.h"
+#include "pygtype.h"
#include <girepository.h>
diff --git a/gi/pygi-property.h b/gi/pygi-property.h
index 19c720fb..d641b018 100644
--- a/gi/pygi-property.h
+++ b/gi/pygi-property.h
@@ -27,7 +27,7 @@
#include <Python.h>
#include <girepository.h>
-#include "pygobject-private.h"
+#include "pygobject-internal.h"
PyObject *
pygi_get_property_value (PyGObject *instance,
diff --git a/gi/pygi-signal-closure.h b/gi/pygi-signal-closure.h
index 80bc58c5..92e18708 100644
--- a/gi/pygi-signal-closure.h
+++ b/gi/pygi-signal-closure.h
@@ -25,7 +25,7 @@
#define __PYGI_SIGNAL_CLOSURE_H__
#include <girepository.h>
-#include "pygobject-private.h"
+#include "pygobject-internal.h"
G_BEGIN_DECLS
diff --git a/gi/pygi-source.c b/gi/pygi-source.c
index 1a847887..154b1cd6 100644
--- a/gi/pygi-source.c
+++ b/gi/pygi-source.c
@@ -23,12 +23,11 @@
* IN THE SOFTWARE.
*/
-#include "pygobject-private.h"
-
#include "pygi-info.h"
#include "pygi-boxed.h"
#include "pygi-type.h"
#include "pyglib.h"
+#include "pygboxed.h"
#include "pygi-source.h"
typedef struct
diff --git a/gi/pygi-struct-marshal.c b/gi/pygi-struct-marshal.c
index 0d365217..a4276a47 100644
--- a/gi/pygi-struct-marshal.c
+++ b/gi/pygi-struct-marshal.c
@@ -29,6 +29,9 @@
#include "pygi-type.h"
#include "pygi-boxed.h"
#include "pygi-info.h"
+#include "pygpointer.h"
+#include "pygboxed.h"
+#include "pygtype.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 5bbb7899..4d5b5411 100644
--- a/gi/pygi-struct.c
+++ b/gi/pygi-struct.c
@@ -23,7 +23,8 @@
#include "pygi-foreign.h"
#include "pygi-info.h"
#include "pygi-type.h"
-#include "pygobject-private.h"
+#include "pygtype.h"
+#include "pygpointer.h"
#include <girepository.h>
#include <pyglib-python-compat.h>
diff --git a/gi/pygi-struct.h b/gi/pygi-struct.h
index dde42dd4..8796a5e4 100644
--- a/gi/pygi-struct.h
+++ b/gi/pygi-struct.h
@@ -21,7 +21,7 @@
#define __PYGI_STRUCT_H__
#include <Python.h>
-#include <pygobject-private.h>
+#include <pygobject-internal.h>
G_BEGIN_DECLS
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index a1213f71..06d773a3 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -19,7 +19,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "pygobject-private.h"
+#include "pygtype.h"
#include "pygi-type.h"
#include <pyglib-python-compat.h>
diff --git a/gi/pygi-util.c b/gi/pygi-util.c
new file mode 100644
index 00000000..1d9201e6
--- /dev/null
+++ b/gi/pygi-util.c
@@ -0,0 +1,42 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pygtk- Python bindings for the GTK toolkit.
+ * Copyright (C) 1998-2003 James Henstridge
+ *
+ * gobjectmodule.c: wrapper for the gobject library.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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-util.h"
+
+PyObject *
+pyg_integer_richcompare(PyObject *v, PyObject *w, int op)
+{
+ PyObject *result;
+ gboolean t;
+
+ switch (op) {
+ case Py_EQ: t = PYGLIB_PyLong_AS_LONG(v) == PYGLIB_PyLong_AS_LONG(w); break;
+ case Py_NE: t = PYGLIB_PyLong_AS_LONG(v) != PYGLIB_PyLong_AS_LONG(w); break;
+ case Py_LE: t = PYGLIB_PyLong_AS_LONG(v) <= PYGLIB_PyLong_AS_LONG(w); break;
+ case Py_GE: t = PYGLIB_PyLong_AS_LONG(v) >= PYGLIB_PyLong_AS_LONG(w); break;
+ case Py_LT: t = PYGLIB_PyLong_AS_LONG(v) < PYGLIB_PyLong_AS_LONG(w); break;
+ case Py_GT: t = PYGLIB_PyLong_AS_LONG(v) > PYGLIB_PyLong_AS_LONG(w); break;
+ default: g_assert_not_reached();
+ }
+
+ result = t ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
+}
diff --git a/gi/pygi-util.h b/gi/pygi-util.h
index 3144d6e4..c7a6ca7b 100644
--- a/gi/pygi-util.h
+++ b/gi/pygi-util.h
@@ -1,8 +1,14 @@
#ifndef __PYGI_UTIL_H__
#define __PYGI_UTIL_H__
+#include <glib.h>
+#include "pygobject-internal.h"
+#include <pyglib-python-compat.h>
+
G_BEGIN_DECLS
+PyObject * pyg_integer_richcompare(PyObject *v, PyObject *w, int op);
+
#if PY_VERSION_HEX >= 0x03000000
#define _PyGI_ERROR_PREFIX(format, ...) G_STMT_START { \
diff --git a/gi/pygi-value.c b/gi/pygi-value.c
index 9da87a56..88faf630 100644
--- a/gi/pygi-value.c
+++ b/gi/pygi-value.c
@@ -20,8 +20,12 @@
#include "pygi-value.h"
#include "pygi-struct.h"
#include "pyglib-python-compat.h"
-#include "pygobject-private.h"
+#include "pygobject-object.h"
#include "pygtype.h"
+#include "pygenum.h"
+#include "pygpointer.h"
+#include "pygboxed.h"
+#include "pygflags.h"
#include "pygparamspec.h"
GIArgument
diff --git a/gi/pyginterface.c b/gi/pyginterface.c
index 40d54f7f..1737de5a 100644
--- a/gi/pyginterface.c
+++ b/gi/pyginterface.c
@@ -23,10 +23,11 @@
#endif
#include <Python.h>
+#include <glib-object.h>
#include "pyglib.h"
-#include "pygobject-private.h"
#include "pyginterface.h"
+#include "pygtype.h"
GQuark pyginterface_type_key;
GQuark pyginterface_info_key;
diff --git a/gi/pygobject-internal.h b/gi/pygobject-internal.h
new file mode 100644
index 00000000..2cd82c53
--- /dev/null
+++ b/gi/pygobject-internal.h
@@ -0,0 +1,7 @@
+#ifndef _PYGOBJECT_INTERNAL_H_
+#define _PYGOBJECT_INTERNAL_H_
+
+#define _INSIDE_PYGOBJECT_
+#include "pygobject.h"
+
+#endif /*_PYGOBJECT_INTERNAL_H_*/
diff --git a/gi/pygobject.c b/gi/pygobject-object.c
index e7ea5edc..b2fe4712 100644
--- a/gi/pygobject.c
+++ b/gi/pygobject-object.c
@@ -23,9 +23,12 @@
#endif
#include <pyglib.h>
-#include "pygobject-private.h"
+#include "pygobject-object.h"
#include "pyginterface.h"
#include "pygparamspec.h"
+#include "pygtype.h"
+#include "pygboxed.h"
+#include "gobjectmodule.h"
#include "pygi-value.h"
#include "pygi-type.h"
@@ -53,6 +56,26 @@ GQuark pygobject_wrapper_key;
GQuark pygobject_has_updated_constructor_key;
GQuark pygobject_instance_data_key;
+GClosure *
+gclosure_from_pyfunc(PyGObject *object, PyObject *func)
+{
+ GSList *l;
+ PyGObjectData *inst_data;
+ inst_data = pyg_object_peek_inst_data(object->obj);
+ if (inst_data) {
+ for (l = inst_data->closures; l; l = l->next) {
+ PyGClosure *pyclosure = l->data;
+ int res = PyObject_RichCompareBool(pyclosure->callback, func, Py_EQ);
+ if (res == -1) {
+ PyErr_Clear(); /* Is there anything else to do? */
+ } else if (res) {
+ return (GClosure*)pyclosure;
+ }
+ }
+ }
+ return NULL;
+}
+
/* Copied from glib. gobject uses hyphens in property names, but in Python
* we can only represent hyphens as underscores. Convert underscores to
* hyphens for glib compatibility. */
@@ -75,7 +98,7 @@ canonicalize_key (gchar *key)
/* -------------- class <-> wrapper manipulation --------------- */
-void
+static void
pygobject_data_free(PyGObjectData *data)
{
/* This function may be called after the python interpreter has already
diff --git a/gi/pygobject-object.h b/gi/pygobject-object.h
new file mode 100644
index 00000000..fb39a259
--- /dev/null
+++ b/gi/pygobject-object.h
@@ -0,0 +1,56 @@
+#ifndef _PYGOBJECT_OBJECT_H_
+#define _PYGOBJECT_OBJECT_H_
+
+#include <Python.h>
+#include <glib-object.h>
+#include "pyglib-python-compat.h"
+#include "pygobject-internal.h"
+
+/* Data that belongs to the GObject instance, not the Python wrapper */
+struct _PyGObjectData {
+ PyTypeObject *type; /* wrapper type for this instance */
+ GSList *closures;
+};
+
+extern GType PY_TYPE_OBJECT;
+extern GQuark pygobject_instance_data_key;
+extern GQuark pygobject_custom_key;
+extern GQuark pygobject_wrapper_key;
+extern GQuark pygobject_class_key;
+extern GQuark pygobject_class_init_key;
+
+extern PyTypeObject PyGObjectWeakRef_Type;
+extern PyTypeObject PyGPropsIter_Type;
+extern PyTypeObject PyGPropsDescr_Type;
+extern PyTypeObject PyGProps_Type;
+extern PyTypeObject PyGObject_Type;
+extern PyTypeObject *PyGObject_MetaType;
+
+static inline PyGObjectData *
+pyg_object_peek_inst_data(GObject *obj)
+{
+ return ((PyGObjectData *)
+ g_object_get_qdata(obj, pygobject_instance_data_key));
+}
+
+gboolean pygobject_prepare_construct_properties (GObjectClass *class,
+ PyObject *kwargs,
+ guint *n_params,
+ GParameter **params);
+void pygobject_register_class (PyObject *dict,
+ const gchar *type_name,
+ GType gtype, PyTypeObject *type,
+ PyObject *bases);
+void pygobject_register_wrapper (PyObject *self);
+PyObject * pygobject_new (GObject *obj);
+PyObject * pygobject_new_full (GObject *obj, gboolean steal, gpointer g_class);
+void pygobject_sink (GObject *obj);
+PyTypeObject *pygobject_lookup_class (GType gtype);
+void pygobject_watch_closure (PyObject *self, GClosure *closure);
+void pygobject_object_register_types(PyObject *d);
+void pygobject_ref_float(PyGObject *self);
+void pygobject_ref_sink(PyGObject *self);
+
+GClosure * gclosure_from_pyfunc(PyGObject *object, PyObject *func);
+
+#endif /*_PYGOBJECT_OBJECT_H_*/
diff --git a/gi/pygobject-private.h b/gi/pygobject-private.h
deleted file mode 100644
index b6242cd9..00000000
--- a/gi/pygobject-private.h
+++ /dev/null
@@ -1,186 +0,0 @@
-#ifndef _PYGOBJECT_PRIVATE_H_
-#define _PYGOBJECT_PRIVATE_H_
-
-#ifdef _PYGOBJECT_H_
-# error "include pygobject.h or pygobject-private.h, but not both"
-#endif
-
-#define _INSIDE_PYGOBJECT_
-#include "pygobject.h"
-
-#include "pyglib-python-compat.h"
-
-#define PYGOBJECT_REGISTER_GTYPE(d, type, name, gtype) \
- { \
- PyObject *o; \
- PYGLIB_REGISTER_TYPE(d, type, name); \
- PyDict_SetItemString(type.tp_dict, "__gtype__", \
- o=pyg_type_wrapper_new(gtype)); \
- Py_DECREF(o); \
-}
-
-/* from gobjectmodule.c */
-extern struct _PyGObject_Functions pygobject_api_functions;
-
-
-#ifndef Py_CLEAR /* since Python 2.4 */
-# define Py_CLEAR(op) \
- do { \
- if (op) { \
- PyObject *tmp = (PyObject *)(op); \
- (op) = NULL; \
- Py_DECREF(tmp); \
- } \
- } while (0)
-#endif
-
-extern GType PY_TYPE_OBJECT;
-
-extern GQuark pygboxed_type_key;
-extern GQuark pygboxed_marshal_key;
-extern GQuark pygenum_class_key;
-extern GQuark pygflags_class_key;
-extern GQuark pyginterface_type_key;
-extern GQuark pyginterface_info_key;
-extern GQuark pygobject_class_init_key;
-extern GQuark pygobject_class_key;
-extern GQuark pygobject_wrapper_key;
-extern GQuark pygpointer_class_key;
-extern GQuark pygobject_has_updated_constructor_key;
-extern GQuark pygobject_instance_data_key;
-extern GQuark pygobject_custom_key;
-
-void pygobject_data_free (PyGObjectData *data);
-void pyg_destroy_notify (gpointer user_data);
-gboolean pyg_handler_marshal (gpointer user_data);
-int pygobject_constructv (PyGObject *self,
- guint n_parameters,
- GParameter *parameters);
-
-PyObject *pyg_integer_richcompare(PyObject *v,
- PyObject *w,
- int op);
-
-void pygobject_ref_float(PyGObject *self);
-void pygobject_ref_sink(PyGObject *self);
-
-/* from pygtype.h */
-extern PyTypeObject PyGTypeWrapper_Type;
-
-PyObject *pyg_type_wrapper_new (GType type);
-GType pyg_type_from_object_strict (PyObject *obj, gboolean strict);
-GType pyg_type_from_object (PyObject *obj);
-
-gint pyg_enum_get_value (GType enum_type, PyObject *obj, gint *val);
-gint pyg_flags_get_value (GType flag_type, PyObject *obj, guint *val);
-int pyg_pyobj_to_unichar_conv (PyObject* py_obj, void* ptr);
-
-GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data);
-void pyg_closure_set_exception_handler(GClosure *closure,
- PyClosureExceptionHandler handler);
-GClosure *pyg_signal_class_closure_get(void);
-GClosure *gclosure_from_pyfunc(PyGObject *object, PyObject *func);
-
-PyObject *pyg_object_descr_doc_get(void);
-void pygobject_object_register_types(PyObject *d);
-
-extern PyTypeObject *PyGObject_MetaType;
-
-/* from pygobject.h */
-extern PyTypeObject PyGObject_Type;
-extern PyTypeObject PyGProps_Type;
-extern PyTypeObject PyGPropsDescr_Type;
-extern PyTypeObject PyGPropsIter_Type;
-
- /* Data that belongs to the GObject instance, not the Python wrapper */
-struct _PyGObjectData {
- PyTypeObject *type; /* wrapper type for this instance */
- GSList *closures;
-};
-
-void pygobject_register_class (PyObject *dict,
- const gchar *type_name,
- GType gtype, PyTypeObject *type,
- PyObject *bases);
-void pygobject_register_wrapper (PyObject *self);
-PyObject * pygobject_new (GObject *obj);
-PyObject * pygobject_new_full (GObject *obj, gboolean steal, gpointer g_class);
-void pygobject_sink (GObject *obj);
-PyTypeObject *pygobject_lookup_class (GType gtype);
-void pygobject_watch_closure (PyObject *self, GClosure *closure);
-int pyg_type_register (PyTypeObject *class,
- const gchar *type_name);
-
-/* from pygboxed.c */
-extern PyTypeObject PyGBoxed_Type;
-
-void pyg_register_boxed (PyObject *dict, const gchar *class_name,
- GType boxed_type, PyTypeObject *type);
-PyObject * pyg_boxed_new (GType boxed_type, gpointer boxed,
- gboolean copy_boxed, gboolean own_ref);
-
-extern PyTypeObject PyGPointer_Type;
-
-void pyg_register_pointer (PyObject *dict, const gchar *class_name,
- GType pointer_type, PyTypeObject *type);
-PyObject * pyg_pointer_new (GType pointer_type, gpointer pointer);
-
-const gchar * pyg_constant_strip_prefix(const gchar *name, const gchar *strip_prefix);
-
-/* pygflags */
-typedef struct {
- PYGLIB_PyLongObject parent;
- int zero_pad; /* must always be 0 */
- GType gtype;
-} PyGFlags;
-
-extern PyTypeObject PyGFlags_Type;
-
-#define PyGFlags_Check(x) (PyObject_IsInstance((PyObject *)x, (PyObject *)&PyGFlags_Type) && g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_FLAGS))
-
-extern PyObject * pyg_flags_add (PyObject * module,
- const char * type_name,
- const char * strip_prefix,
- GType gtype);
-extern PyObject * pyg_flags_from_gtype (GType gtype,
- guint value);
-
-/* pygenum */
-#define PyGEnum_Check(x) (PyObject_IsInstance((PyObject *)x, (PyObject *)&PyGEnum_Type) && g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_ENUM))
-
-typedef struct {
- PYGLIB_PyLongObject parent;
- int zero_pad; /* must always be 0 */
- GType gtype;
-} PyGEnum;
-
-extern PyTypeObject PyGEnum_Type;
-
-extern PyObject * pyg_enum_add (PyObject * module,
- const char * type_name,
- const char * strip_prefix,
- GType gtype);
-extern PyObject * pyg_enum_from_gtype (GType gtype,
- int value);
-
-/* pygtype.c */
-extern gboolean pyg_gtype_is_custom (GType gtype);
-
-/* pygobject.c */
-extern PyTypeObject PyGObjectWeakRef_Type;
-
-static inline PyGObjectData *
-pyg_object_peek_inst_data(GObject *obj)
-{
- return ((PyGObjectData *)
- g_object_get_qdata(obj, pygobject_instance_data_key));
-}
-
-gboolean pygobject_prepare_construct_properties (GObjectClass *class,
- PyObject *kwargs,
- guint *n_params,
- GParameter **params);
-/* Defined by PYGLIB_MODULE_START */
-extern PyObject *pyglib__gobject_module_create (void);
-
-#endif /*_PYGOBJECT_PRIVATE_H_*/
diff --git a/gi/pygparamspec.c b/gi/pygparamspec.c
index ff532436..0982b995 100644
--- a/gi/pygparamspec.c
+++ b/gi/pygparamspec.c
@@ -24,8 +24,11 @@
#endif
#include <pyglib.h>
+#include <glib-object.h>
-#include "pygobject-private.h"
+#include "pygenum.h"
+#include "pygflags.h"
+#include "pygtype.h"
#include "pygparamspec.h"
PYGLIB_DEFINE_TYPE("gobject.GParamSpec", PyGParamSpec_Type, PyGParamSpec);
diff --git a/gi/pygpointer.c b/gi/pygpointer.c
index d160fff1..64ca9838 100644
--- a/gi/pygpointer.c
+++ b/gi/pygpointer.c
@@ -23,8 +23,9 @@
#endif
#include <pyglib.h>
-#include "pygobject-private.h"
+#include <glib-object.h>
#include "pygpointer.h"
+#include "pygtype.h"
#include "pygi-type.h"
diff --git a/gi/pygpointer.h b/gi/pygpointer.h
index 792846e3..363362c2 100644
--- a/gi/pygpointer.h
+++ b/gi/pygpointer.h
@@ -20,6 +20,14 @@
#ifndef __PYGOBJECT_POINTER_H__
#define __PYGOBJECT_POINTER_H__
+extern GQuark pygpointer_class_key;
+
+extern PyTypeObject PyGPointer_Type;
+
+void pyg_register_pointer (PyObject *dict, const gchar *class_name,
+ GType pointer_type, PyTypeObject *type);
+PyObject * pyg_pointer_new (GType pointer_type, gpointer pointer);
+
void pygobject_pointer_register_types(PyObject *d);
#endif /* __PYGOBJECT_POINTER_H__ */
diff --git a/gi/pygtype.c b/gi/pygtype.c
index a3784c86..32132ad4 100644
--- a/gi/pygtype.c
+++ b/gi/pygtype.c
@@ -24,9 +24,14 @@
#include <pyglib.h>
-#include "pygobject-private.h"
+#include "pygobject-object.h"
+#include "pygboxed.h"
+#include "pygenum.h"
+#include "pygflags.h"
#include "pygparamspec.h"
#include "pygtype.h"
+#include "pygpointer.h"
+#include "pyginterface.h"
#include "pygi-type.h"
#include "pygi-value.h"
@@ -945,26 +950,6 @@ pyg_signal_class_closure_get(void)
return closure;
}
-GClosure *
-gclosure_from_pyfunc(PyGObject *object, PyObject *func)
-{
- GSList *l;
- PyGObjectData *inst_data;
- inst_data = pyg_object_peek_inst_data(object->obj);
- if (inst_data) {
- for (l = inst_data->closures; l; l = l->next) {
- PyGClosure *pyclosure = l->data;
- int res = PyObject_RichCompareBool(pyclosure->callback, func, Py_EQ);
- if (res == -1) {
- PyErr_Clear(); /* Is there anything else to do? */
- } else if (res) {
- return (GClosure*)pyclosure;
- }
- }
- }
- return NULL;
-}
-
/* ----- __doc__ descriptor for GObject and GInterface ----- */
static void
diff --git a/gi/pygtype.h b/gi/pygtype.h
index f21cf1f7..82c2523c 100644
--- a/gi/pygtype.h
+++ b/gi/pygtype.h
@@ -23,6 +23,18 @@
#include <glib-object.h>
#include <Python.h>
+#include "pygobject-internal.h"
+
+#define PYGOBJECT_REGISTER_GTYPE(d, type, name, gtype) \
+ { \
+ PyObject *o; \
+ PYGLIB_REGISTER_TYPE(d, type, name); \
+ PyDict_SetItemString(type.tp_dict, "__gtype__", \
+ o=pyg_type_wrapper_new(gtype)); \
+ Py_DECREF(o); \
+}
+
+extern PyTypeObject PyGTypeWrapper_Type;
typedef PyObject *(* fromvaluefunc)(const GValue *value);
typedef int (*tovaluefunc)(GValue *value, PyObject *obj);
@@ -34,10 +46,23 @@ typedef struct {
PyGTypeMarshal *pyg_type_lookup(GType type);
+gboolean pyg_gtype_is_custom (GType gtype);
+
void pyg_register_gtype_custom(GType gtype,
fromvaluefunc from_func,
tovaluefunc to_func);
void pygobject_type_register_types(PyObject *d);
+PyObject *pyg_object_descr_doc_get(void);
+PyObject *pyg_type_wrapper_new (GType type);
+GType pyg_type_from_object_strict (PyObject *obj, gboolean strict);
+GType pyg_type_from_object (PyObject *obj);
+
+int pyg_pyobj_to_unichar_conv (PyObject* py_obj, void* ptr);
+
+GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data);
+GClosure *pyg_signal_class_closure_get(void);
+void pyg_closure_set_exception_handler(GClosure *closure,
+ PyClosureExceptionHandler handler);
#endif /* __PYGOBJECT_TYPE_H__ */