summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-03-22 14:13:01 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2014-05-05 16:05:51 -0700
commitdef47144b63a1492ebf47a4eadb535f45253ff3a (patch)
treeb0249801e2633ba32afe174919d6c3eacad7b163 /gi
parent4c2e6914bf0277ebc3a6a4426f33a1b378a04b00 (diff)
downloadpygobject-def47144b63a1492ebf47a4eadb535f45253ff3a.tar.gz
Move pygi foreign API into pygi-foreign-api.h
Move limited set of APIs necessary for registering foreign marshalers into pygi-foreign-api.h. Remove "_real" from internally used APIs and add necessary includes to the rest of pygobject for calling directly (instead of going through the PyCapsule API within PyGI itself). This is needed to avoid compilation errors when including pygobject.h in foreign marshaling plugins which conflicts with pygobject-private.h. https://bugzilla.gnome.org/show_bug.cgi?id=694604
Diffstat (limited to 'gi')
-rw-r--r--gi/Makefile.am1
-rw-r--r--gi/gimodule.c6
-rw-r--r--gi/pygboxed.c1
-rw-r--r--gi/pygenum.c1
-rw-r--r--gi/pygflags.c1
-rw-r--r--gi/pygi-foreign-api.h85
-rw-r--r--gi/pygi-foreign-cairo.c8
-rw-r--r--gi/pygi-foreign.c10
-rw-r--r--gi/pygi-foreign.h14
-rw-r--r--gi/pygi-property.c8
-rw-r--r--gi/pygi-property.h14
-rw-r--r--gi/pygi-signal-closure.c12
-rw-r--r--gi/pygi-signal-closure.h15
-rw-r--r--gi/pygi-type.c4
-rw-r--r--gi/pygi-type.h2
-rw-r--r--gi/pygi.h107
-rw-r--r--gi/pygobject.c3
-rw-r--r--gi/pygpointer.c1
18 files changed, 139 insertions, 154 deletions
diff --git a/gi/Makefile.am b/gi/Makefile.am
index b00d30a1..61e4ee7b 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -71,6 +71,7 @@ _gi_la_SOURCES = \
pygi-info.h \
pygi-foreign.c \
pygi-foreign.h \
+ pygi-foreign-api.h \
pygi-struct.c \
pygi-struct.h \
pygi-source.c \
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 17e85878..1731190c 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -620,11 +620,7 @@ static PyMethodDef _gi_functions[] = {
};
static struct PyGI_API CAPI = {
- pygi_type_import_by_g_type_real,
- pygi_get_property_value_real,
- pygi_set_property_value_real,
- pygi_signal_closure_new_real,
- pygi_register_foreign_struct_real,
+ pygi_register_foreign_struct,
};
PYGLIB_MODULE_START(_gi, "_gi")
diff --git a/gi/pygboxed.c b/gi/pygboxed.c
index 35716a25..5e579dbc 100644
--- a/gi/pygboxed.c
+++ b/gi/pygboxed.c
@@ -27,6 +27,7 @@
#include "pygboxed.h"
#include "pygi.h"
+#include "pygi-type.h"
GQuark pygboxed_type_key;
GQuark pygboxed_marshal_key;
diff --git a/gi/pygenum.c b/gi/pygenum.c
index 1b9b50e9..053518f8 100644
--- a/gi/pygenum.c
+++ b/gi/pygenum.c
@@ -26,6 +26,7 @@
#include <pyglib.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 c14bf7d9..a7df8ce2 100644
--- a/gi/pygflags.c
+++ b/gi/pygflags.c
@@ -28,6 +28,7 @@
#include "pygflags.h"
#include "pygi.h"
+#include "pygi-type.h"
GQuark pygflags_class_key;
diff --git a/gi/pygi-foreign-api.h b/gi/pygi-foreign-api.h
new file mode 100644
index 00000000..93675187
--- /dev/null
+++ b/gi/pygi-foreign-api.h
@@ -0,0 +1,85 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * vim: tabstop=4 shiftwidth=4 expandtab
+ *
+ * Copyright (C) 2005-2009 Johan Dahlin <johan@gnome.org>
+ *
+ * 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/>.
+ */
+
+#ifndef __PYGI_FOREIGN_API_H__
+#define __PYGI_FOREIGN_API_H__
+
+#include <girepository.h>
+#include <pygobject.h>
+
+typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
+ GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ GIArgument *arg);
+typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
+ GITransfer transfer,
+ gpointer data);
+typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
+ gpointer struct_);
+
+
+struct PyGI_API {
+ void (*register_foreign_struct) (const char* namespace_,
+ const char* name,
+ PyGIArgOverrideToGIArgumentFunc to_func,
+ PyGIArgOverrideFromGIArgumentFunc from_func,
+ PyGIArgOverrideReleaseFunc release_func);
+};
+
+
+#ifndef _INSIDE_PYGOBJECT_
+
+static struct PyGI_API *PyGI_API = NULL;
+
+static int
+_pygi_import (void)
+{
+ if (PyGI_API != NULL) {
+ return 1;
+ }
+ PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
+ if (PyGI_API == NULL) {
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static inline PyObject *
+pygi_register_foreign_struct (const char* namespace_,
+ const char* name,
+ PyGIArgOverrideToGIArgumentFunc to_func,
+ PyGIArgOverrideFromGIArgumentFunc from_func,
+ PyGIArgOverrideReleaseFunc release_func)
+{
+ if (_pygi_import() < 0) {
+ return NULL;
+ }
+ PyGI_API->register_foreign_struct(namespace_,
+ name,
+ to_func,
+ from_func,
+ release_func);
+ Py_RETURN_NONE;
+}
+
+#endif /* _INSIDE_PYGOBJECT_ */
+
+#endif /* __PYGI_FOREIGN_API_H__ */
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index 8261a07f..a53ae4fd 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -31,9 +31,11 @@ static Pycairo_CAPI_t *Pycairo_CAPI;
#include <pycairo/py3cairo.h>
#endif
-
-#include "pygi-foreign.h"
-
+/* Limit includes from PyGI to APIs which do not have link dependencies
+ * (pygobject.h and pygi-foreign-api.h) since _gi_cairo is built as a separate
+ * shared library that interacts with PyGI through a PyCapsule API at runtime.
+ */
+#include <pygi-foreign-api.h>
#include <pyglib-python-compat.h>
static PyObject *
diff --git a/gi/pygi-foreign.c b/gi/pygi-foreign.c
index f3c1a344..6e0bf79d 100644
--- a/gi/pygi-foreign.c
+++ b/gi/pygi-foreign.c
@@ -151,11 +151,11 @@ pygi_struct_foreign_release (GIBaseInfo *base_info,
}
void
-pygi_register_foreign_struct_real (const char* namespace_,
- const char* name,
- PyGIArgOverrideToGIArgumentFunc to_func,
- PyGIArgOverrideFromGIArgumentFunc from_func,
- PyGIArgOverrideReleaseFunc release_func)
+pygi_register_foreign_struct (const char* namespace_,
+ const char* name,
+ PyGIArgOverrideToGIArgumentFunc to_func,
+ PyGIArgOverrideFromGIArgumentFunc from_func,
+ PyGIArgOverrideReleaseFunc release_func)
{
PyGIForeignStruct *new_struct = g_slice_new (PyGIForeignStruct);
new_struct->namespace = namespace_;
diff --git a/gi/pygi-foreign.h b/gi/pygi-foreign.h
index 478d7594..acec0698 100644
--- a/gi/pygi-foreign.h
+++ b/gi/pygi-foreign.h
@@ -26,9 +26,7 @@
#define __PYGI_FOREIGN_H__
#include <Python.h>
-#include <girepository.h>
-
-#include "pygi.h"
+#include "pygi-foreign-api.h"
PyObject *pygi_struct_foreign_convert_to_g_argument (PyObject *value,
GIInterfaceInfo *interface_info,
@@ -40,10 +38,10 @@ PyObject *pygi_struct_foreign_convert_from_g_argument (GIInterfaceInfo *interfac
PyObject *pygi_struct_foreign_release (GITypeInfo *type_info,
gpointer struct_);
-void pygi_register_foreign_struct_real (const char* namespace_,
- const char* name,
- PyGIArgOverrideToGIArgumentFunc to_func,
- PyGIArgOverrideFromGIArgumentFunc from_func,
- PyGIArgOverrideReleaseFunc release_func);
+void pygi_register_foreign_struct (const char* namespace_,
+ const char* name,
+ PyGIArgOverrideToGIArgumentFunc to_func,
+ PyGIArgOverrideFromGIArgumentFunc from_func,
+ PyGIArgOverrideReleaseFunc release_func);
#endif /* __PYGI_FOREIGN_H__ */
diff --git a/gi/pygi-property.c b/gi/pygi-property.c
index 6f805063..f7cb032b 100644
--- a/gi/pygi-property.c
+++ b/gi/pygi-property.c
@@ -105,7 +105,7 @@ g_value_get_or_dup_boxed (const GValue *value, GITransfer transfer)
}
PyObject *
-pygi_get_property_value_real (PyGObject *instance, GParamSpec *pspec)
+pygi_get_property_value (PyGObject *instance, GParamSpec *pspec)
{
GIPropertyInfo *property_info = NULL;
GValue value = { 0, };
@@ -271,9 +271,9 @@ out:
}
gint
-pygi_set_property_value_real (PyGObject *instance,
- GParamSpec *pspec,
- PyObject *py_value)
+pygi_set_property_value (PyGObject *instance,
+ GParamSpec *pspec,
+ PyObject *py_value)
{
GIPropertyInfo *property_info = NULL;
GITypeInfo *type_info = NULL;
diff --git a/gi/pygi-property.h b/gi/pygi-property.h
index 875d21e2..5678bc33 100644
--- a/gi/pygi-property.h
+++ b/gi/pygi-property.h
@@ -27,13 +27,15 @@
#include <Python.h>
#include <girepository.h>
-#include "pygi.h"
+#include "pygobject.h"
-PyObject *pygi_get_property_value_real (PyGObject *instance,
- GParamSpec *pspec);
+PyObject *
+pygi_get_property_value (PyGObject *instance,
+ GParamSpec *pspec);
-gint pygi_set_property_value_real (PyGObject *instance,
- GParamSpec *pspec,
- PyObject *py_value);
+gint
+pygi_set_property_value (PyGObject *instance,
+ GParamSpec *pspec,
+ PyObject *py_value);
#endif /* __PYGI_PROPERTY_H__ */
diff --git a/gi/pygi-signal-closure.c b/gi/pygi-signal-closure.c
index c5f51af6..079669cf 100644
--- a/gi/pygi-signal-closure.c
+++ b/gi/pygi-signal-closure.c
@@ -171,12 +171,12 @@ pygi_signal_closure_marshal(GClosure *closure,
}
GClosure *
-pygi_signal_closure_new_real (PyGObject *instance,
- GType g_type,
- const gchar *signal_name,
- PyObject *callback,
- PyObject *extra_args,
- PyObject *swap_data)
+pygi_signal_closure_new (PyGObject *instance,
+ GType g_type,
+ const gchar *signal_name,
+ PyObject *callback,
+ PyObject *extra_args,
+ PyObject *swap_data)
{
GClosure *closure = NULL;
PyGISignalClosure *pygi_closure = NULL;
diff --git a/gi/pygi-signal-closure.h b/gi/pygi-signal-closure.h
index ffdd29c4..5cc191b8 100644
--- a/gi/pygi-signal-closure.h
+++ b/gi/pygi-signal-closure.h
@@ -24,7 +24,7 @@
#ifndef __PYGI_SIGNAL_CLOSURE_H__
#define __PYGI_SIGNAL_CLOSURE_H__
-#include "pygi.h"
+#include "pygobject.h"
G_BEGIN_DECLS
@@ -35,12 +35,13 @@ typedef struct _PyGISignalClosure
GISignalInfo *signal_info;
} PyGISignalClosure;
-GClosure * pygi_signal_closure_new_real (PyGObject *instance,
- GType g_type,
- const gchar *sig_name,
- PyObject *callback,
- PyObject *extra_args,
- PyObject *swap_data);
+GClosure *
+pygi_signal_closure_new (PyGObject *instance,
+ GType g_type,
+ const gchar *sig_name,
+ PyObject *callback,
+ PyObject *extra_args,
+ PyObject *swap_data);
G_END_DECLS
diff --git a/gi/pygi-type.c b/gi/pygi-type.c
index b8d4c65e..924e0b80 100644
--- a/gi/pygi-type.c
+++ b/gi/pygi-type.c
@@ -50,7 +50,7 @@ _pygi_type_import_by_name (const char *namespace_,
}
PyObject *
-pygi_type_import_by_g_type_real (GType g_type)
+pygi_type_import_by_g_type (GType g_type)
{
GIRepository *repository;
GIBaseInfo *info;
@@ -89,7 +89,7 @@ _pygi_type_get_from_g_type (GType g_type)
py_type = PyObject_GetAttrString (py_g_type, "pytype");
if (py_type == Py_None) {
- py_type = pygi_type_import_by_g_type_real (g_type);
+ py_type = pygi_type_import_by_g_type (g_type);
}
Py_DECREF (py_g_type);
diff --git a/gi/pygi-type.h b/gi/pygi-type.h
index 822a4414..fdac5c07 100644
--- a/gi/pygi-type.h
+++ b/gi/pygi-type.h
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
/* Public */
-PyObject *pygi_type_import_by_g_type_real (GType g_type);
+PyObject *pygi_type_import_by_g_type (GType g_type);
/* Private */
diff --git a/gi/pygi.h b/gi/pygi.h
index a67696e8..2a9ee145 100644
--- a/gi/pygi.h
+++ b/gi/pygi.h
@@ -78,112 +78,5 @@ typedef struct {
PyGICallableCache *cache;
} PyGICCallback;
-typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
- GIInterfaceInfo *interface_info,
- GITransfer transfer,
- GIArgument *arg);
-typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
- GITransfer transfer,
- gpointer data);
-typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
- gpointer struct_);
-
-struct PyGI_API {
- PyObject* (*type_import_by_g_type) (GType g_type);
- PyObject* (*get_property_value) (PyGObject *instance,
- GParamSpec *pspec);
- gint (*set_property_value) (PyGObject *instance,
- GParamSpec *pspec,
- PyObject *value);
- GClosure * (*signal_closure_new) (PyGObject *instance,
- GType g_type,
- const gchar *sig_name,
- PyObject *callback,
- PyObject *extra_args,
- PyObject *swap_data);
- void (*register_foreign_struct) (const char* namespace_,
- const char* name,
- PyGIArgOverrideToGIArgumentFunc to_func,
- PyGIArgOverrideFromGIArgumentFunc from_func,
- PyGIArgOverrideReleaseFunc release_func);
-};
-
-static struct PyGI_API *PyGI_API = NULL;
-
-static int
-_pygi_import (void)
-{
- if (PyGI_API != NULL) {
- return 1;
- }
- PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
- if (PyGI_API == NULL) {
- return -1;
- }
-
- return 0;
-}
-
-static inline PyObject *
-pygi_type_import_by_g_type (GType g_type)
-{
- if (_pygi_import() < 0) {
- return NULL;
- }
- return PyGI_API->type_import_by_g_type(g_type);
-}
-
-static inline PyObject *
-pygi_get_property_value (PyGObject *instance,
- GParamSpec *pspec)
-{
- if (_pygi_import() < 0) {
- return NULL;
- }
- return PyGI_API->get_property_value(instance, pspec);
-}
-
-static inline gint
-pygi_set_property_value (PyGObject *instance,
- GParamSpec *pspec,
- PyObject *value)
-{
- if (_pygi_import() < 0) {
- return -1;
- }
- return PyGI_API->set_property_value(instance, pspec, value);
-}
-
-static inline GClosure *
-pygi_signal_closure_new (PyGObject *instance,
- GType g_type,
- const gchar *sig_name,
- PyObject *callback,
- PyObject *extra_args,
- PyObject *swap_data)
-{
- if (_pygi_import() < 0) {
- return NULL;
- }
- return PyGI_API->signal_closure_new(instance, g_type, sig_name, callback, extra_args, swap_data);
-}
-
-static inline PyObject *
-pygi_register_foreign_struct (const char* namespace_,
- const char* name,
- PyGIArgOverrideToGIArgumentFunc to_func,
- PyGIArgOverrideFromGIArgumentFunc from_func,
- PyGIArgOverrideReleaseFunc release_func)
-{
- if (_pygi_import() < 0) {
- return NULL;
- }
- PyGI_API->register_foreign_struct(namespace_,
- name,
- to_func,
- from_func,
- release_func);
- Py_RETURN_NONE;
-}
#endif /* __PYGI_H__ */
diff --git a/gi/pygobject.c b/gi/pygobject.c
index 04fd6a5b..1a011e1d 100644
--- a/gi/pygobject.c
+++ b/gi/pygobject.c
@@ -29,6 +29,9 @@
#include "pygi.h"
#include "pygi-value.h"
+#include "pygi-type.h"
+#include "pygi-property.h"
+#include "pygi-signal-closure.h"
static void pygobject_dealloc(PyGObject *self);
static int pygobject_traverse(PyGObject *self, visitproc visit, void *arg);
diff --git a/gi/pygpointer.c b/gi/pygpointer.c
index 27296957..7e39429e 100644
--- a/gi/pygpointer.c
+++ b/gi/pygpointer.c
@@ -27,6 +27,7 @@
#include "pygpointer.h"
#include "pygi.h"
+#include "pygi-type.h"
GQuark pygpointer_class_key;