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"
35 extern PyObject *PyGIDeprecationWarning;
39 GIRepository *repository;
45 PyObject *inst_weakreflist;
46 PyGICallableCache *cache;
52 /* Reference the unbound version of this struct.
53 * We use this for the actual call to invoke because it manages the cache.
55 struct PyGICallableInfo *py_unbound_info;
57 /* Holds bound argument for instance, class, and vfunc methods. */
58 PyObject *py_bound_arg;
64 gboolean free_on_dealloc;
69 gboolean slice_allocated;
79 GDestroyNotify destroy_notify_func;
80 PyGICallableCache *cache;
83 typedef PyObject * (*PyGIArgOverrideToGIArgumentFunc) (PyObject *value,
84 GIInterfaceInfo *interface_info,
87 typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
89 typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
93 PyObject* (*type_import_by_g_type) (GType g_type);
94 PyObject* (*get_property_value) (PyGObject *instance,
96 gint (*set_property_value) (PyGObject *instance,
99 GClosure * (*signal_closure_new) (PyGObject *instance,
101 const gchar *sig_name,
103 PyObject *extra_args,
104 PyObject *swap_data);
105 void (*register_foreign_struct) (const char* namespace_,
107 PyGIArgOverrideToGIArgumentFunc to_func,
108 PyGIArgOverrideFromGIArgumentFunc from_func,
109 PyGIArgOverrideReleaseFunc release_func);
112 static struct PyGI_API *PyGI_API = NULL;
117 if (PyGI_API != NULL) {
120 PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
121 if (PyGI_API == NULL) {
128 static inline PyObject *
129 pygi_type_import_by_g_type (GType g_type)
131 if (_pygi_import() < 0) {
134 return PyGI_API->type_import_by_g_type(g_type);
137 static inline PyObject *
138 pygi_get_property_value (PyGObject *instance,
141 if (_pygi_import() < 0) {
144 return PyGI_API->get_property_value(instance, pspec);
148 pygi_set_property_value (PyGObject *instance,
152 if (_pygi_import() < 0) {
155 return PyGI_API->set_property_value(instance, pspec, value);
158 static inline GClosure *
159 pygi_signal_closure_new (PyGObject *instance,
161 const gchar *sig_name,
163 PyObject *extra_args,
166 if (_pygi_import() < 0) {
169 return PyGI_API->signal_closure_new(instance, g_type, sig_name, callback, extra_args, swap_data);
172 static inline PyObject *
173 pygi_register_foreign_struct (const char* namespace_,
175 PyGIArgOverrideToGIArgumentFunc to_func,
176 PyGIArgOverrideFromGIArgumentFunc from_func,
177 PyGIArgOverrideReleaseFunc release_func)
179 if (_pygi_import() < 0) {
182 PyGI_API->register_foreign_struct(namespace_,
190 #endif /* __PYGI_H__ */