c0e842195b85230a6936674183653442f290d555
[platform/upstream/pygobject2.git] / gi / pygi-closure.h
1 /* -*- Mode: C; c-basic-offset: 4 -*-
2  * vim: tabstop=4 shiftwidth=4 expandtab
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef __PYGI_CLOSURE_H__
19 #define __PYGI_CLOSURE_H__
20
21 #include <Python.h>
22 #include <girffi.h>
23 #include <ffi.h>
24
25 #include "pygi-cache.h"
26
27 G_BEGIN_DECLS
28
29
30 /* Private */
31
32 typedef struct _PyGICClosure
33 {
34     GICallableInfo *info;
35     PyObject *function;
36
37     ffi_closure *closure;
38     ffi_cif cif;
39
40     GIScopeType scope;
41
42     PyObject* user_data;
43
44     PyGIClosureCache *cache;
45 } PyGICClosure;
46
47 void _pygi_closure_handle (ffi_cif *cif, void *result, void
48                            **args, void *userdata);
49
50 void _pygi_invoke_closure_free (gpointer user_data);
51
52 PyGICClosure* _pygi_make_native_closure (GICallableInfo* info,
53                                          GIScopeType scope,
54                                          PyObject *function,
55                                          gpointer user_data);
56
57 PyGIArgCache *pygi_arg_callback_new_from_info  (GITypeInfo        *type_info,
58                                                 GIArgInfo         *arg_info,   /* may be null */
59                                                 GITransfer         transfer,
60                                                 PyGIDirection      direction,
61                                                 GIInterfaceInfo   *iface_info,
62                                                 PyGICallableCache *callable_cache);
63
64 G_END_DECLS
65
66 #endif /* __PYGI_CLOSURE_H__ */