Initial packaging for Tizen
[profile/ivi/gobject-introspection.git] / girepository / girnode.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  * GObject introspection: Parsed GIR
3  *
4  * Copyright (C) 2005 Matthias Clasen
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 __G_IR_NODE_H__
23 #define __G_IR_NODE_H__
24
25 #include <glib.h>
26
27 #include "girmodule.h"
28
29 G_BEGIN_DECLS
30
31 typedef struct _GIrNode GIrNode;
32 typedef struct _GIrNodeFunction GIrNodeFunction;
33 typedef struct _GIrNodeParam GIrNodeParam;
34 typedef struct _GIrNodeType GIrNodeType;
35 typedef struct _GIrNodeInterface GIrNodeInterface;
36 typedef struct _GIrNodeSignal GIrNodeSignal;
37 typedef struct _GIrNodeProperty GIrNodeProperty;
38 typedef struct _GIrNodeVFunc GIrNodeVFunc;
39 typedef struct _GIrNodeField GIrNodeField;
40 typedef struct _GIrNodeValue GIrNodeValue;
41 typedef struct _GIrNodeEnum GIrNodeEnum;
42 typedef struct _GIrNodeBoxed GIrNodeBoxed;
43 typedef struct _GIrNodeStruct GIrNodeStruct;
44 typedef struct _GIrNodeConstant GIrNodeConstant;
45 typedef struct _GIrNodeXRef GIrNodeXRef;
46 typedef struct _GIrNodeUnion GIrNodeUnion;
47
48 typedef enum
49 {
50   G_IR_NODE_INVALID      =  0,
51   G_IR_NODE_FUNCTION     =  1,
52   G_IR_NODE_CALLBACK     =  2,
53   G_IR_NODE_STRUCT       =  3,
54   G_IR_NODE_BOXED        =  4,
55   G_IR_NODE_ENUM         =  5,
56   G_IR_NODE_FLAGS        =  6,
57   G_IR_NODE_OBJECT       =  7,
58   G_IR_NODE_INTERFACE    =  8,
59   G_IR_NODE_CONSTANT     =  9,
60   G_IR_NODE_INVALID_0    = 10, /* DELETED - used to be ERROR_DOMAIN */
61   G_IR_NODE_UNION        = 11,
62   G_IR_NODE_PARAM        = 12,
63   G_IR_NODE_TYPE         = 13,
64   G_IR_NODE_PROPERTY     = 14,
65   G_IR_NODE_SIGNAL       = 15,
66   G_IR_NODE_VALUE        = 16,
67   G_IR_NODE_VFUNC        = 17,
68   G_IR_NODE_FIELD        = 18,
69   G_IR_NODE_XREF         = 19
70 } GIrNodeTypeId;
71
72 struct _GIrNode
73 {
74   GIrNodeTypeId type;
75   gchar *name;
76   GIrModule *module;
77
78   guint32 offset; /* Assigned as we build the typelib */
79
80   GHashTable *attributes;
81 };
82
83 struct _GIrNodeXRef
84 {
85   GIrNode node;
86
87   gchar *namespace;
88 };
89
90 struct _GIrNodeFunction
91 {
92   GIrNode node;
93
94   gboolean deprecated;
95   gboolean is_varargs; /* Not in typelib yet */
96
97   gboolean is_method;
98   gboolean is_setter;
99   gboolean is_getter;
100   gboolean is_constructor;
101   gboolean wraps_vfunc;
102   gboolean throws;
103
104   gchar *symbol;
105
106   GIrNodeParam *result;
107   GList *parameters;
108 };
109
110 struct _GIrNodeType
111 {
112   GIrNode node;
113
114   gboolean is_pointer;
115   gboolean is_basic;
116   gboolean is_array;
117   gboolean is_glist;
118   gboolean is_gslist;
119   gboolean is_ghashtable;
120   gboolean is_interface;
121   gboolean is_error;
122   gint tag;
123
124   gchar *unparsed;
125
126   gboolean zero_terminated;
127   gboolean has_length;
128   gint length;
129   gboolean has_size;
130   gint size;
131   gint array_type;
132
133   GIrNodeType *parameter_type1;
134   GIrNodeType *parameter_type2;
135
136   gchar *interface;
137   gchar **errors;
138 };
139
140 struct _GIrNodeParam
141 {
142   GIrNode node;
143
144   gboolean in;
145   gboolean out;
146   gboolean caller_allocates;
147   gboolean optional;
148   gboolean retval;
149   gboolean allow_none;
150   gboolean skip;
151   gboolean transfer;
152   gboolean shallow_transfer;
153   GIScopeType scope;
154
155   gint8 closure;
156   gint8 destroy;
157
158   GIrNodeType *type;
159 };
160
161 struct _GIrNodeProperty
162 {
163   GIrNode node;
164
165   gboolean deprecated;
166
167   gchar *name;
168   gboolean readable;
169   gboolean writable;
170   gboolean construct;
171   gboolean construct_only;
172   gboolean transfer;
173   gboolean shallow_transfer;
174
175   GIrNodeType *type;
176 };
177
178 struct _GIrNodeSignal
179 {
180   GIrNode node;
181
182   gboolean deprecated;
183
184   gboolean run_first;
185   gboolean run_last;
186   gboolean run_cleanup;
187   gboolean no_recurse;
188   gboolean detailed;
189   gboolean action;
190   gboolean no_hooks;
191
192   gboolean has_class_closure;
193   gboolean true_stops_emit;
194
195   gint class_closure;
196
197   GList *parameters;
198   GIrNodeParam *result;
199 };
200
201 struct _GIrNodeVFunc
202 {
203   GIrNode node;
204
205   gboolean is_varargs; /* Not in typelib yet */
206   gboolean must_chain_up;
207   gboolean must_be_implemented;
208   gboolean must_not_be_implemented;
209   gboolean is_class_closure;
210   gboolean throws;
211
212   char *invoker;
213
214   GList *parameters;
215   GIrNodeParam *result;
216
217   gint offset;
218 };
219
220 struct _GIrNodeField
221 {
222   GIrNode node;
223
224   gboolean readable;
225   gboolean writable;
226   gint bits;
227   gint offset;
228   GIrNodeFunction *callback;
229
230   GIrNodeType *type;
231 };
232
233 struct _GIrNodeInterface
234 {
235   GIrNode node;
236
237   gboolean abstract;
238   gboolean deprecated;
239   gboolean fundamental;
240
241   gchar *gtype_name;
242   gchar *gtype_init;
243
244   gchar *ref_func;
245   gchar *unref_func;
246   gchar *set_value_func;
247   gchar *get_value_func;
248
249   gchar *parent;
250   gchar *glib_type_struct;
251
252   GList *interfaces;
253   GList *prerequisites;
254
255   gint alignment;
256   gint size;
257
258   GList *members;
259 };
260
261 struct _GIrNodeValue
262 {
263   GIrNode node;
264
265   gboolean deprecated;
266
267   gint64 value;
268 };
269
270 struct _GIrNodeConstant
271 {
272   GIrNode node;
273
274   gboolean deprecated;
275
276   GIrNodeType *type;
277
278   gchar *value;
279 };
280
281 struct _GIrNodeEnum
282 {
283   GIrNode node;
284
285   gboolean deprecated;
286   gint storage_type;
287
288   gchar *gtype_name;
289   gchar *gtype_init;
290   gchar *error_domain;
291
292   GList *values;
293   GList *methods;
294 };
295
296 struct _GIrNodeBoxed
297 {
298   GIrNode node;
299
300   gboolean deprecated;
301
302   gchar *gtype_name;
303   gchar *gtype_init;
304
305   gint alignment;
306   gint size;
307
308   GList *members;
309 };
310
311 struct _GIrNodeStruct
312 {
313   GIrNode node;
314
315   gboolean deprecated;
316   gboolean disguised;
317   gboolean is_gtype_struct;
318   gboolean foreign;
319
320   gchar *gtype_name;
321   gchar *gtype_init;
322
323   gint alignment;
324   gint size;
325
326   GList *members;
327 };
328
329 struct _GIrNodeUnion
330 {
331   GIrNode node;
332
333   gboolean deprecated;
334
335   GList *members;
336   GList *discriminators;
337
338   gchar *gtype_name;
339   gchar *gtype_init;
340
341   gint alignment;
342   gint size;
343
344   gint discriminator_offset;
345   GIrNodeType *discriminator_type;
346 };
347
348
349 GIrNode * _g_ir_node_new             (GIrNodeTypeId type,
350                                      GIrModule     *module);
351 void      _g_ir_node_free            (GIrNode    *node);
352 guint32   _g_ir_node_get_size        (GIrNode    *node);
353 guint32   _g_ir_node_get_full_size   (GIrNode    *node);
354 void      _g_ir_node_build_typelib   (GIrNode         *node,
355                                       GIrNode         *parent,
356                                       GIrTypelibBuild *build,
357                                       guint32         *offset,
358                                       guint32         *offset2);
359 int       _g_ir_node_cmp             (GIrNode    *node,
360                                      GIrNode    *other);
361 gboolean  _g_ir_node_can_have_member (GIrNode    *node);
362 void      _g_ir_node_add_member      (GIrNode         *node,
363                                       GIrNodeFunction *member);
364 guint32   _g_ir_write_string              (const gchar *str,
365                                            GHashTable  *strings,
366                                            guchar      *data,
367                                            guint32     *offset);
368
369 const gchar * _g_ir_node_param_direction_string (GIrNodeParam * node);
370 const gchar * _g_ir_node_type_to_string         (GIrNodeTypeId type);
371
372 GIrNode *_g_ir_find_node (GIrTypelibBuild  *build,
373                          GIrModule        *module,
374                          const char       *name);
375
376 /* In giroffsets.c */
377
378 void _g_ir_node_compute_offsets (GIrTypelibBuild *build,
379                                 GIrNode         *node);
380
381
382 G_END_DECLS
383
384 #endif  /* __G_IR_NODE_H__ */