Make enum serializing functions public. Clean up some whitespace.
[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
89   gboolean is_method;
90   gboolean is_setter;
91   gboolean is_getter;
92   gboolean is_constructor;
93   gboolean wraps_vfunc;
94
95   gchar *symbol;
96
97   GIrNodeParam *result;
98   GList *parameters;
99 };
100
101 struct _GIrNodeType 
102 {
103   GIrNode node;
104
105   gboolean is_pointer;
106   gboolean is_basic;
107   gboolean is_array;
108   gboolean is_glist;
109   gboolean is_gslist;
110   gboolean is_ghashtable;
111   gboolean is_interface;
112   gboolean is_error;
113   gint tag;
114
115   gchar *unparsed;
116
117   gboolean zero_terminated;
118   gboolean has_length;
119   gint length;
120   
121   GIrNodeType *parameter_type1;
122   GIrNodeType *parameter_type2;  
123
124   gchar *interface;
125   gchar **errors;
126 };
127
128 struct _GIrNodeParam 
129 {
130   GIrNode node;
131
132   gboolean in;
133   gboolean out;
134   gboolean dipper;
135   gboolean optional;
136   gboolean retval;
137   gboolean null_ok;
138   gboolean transfer;
139   gboolean shallow_transfer;
140   
141   GIrNodeType *type;
142 };
143
144 struct _GIrNodeProperty
145 {
146   GIrNode node;
147
148   gboolean deprecated;
149
150   gchar *name;
151   gboolean readable;
152   gboolean writable;
153   gboolean construct;
154   gboolean construct_only;
155   
156   GIrNodeType *type;
157 };
158
159 struct _GIrNodeSignal 
160 {
161   GIrNode node;
162
163   gboolean deprecated;
164
165   gboolean run_first;
166   gboolean run_last;
167   gboolean run_cleanup;
168   gboolean no_recurse;
169   gboolean detailed;
170   gboolean action;
171   gboolean no_hooks;
172   
173   gboolean has_class_closure;
174   gboolean true_stops_emit;
175   
176   gint class_closure;
177   
178   GList *parameters;
179   GIrNodeParam *result;    
180 };
181
182 struct _GIrNodeVFunc 
183 {
184   GIrNode node;
185
186   gboolean must_chain_up;
187   gboolean must_be_implemented;
188   gboolean must_not_be_implemented;
189   gboolean is_class_closure;
190   
191   GList *parameters;
192   GIrNodeParam *result;      
193
194   gint offset;
195 };
196
197 struct _GIrNodeField
198 {
199   GIrNode node;
200
201   gboolean readable;
202   gboolean writable;
203   gint bits;
204   gint offset;
205   
206   GIrNodeType *type;
207 };
208
209 struct _GIrNodeInterface
210 {
211   GIrNode node;
212
213   gboolean deprecated;
214
215   gchar *gtype_name;
216   gchar *gtype_init;
217
218   gchar *parent;
219   
220   GList *interfaces;
221   GList *prerequisites;
222
223   GList *members;
224 };
225
226 struct _GIrNodeValue
227 {
228   GIrNode node;
229
230   gboolean deprecated;
231
232   guint32 value;
233 };
234
235 struct _GIrNodeConstant
236 {
237   GIrNode node;
238
239   gboolean deprecated;
240
241   GIrNodeType *type;
242   
243   gchar *value;
244 };
245
246 struct _GIrNodeEnum
247 {
248   GIrNode node;
249
250   gboolean deprecated;
251
252   gchar *gtype_name;
253   gchar *gtype_init;
254
255   GList *values;
256 };
257
258 struct _GIrNodeBoxed
259
260   GIrNode node;
261
262   gboolean deprecated;
263
264   gchar *gtype_name;
265   gchar *gtype_init;
266   
267   GList *members;
268 };
269
270 struct _GIrNodeStruct
271 {
272   GIrNode node;
273
274   gboolean deprecated;
275   
276   GList *members;
277 };
278
279 struct _GIrNodeUnion
280 {
281   GIrNode node;
282
283   gboolean deprecated;
284   
285   GList *members;
286   GList *discriminators;
287
288   gchar *gtype_name;
289   gchar *gtype_init;
290
291   gint discriminator_offset;
292   GIrNodeType *discriminator_type;
293 };
294
295
296 struct _GIrNodeErrorDomain
297 {
298   GIrNode node;
299
300   gboolean deprecated;
301   
302   gchar *name;
303   gchar *getquark;
304   gchar *codes;
305 };
306
307
308 GIrNode * g_ir_node_new             (GIrNodeTypeId type);
309 void      g_ir_node_free            (GIrNode    *node);
310 guint32   g_ir_node_get_size        (GIrNode    *node);
311 guint32   g_ir_node_get_full_size   (GIrNode    *node);
312 void      g_ir_node_build_typelib   (GIrNode    *node,
313                                      GIrModule  *module,
314                                      GList       *modules,
315                                      GHashTable  *strings,
316                                      GHashTable  *types,
317                                      guchar      *data,
318                                      guint32     *offset,
319                                      guint32     *offset2);
320 int       g_ir_node_cmp             (GIrNode    *node,
321                                      GIrNode    *other);
322 gboolean  g_ir_node_can_have_member (GIrNode    *node);
323 void      g_ir_node_add_member      (GIrNode         *node,
324                                      GIrNodeFunction *member);
325 guint32   write_string              (const gchar *str,
326                                      GHashTable  *strings, 
327                                      guchar      *data,
328                                      guint32     *offset);
329
330 const gchar * g_ir_node_param_direction_string (GIrNodeParam * node);
331 const gchar * g_ir_node_type_to_string         (GIrNodeTypeId type);
332
333 G_END_DECLS
334
335 #endif  /* __G_IR_NODE_H__ */