tests: don't test for specific device labels
[pygobject.git] / gi / pygi-foreign-api.h
blob9367518724ec75a02118e2c613ad887ebd546ac7
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,
28 GITransfer transfer,
29 GIArgument *arg);
30 typedef PyObject * (*PyGIArgOverrideFromGIArgumentFunc) (GIInterfaceInfo *interface_info,
31 GITransfer transfer,
32 gpointer data);
33 typedef PyObject * (*PyGIArgOverrideReleaseFunc) (GITypeInfo *type_info,
34 gpointer struct_);
37 struct PyGI_API {
38 void (*register_foreign_struct) (const char* namespace_,
39 const char* name,
40 PyGIArgOverrideToGIArgumentFunc to_func,
41 PyGIArgOverrideFromGIArgumentFunc from_func,
42 PyGIArgOverrideReleaseFunc release_func);
46 #ifndef _INSIDE_PYGOBJECT_
48 static struct PyGI_API *PyGI_API = NULL;
50 static int
51 _pygi_import (void)
53 if (PyGI_API != NULL) {
54 return 1;
56 PyGI_API = (struct PyGI_API*) PyCapsule_Import("gi._API", FALSE);
57 if (PyGI_API == NULL) {
58 return -1;
61 return 0;
65 static inline PyObject *
66 pygi_register_foreign_struct (const char* namespace_,
67 const char* name,
68 PyGIArgOverrideToGIArgumentFunc to_func,
69 PyGIArgOverrideFromGIArgumentFunc from_func,
70 PyGIArgOverrideReleaseFunc release_func)
72 if (_pygi_import() < 0) {
73 return NULL;
75 PyGI_API->register_foreign_struct(namespace_,
76 name,
77 to_func,
78 from_func,
79 release_func);
80 Py_RETURN_NONE;
83 #endif /* _INSIDE_PYGOBJECT_ */
85 #endif /* __PYGI_FOREIGN_API_H__ */