[pygobject] Remove pygobject-private.h and rename pygobject.c to pygobject-object.c



commit f5dd1551371308d33df9627bc8cc0e34fa68a2a8
Author: Christoph Reiter <creiter src gnome org>
Date:   Tue May 31 18:47:54 2016 +0200

    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

 gi/Makefile.am                         |    7 +-
 gi/gimodule.c                          |   10 ++-
 gi/gobjectmodule.c                     |   56 +---------
 gi/gobjectmodule.h                     |   11 ++
 gi/pygboxed.c                          |    4 +-
 gi/pygboxed.h                          |   11 ++
 gi/pygenum.c                           |    4 +-
 gi/pygenum.h                           |   22 ++++
 gi/pygflags.c                          |    4 +-
 gi/pygflags.h                          |   21 ++++
 gi/pygi-argument.c                     |    4 +-
 gi/pygi-basictype.c                    |    2 +-
 gi/pygi-boxed.c                        |    3 +-
 gi/pygi-boxed.h                        |    2 +-
 gi/pygi-cache.c                        |    1 +
 gi/pygi-ccallback.c                    |    1 -
 gi/pygi-enum-marshal.c                 |    3 +-
 gi/pygi-foreign.c                      |    2 +-
 gi/pygi-info.c                         |    2 +-
 gi/pygi-object.c                       |    2 +-
 gi/pygi-property.c                     |    1 +
 gi/pygi-property.h                     |    2 +-
 gi/pygi-signal-closure.h               |    2 +-
 gi/pygi-source.c                       |    3 +-
 gi/pygi-struct-marshal.c               |    3 +
 gi/pygi-struct.c                       |    3 +-
 gi/pygi-struct.h                       |    2 +-
 gi/pygi-type.c                         |    2 +-
 gi/pygi-util.c                         |   42 +++++++
 gi/pygi-util.h                         |    6 +
 gi/pygi-value.c                        |    6 +-
 gi/pyginterface.c                      |    3 +-
 gi/pygobject-internal.h                |    7 ++
 gi/{pygobject.c => pygobject-object.c} |   27 +++++-
 gi/pygobject-object.h                  |   56 ++++++++++
 gi/pygobject-private.h                 |  186 --------------------------------
 gi/pygparamspec.c                      |    5 +-
 gi/pygpointer.c                        |    3 +-
 gi/pygpointer.h                        |    8 ++
 gi/pygtype.c                           |   27 +----
 gi/pygtype.h                           |   25 +++++
 41 files changed, 305 insertions(+), 286 deletions(-)
---
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 3dee504..defe77e 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 9206a50..d60a6a5 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 726216d..0dc2670 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 0000000..11f99cf
--- /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 814cdb9..2eaff85 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 86f72d5..93b3de6 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 fb0873d..cea9c0f 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 6c01ec9..0625a94 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 0be3097..693fca0 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 3c7b0e8..9555b94 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 2e4dd40..e9bfe3b 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 470547d..b6515c3 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 c1e4b0e..e9014f2 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 89942d0..8679322 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 263dc8e..5080b66 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 c7f3ecf..3fe5366 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 945a8e0..11c2049 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 82392be..f74b1e7 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 3422ea9..09c513b 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 11ea226..35a2790 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 4eb9ca8..19cdb44 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 19c720f..d641b01 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 80bc58c..92e1870 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 1a84788..154b1cd 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 0d36521..a4276a4 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 5bbb789..4d5b541 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 dde42dd..8796a5e 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 a1213f7..06d773a 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 0000000..1d9201e
--- /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 3144d6e..c7a6ca7 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 9da87a5..88faf63 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 40d54f7..1737de5 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 0000000..2cd82c5
--- /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
similarity index 99%
rename from gi/pygobject.c
rename to gi/pygobject-object.c
index e7ea5ed..b2fe471 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 0000000..fb39a25
--- /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/pygparamspec.c b/gi/pygparamspec.c
index ff53243..0982b99 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 d160fff..64ca983 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 792846e..363362c 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 a3784c8..32132ad 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 f21cf1f..82c2523 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__ */


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