1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * vim: tabstop=4 shiftwidth=4 expandtab
4 * Copyright (C) 2005-2009 Johan Dahlin <johan@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
29 #define NO_IMPORT_PYGOBJECT
30 #include <pygobject.h>
32 #include <girepository.h>
33 #include "pygi-cache.h"
37 GIRepository *repository;
43 PyObject *inst_weakreflist;
44 PyGICallableCache *cache;
49 gboolean free_on_dealloc;
54 gboolean slice_allocated;
64 GDestroyNotify destroy_notify_func;
65 PyGICallableCache *cache;
68 typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
69 GIInterfaceInfo *interface_info,
72 typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
74 typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
78 PyObject* (*type_import_by_g_type) (GType g_type);
79 PyObject* (*get_property_value) (PyGObject *instance,
81 gint (*set_property_value) (PyGObject *instance,
84 GClosure * (*signal_closure_new) (PyGObject *instance,
85 const gchar *sig_name,
89 void (*register_foreign_struct) (const char* namespace_,
91 PyGIArgOverrideToGIArgumentFunc to_func,
92 PyGIArgOverrideFromGIArgumentFunc from_func,
93 PyGIArgOverrideReleaseFunc release_func);
96 static struct PyGI_API *PyGI_API = NULL;
101 if (PyGI_API != NULL) {
104 #if PY_VERSION_HEX >= 0x03000000
105 PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
107 PyGI_API = (struct PyGI_API*) PyCObject_Import("gi", "_API");
109 if (PyGI_API == NULL) {
116 static inline PyObject *
117 pygi_type_import_by_g_type (GType g_type)
119 if (_pygi_import() < 0) {
122 return PyGI_API->type_import_by_g_type(g_type);
125 static inline PyObject *
126 pygi_get_property_value (PyGObject *instance,
129 if (_pygi_import() < 0) {
132 return PyGI_API->get_property_value(instance, pspec);
136 pygi_set_property_value (PyGObject *instance,
140 if (_pygi_import() < 0) {
143 return PyGI_API->set_property_value(instance, pspec, value);
146 static inline GClosure *
147 pygi_signal_closure_new (PyGObject *instance,
148 const gchar *sig_name,
150 PyObject *extra_args,
153 if (_pygi_import() < 0) {
156 return PyGI_API->signal_closure_new(instance, sig_name, callback, extra_args, swap_data);
159 static inline PyObject *
160 pygi_register_foreign_struct (const char* namespace_,
162 PyGIArgOverrideToGIArgumentFunc to_func,
163 PyGIArgOverrideFromGIArgumentFunc from_func,
164 PyGIArgOverrideReleaseFunc release_func)
166 if (_pygi_import() < 0) {
169 PyGI_API->register_foreign_struct(namespace_,
177 #endif /* __PYGI_H__ */