Bug 557241 – "throws" flag for functions
[gnome.gobject-introspection] / girepository / girnode.h
1 /* GObject introspection: Parsed GIR
2  *
3  * Copyright (C) 2005 Matthias Clasen
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __G_IR_NODE_H__
22 #define __G_IR_NODE_H__
23
24 #include <glib.h>
25
26 G_BEGIN_DECLS
27
28 typedef struct _GIrNode GIrNode; 
29 typedef struct _GIrNodeFunction GIrNodeFunction;
30 typedef struct _GIrNodeParam GIrNodeParam;
31 typedef struct _GIrNodeType GIrNodeType;
32 typedef struct _GIrNodeInterface GIrNodeInterface;
33 typedef struct _GIrNodeSignal GIrNodeSignal;
34 typedef struct _GIrNodeProperty GIrNodeProperty;
35 typedef struct _GIrNodeVFunc GIrNodeVFunc;
36 typedef struct _GIrNodeField GIrNodeField;
37 typedef struct _GIrNodeValue GIrNodeValue;
38 typedef struct _GIrNodeEnum GIrNodeEnum;
39 typedef struct _GIrNodeBoxed GIrNodeBoxed;
40 typedef struct _GIrNodeStruct GIrNodeStruct;
41 typedef struct _GIrNodeConstant GIrNodeConstant;
42 typedef struct _GIrNodeErrorDomain GIrNodeErrorDomain;
43 typedef struct _GIrNodeXRef GIrNodeXRef;
44 typedef struct _GIrNodeUnion GIrNodeUnion;
45
46 typedef enum 
47 {
48   G_IR_NODE_INVALID      =  0,
49   G_IR_NODE_FUNCTION     =  1,
50   G_IR_NODE_CALLBACK     =  2,
51   G_IR_NODE_STRUCT       =  3,
52   G_IR_NODE_BOXED        =  4,
53   G_IR_NODE_ENUM         =  5,
54   G_IR_NODE_FLAGS        =  6, 
55   G_IR_NODE_OBJECT       =  7,
56   G_IR_NODE_INTERFACE    =  8,
57   G_IR_NODE_CONSTANT     =  9,
58   G_IR_NODE_ERROR_DOMAIN = 10,
59   G_IR_NODE_UNION        = 11,
60   G_IR_NODE_PARAM        = 12,
61   G_IR_NODE_TYPE         = 13,
62   G_IR_NODE_PROPERTY     = 14,
63   G_IR_NODE_SIGNAL       = 15,
64   G_IR_NODE_VALUE        = 16,
65   G_IR_NODE_VFUNC        = 17,
66   G_IR_NODE_FIELD        = 18,
67   G_IR_NODE_XREF         = 19
68 } GIrNodeTypeId;
69
70 struct _GIrNode
71 {
72   GIrNodeTypeId type;
73   gchar *name;
74 };
75
76 struct _GIrNodeXRef
77 {
78   GIrNode node;
79
80   gchar *namespace;
81 };
82
83 struct _GIrNodeFunction
84 {
85   GIrNode node;
86
87   gboolean deprecated;
88   gboolean is_varargs; /* Not in typelib yet */ 
89
90   gboolean is_method;
91   gboolean is_setter;
92   gboolean is_getter;
93   gboolean is_constructor;
94   gboolean wraps_vfunc;
95   gboolean throws;
96
97   gchar *symbol;
98
99   GIrNodeParam *result;
100   GList *parameters;
101 };
102
103 struct _GIrNodeType 
104 {
105   GIrNode node;
106
107   gboolean is_pointer;
108   gboolean is_basic;
109   gboolean is_array;
110   gboolean is_glist;
111   gboolean is_gslist;
112   gboolean is_ghashtable;
113   gboolean is_interface;
114   gboolean is_error;
115   gint tag;
116
117   gchar *unparsed;
118
119   gboolean zero_terminated;
120   gboolean has_length;
121   gint length;
122   
123   GIrNodeType *parameter_type1;
124   GIrNodeType *parameter_type2;  
125
126   gchar *interface;
127   gchar **errors;
128 };
129
130 struct _GIrNodeParam 
131 {
132   GIrNode node;
133
134   gboolean in;
135   gboolean out;
136   gboolean dipper;
137   gboolean optional;
138   gboolean retval;
139   gboolean null_ok;
140   gboolean transfer;
141   gboolean shallow_transfer;
142   
143   GIrNodeType *type;
144 };
145
146 struct _GIrNodeProperty
147 {
148   GIrNode node;
149
150   gboolean deprecated;
151
152   gchar *name;
153   gboolean readable;
154   gboolean writable;
155   gboolean construct;
156   gboolean construct_only;
157   
158   GIrNodeType *type;
159 };
160
161 struct _GIrNodeSignal 
162 {
163   GIrNode node;
164
165   gboolean deprecated;
166
167   gboolean run_first;
168   gboolean run_last;
169   gboolean run_cleanup;
170   gboolean no_recurse;
171   gboolean detailed;
172   gboolean action;
173   gboolean no_hooks;
174   
175   gboolean has_class_closure;
176   gboolean true_stops_emit;
177   
178   gint class_closure;
179   
180   GList *parameters;
181   GIrNodeParam *result;    
182 };
183
184 struct _GIrNodeVFunc 
185 {
186   GIrNode node;
187
188   gboolean is_varargs; /* Not in typelib yet */ 
189   gboolean must_chain_up;
190   gboolean must_be_implemented;
191   gboolean must_not_be_implemented;
192   gboolean is_class_closure;
193   
194   GList *parameters;
195   GIrNodeParam *result;      
196
197   gint offset;
198 };
199
200 struct _GIrNodeField
201 {
202   GIrNode node;
203
204   gboolean readable;
205   gboolean writable;
206   gint bits;
207   gint offset;
208   
209   GIrNodeType *type;
210 };
211
212 struct _GIrNodeInterface
213 {
214   GIrNode node;
215
216   gboolean abstract;
217   gboolean deprecated;
218
219   gchar *gtype_name;
220   gchar *gtype_init;
221
222   gchar *parent;
223   
224   GList *interfaces;
225   GList *prerequisites;
226
227   GList *members;
228 };
229
230 struct _GIrNodeValue
231 {
232   GIrNode node;
233
234   gboolean deprecated;
235
236   guint32 value;
237 };
238
239 struct _GIrNodeConstant
240 {
241   GIrNode node;
242
243   gboolean deprecated;
244
245   GIrNodeType *type;
246   
247   gchar *value;
248 };
249
250 struct _GIrNodeEnum
251 {
252   GIrNode node;
253
254   gboolean deprecated;
255
256   gchar *gtype_name;
257   gchar *gtype_init;
258
259   GList *values;
260 };
261
262 struct _GIrNodeBoxed
263
264   GIrNode node;
265
266   gboolean deprecated;
267
268   gchar *gtype_name;
269   gchar *gtype_init;
270   
271   GList *members;
272 };
273
274 struct _GIrNodeStruct
275 {
276   GIrNode node;
277
278   gboolean deprecated;
279
280   gchar *gtype_name;
281   gchar *gtype_init;
282   
283   GList *members;
284 };
285
286 struct _GIrNodeUnion
287 {
288   GIrNode node;
289
290   gboolean deprecated;
291   
292   GList *members;
293   GList *discriminators;
294
295   gchar *gtype_name;
296   gchar *gtype_init;
297
298   gint discriminator_offset;
299   GIrNodeType *discriminator_type;
300 };
301
302
303 struct _GIrNodeErrorDomain
304 {
305   GIrNode node;
306
307   gboolean deprecated;
308   
309   gchar *name;
310   gchar *getquark;
311   gchar *codes;
312 };
313
314
315 GIrNode * g_ir_node_new             (GIrNodeTypeId type);
316 void      g_ir_node_free            (GIrNode    *node);
317 guint32   g_ir_node_get_size        (GIrNode    *node);
318 guint32   g_ir_node_get_full_size   (GIrNode    *node);
319 void      g_ir_node_build_typelib   (GIrNode    *node,
320                                      GIrModule  *module,
321                                      GList       *modules,
322                                      GHashTable  *strings,
323                                      GHashTable  *types,
324                                      guchar      *data,
325                                      guint32     *offset,
326                                      guint32     *offset2);
327 int       g_ir_node_cmp             (GIrNode    *node,
328                                      GIrNode    *other);
329 gboolean  g_ir_node_can_have_member (GIrNode    *node);
330 void      g_ir_node_add_member      (GIrNode         *node,
331                                      GIrNodeFunction *member);
332 guint32   write_string              (const gchar *str,
333                                      GHashTable  *strings, 
334                                      guchar      *data,
335                                      guint32     *offset);
336
337 const gchar * g_ir_node_param_direction_string (GIrNodeParam * node);
338 const gchar * g_ir_node_type_to_string         (GIrNodeTypeId type);
339
340 G_END_DECLS
341
342 #endif  /* __G_IR_NODE_H__ */