pygi-cache.h 4.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* -*- Mode: C; c-basic-offset: 4 -*-
 * vim: tabstop=4 shiftwidth=4 expandtab
 *
 * Copyright (C) 2011 John (J5) Palmieri <johnp@redhat.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
 * USA
 */

22
#ifdef ENABLE_INVOKE_NG
23
24
25
26
27
28
#ifndef __PYGI_CACHE_H__
#define __PYGI_CACHE_H__

#include <Python.h>
#include <girepository.h>

29
30
#include "pygi-invoke-state-struct.h"

31
32
G_BEGIN_DECLS

33
typedef struct _PyGICallableCache PyGICallableCache;
34
35
typedef struct _PyGIArgCache PyGIArgCache;

36
typedef gboolean (*PyGIMarshalInFunc) (PyGIInvokeState   *state,
37
                                       PyGICallableCache *callable_cache,
38
39
40
41
                                       PyGIArgCache      *arg_cache,
                                       PyObject          *py_arg,
                                       GIArgument        *arg);

42
typedef PyObject *(*PyGIMarshalOutFunc) (PyGIInvokeState   *state,
43
                                         PyGICallableCache *callable_cache,
44
45
                                         PyGIArgCache      *arg_cache,
                                         GIArgument        *arg);
46

47
48
49
typedef void (*PyGIMarshalCleanupFunc) (PyGIInvokeState *state,
                                        PyGIArgCache    *arg_cache,
                                        gpointer         *data);
John (J5) Palmieri's avatar
John (J5) Palmieri committed
50
51
52
53
54
55
56
57
58
typedef enum {
  /* Not an AUX type */
  PYGI_AUX_TYPE_NONE   = 0,
  /* AUX type handled by parent */
  PYGI_AUX_TYPE_IGNORE = 1,
  /* AUX type has an associated pyarg which is modified by parent */
  PYGI_AUX_TYPE_HAS_PYARG = 2
} PyGIAuxType;

59
60
struct _PyGIArgCache
{
John (J5) Palmieri's avatar
John (J5) Palmieri committed
61
    PyGIAuxType aux_type;
62
    gboolean is_pointer;
63
    gboolean is_caller_allocates;
64
    gboolean allow_none;
65

66
67
68
    GIDirection direction;
    GITransfer transfer;
    GITypeTag type_tag;
69
    GITypeInfo *type_info;
70
71
72
73
74
    GIArgument *default_value;

    PyGIMarshalInFunc in_marshaller;
    PyGIMarshalOutFunc out_marshaller;

75
    PyGIMarshalCleanupFunc cleanup;
76
77
    GDestroyNotify destroy_notify;

78
79
    gssize c_arg_index;
    gssize py_arg_index;
80
};
81

82
83
typedef struct _PyGISequenceCache
{
84
    PyGIArgCache arg_cache;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
85
    gssize fixed_size;
86
    gint len_arg_index;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
87
    gboolean is_zero_terminated;
88
    gsize item_size;
89
    GIArrayType array_type;
90
    PyGIArgCache *item_cache;
91
} PyGISequenceCache;
92
93
94

typedef struct _PyGIInterfaceCache
{
95
    PyGIArgCache arg_cache;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
96
97
98
    gboolean is_foreign;
    GType g_type;
    PyObject *py_type;
99
    GIInterfaceInfo *interface_info;
100
    gchar *type_name;
101
102
103
104
} PyGIInterfaceCache;

typedef struct _PyGIHashCache
{
105
    PyGIArgCache arg_cache;
106
107
    PyGIArgCache *key_cache;
    PyGIArgCache *value_cache;
108
109
} PyGIHashCache;

John (J5) Palmieri's avatar
John (J5) Palmieri committed
110
typedef struct _PyGICallbackCache
111
{
112
    PyGIArgCache arg_cache;
113
    gint user_data_index;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
114
    gint destroy_notify_index;
115
    GIScopeType scope;
116
    GIInterfaceInfo *interface_info;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
117
} PyGICallbackCache;
118

119
struct _PyGICallableCache
120
{
121
122
    const gchar *name;

123
124
    gboolean is_method;
    gboolean is_constructor;
125
126
    gboolean is_vfunc;
    gboolean is_callback;
127

128
    PyGIArgCache *return_cache;
John (J5) Palmieri's avatar
John (J5) Palmieri committed
129
    PyGIArgCache **args_cache;
130
    GSList *out_args;
131
132

    /* counts */
133
134
    gssize n_in_args;
    gssize n_out_args;
135
136
    gssize n_out_aux_args;

137
138
    gssize n_args;
    gssize n_py_args;
139
};
140
141

void _pygi_arg_cache_clear	(PyGIArgCache *cache);
142
void _pygi_callable_cache_free	(PyGICallableCache *cache);
143

144
PyGICallableCache *_pygi_callable_cache_new (GICallableInfo *callable_info);
145
146

G_END_DECLS
147

148
#endif /* __PYGI_CACHE_H__ */
149
#endif /* def ENABLE_INVOKE_NG */