Branch and submit for IVI panda
[profile/ivi/gobject-introspection.git] / girepository / girffi.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  * GObject introspection: Helper functions for ffi integration
3  *
4  * Copyright (C) 2008 Red Hat, Inc
5  *
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 of the License, or (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GIRFFI_H__
23 #define __GIRFFI_H__
24
25 #include <ffi.h>
26 #include "girepository.h"
27
28 G_BEGIN_DECLS
29
30 typedef void (*GIFFIClosureCallback) (ffi_cif *,
31                                       void *,
32                                       void **,
33                                       void *);
34
35 /**
36  * GIFunctionInvoker:
37  * @cif: the cif
38  * @native_address: the native adress
39  */
40 typedef struct _GIFunctionInvoker GIFunctionInvoker;
41
42 struct _GIFunctionInvoker {
43   ffi_cif cif;
44   gpointer native_address;
45   /* <private> */
46   gpointer padding[3];
47 };
48
49 typedef GIArgument GIFFIReturnValue;
50
51 ffi_type *    gi_type_tag_get_ffi_type            (GITypeTag type_tag, gboolean is_pointer);
52
53 ffi_type *    g_type_info_get_ffi_type            (GITypeInfo           *info);
54
55 void          gi_type_info_extract_ffi_return_value (GITypeInfo                  *return_info,
56                                                      GIFFIReturnValue            *ffi_value,
57                                                      GIArgument                  *arg);
58
59 gboolean      g_function_info_prep_invoker        (GIFunctionInfo       *info,
60                                                    GIFunctionInvoker    *invoker,
61                                                    GError              **error);
62
63 gboolean      g_function_invoker_new_for_address  (gpointer              addr,
64                                                    GICallableInfo       *info,
65                                                    GIFunctionInvoker    *invoker,
66                                                    GError              **error);
67
68 void          g_function_invoker_destroy          (GIFunctionInvoker    *invoker);
69
70
71 ffi_closure * g_callable_info_prepare_closure     (GICallableInfo       *callable_info,
72                                                    ffi_cif              *cif,
73                                                    GIFFIClosureCallback  callback,
74                                                    gpointer              user_data);
75 void          g_callable_info_free_closure        (GICallableInfo       *callable_info,
76                                                    ffi_closure          *closure);
77
78 G_END_DECLS
79
80 #endif /* __GIRFFI_H__ */