1 /* GObject introspection: Parsed IDL
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_IDL_NODE_H__
22 #define __G_IDL_NODE_H__
23 
24 #include <glib.h>
25 
26 G_BEGIN_DECLS
27 
28 typedef struct _GIdlNode GIdlNode;
29 typedef struct _GIdlNodeFunction GIdlNodeFunction;
30 typedef struct _GIdlNodeParam GIdlNodeParam;
31 typedef struct _GIdlNodeType GIdlNodeType;
32 typedef struct _GIdlNodeInterface GIdlNodeInterface;
33 typedef struct _GIdlNodeSignal GIdlNodeSignal;
34 typedef struct _GIdlNodeProperty GIdlNodeProperty;
35 typedef struct _GIdlNodeVFunc GIdlNodeVFunc;
36 typedef struct _GIdlNodeField GIdlNodeField;
37 typedef struct _GIdlNodeValue GIdlNodeValue;
38 typedef struct _GIdlNodeEnum GIdlNodeEnum;
39 typedef struct _GIdlNodeBoxed GIdlNodeBoxed;
40 typedef struct _GIdlNodeStruct GIdlNodeStruct;
41 typedef struct _GIdlNodeConstant GIdlNodeConstant;
42 typedef struct _GIdlNodeErrorDomain GIdlNodeErrorDomain;
43 typedef struct _GIdlNodeXRef GIdlNodeXRef;
44 typedef struct _GIdlNodeUnion GIdlNodeUnion;
45 
46 typedef enum
47 {
48   G_IDL_NODE_INVALID,
49   G_IDL_NODE_FUNCTION,
50   G_IDL_NODE_CALLBACK,
51   G_IDL_NODE_STRUCT,
52   G_IDL_NODE_BOXED,
53   G_IDL_NODE_ENUM,
54   G_IDL_NODE_FLAGS,
55   G_IDL_NODE_OBJECT,
56   G_IDL_NODE_INTERFACE,
57   G_IDL_NODE_CONSTANT,
58   G_IDL_NODE_ERROR_DOMAIN,
59   G_IDL_NODE_UNION,
60   G_IDL_NODE_PARAM,
61   G_IDL_NODE_TYPE,
62   G_IDL_NODE_PROPERTY,
63   G_IDL_NODE_SIGNAL,
64   G_IDL_NODE_VALUE,
65   G_IDL_NODE_VFUNC,
66   G_IDL_NODE_FIELD,
67   G_IDL_NODE_XREF
68 } GIdlNodeTypeId;
69 
70 struct _GIdlNode
71 {
72   GIdlNodeTypeId type;
73   gchar *name;
74 };
75 
76 struct _GIdlNodeXRef
77 {
78   GIdlNode node;
79 
80   gchar *namespace;
81 };
82 
83 struct _GIdlNodeFunction
84 {
85   GIdlNode 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   GIdlNodeParam *result;
98   GList *parameters;
99 };
100 
101 struct _GIdlNodeType
102 {
103   GIdlNode 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   GIdlNodeType *parameter_type1;
122   GIdlNodeType *parameter_type2;
123 
124   gchar *interface;
125   gchar **errors;
126 };
127 
128 struct _GIdlNodeParam
129 {
130   GIdlNode 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   GIdlNodeType *type;
142 };
143 
144 struct _GIdlNodeProperty
145 {
146   GIdlNode node;
147 
148   gboolean deprecated;
149 
150   gchar *name;
151   gboolean readable;
152   gboolean writable;
153   gboolean construct;
154   gboolean construct_only;
155 
156   GIdlNodeType *type;
157 };
158 
159 struct _GIdlNodeSignal
160 {
161   GIdlNode 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   GIdlNodeParam *result;
180 };
181 
182 struct _GIdlNodeVFunc
183 {
184   GIdlNode 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   GIdlNodeParam *result;
193 
194   gint offset;
195 };
196 
197 struct _GIdlNodeField
198 {
199   GIdlNode node;
200 
201   gboolean readable;
202   gboolean writable;
203   gint bits;
204   gint offset;
205 
206   GIdlNodeType *type;
207 };
208 
209 struct _GIdlNodeInterface
210 {
211   GIdlNode 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 _GIdlNodeValue
227 {
228   GIdlNode node;
229 
230   gboolean deprecated;
231 
232   guint32 value;
233 };
234 
235 struct _GIdlNodeConstant
236 {
237   GIdlNode node;
238 
239   gboolean deprecated;
240 
241   GIdlNodeType *type;
242 
243   gchar *value;
244 };
245 
246 struct _GIdlNodeEnum
247 {
248   GIdlNode node;
249 
250   gboolean deprecated;
251 
252   gchar *gtype_name;
253   gchar *gtype_init;
254 
255   GList *values;
256 };
257 
258 struct _GIdlNodeBoxed
259 {
260   GIdlNode node;
261 
262   gboolean deprecated;
263 
264   gchar *gtype_name;
265   gchar *gtype_init;
266 
267   GList *members;
268 };
269 
270 struct _GIdlNodeStruct
271 {
272   GIdlNode node;
273 
274   gboolean deprecated;
275 
276   GList *members;
277 };
278 
279 struct _GIdlNodeUnion
280 {
281   GIdlNode 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   GIdlNodeType *discriminator_type;
293 };
294 
295 
296 struct _GIdlNodeErrorDomain
297 {
298   GIdlNode node;
299 
300   gboolean deprecated;
301 
302   gchar *name;
303   gchar *getquark;
304   gchar *codes;
305 };
306 
307 
308 GIdlNode *g_idl_node_new             (GIdlNodeTypeId type);
309 void      g_idl_node_free            (GIdlNode    *node);
310 guint32   g_idl_node_get_size        (GIdlNode    *node);
311 guint32   g_idl_node_get_full_size   (GIdlNode    *node);
312 void      g_idl_node_build_metadata  (GIdlNode    *node,
313 				      GIdlModule  *module,
314 				      GList       *modules,
315                                       GHashTable  *strings,
316                                       GHashTable  *types,
317 				      guchar      *data,
318 				      guint32     *offset,
319                                       guint32     *offset2);
320 int       g_idl_node_cmp             (GIdlNode    *node,
321 				      GIdlNode    *other);
322 gboolean  g_idl_node_can_have_member (GIdlNode    *node);
323 void      g_idl_node_add_member      (GIdlNode         *node,
324 				      GIdlNodeFunction *member);
325 guint32   write_string               (const gchar *str,
326 				      GHashTable  *strings,
327 				      guchar      *data,
328 				      guint32     *offset);
329 
330 void      init_stats                 (void);
331 void      dump_stats                 (void);
332 
333 G_END_DECLS
334 
335 #endif  /* __G_IDL_NODE_H__ */
336