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, see <http://www.gnu.org/licenses/>.
20 #ifndef __PYGI_FOREIGN_API_H__
21 #define __PYGI_FOREIGN_API_H__
23 #include <girepository.h>
24 #include <pygobject.h>
26 typedef PyObject
* (*PyGIArgOverrideToGIArgumentFunc
) (PyObject
*value
,
27 GIInterfaceInfo
*interface_info
,
30 typedef PyObject
* (*PyGIArgOverrideFromGIArgumentFunc
) (GIInterfaceInfo
*interface_info
,
33 typedef PyObject
* (*PyGIArgOverrideReleaseFunc
) (GITypeInfo
*type_info
,
38 void (*register_foreign_struct
) (const char* namespace_
,
40 PyGIArgOverrideToGIArgumentFunc to_func
,
41 PyGIArgOverrideFromGIArgumentFunc from_func
,
42 PyGIArgOverrideReleaseFunc release_func
);
46 #ifndef _INSIDE_PYGOBJECT_
48 static struct PyGI_API
*PyGI_API
= NULL
;
53 if (PyGI_API
!= NULL
) {
56 PyGI_API
= (struct PyGI_API
*) PyCapsule_Import("gi._API", FALSE
);
57 if (PyGI_API
== NULL
) {
65 static inline PyObject
*
66 pygi_register_foreign_struct (const char* namespace_
,
68 PyGIArgOverrideToGIArgumentFunc to_func
,
69 PyGIArgOverrideFromGIArgumentFunc from_func
,
70 PyGIArgOverrideReleaseFunc release_func
)
72 if (_pygi_import() < 0) {
75 PyGI_API
->register_foreign_struct(namespace_
,
83 #endif /* _INSIDE_PYGOBJECT_ */
85 #endif /* __PYGI_FOREIGN_API_H__ */