Release 0.41.92
[vala-gnome.git] / gobject-introspection / gmetadata.h
bloba22ee235e82cb2f5b70a22534093fea1681198e9
1 /* GObject introspection: struct definitions for the binary
2 * metadata format, validation
4 * Copyright (C) 2005 Matthias Clasen
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.
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.
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.
22 #ifndef __G_METADATA_H__
23 #define __G_METADATA_H__
25 #include <gmodule.h>
26 #include "girepository.h"
28 G_BEGIN_DECLS
30 #define G_IDL_MAGIC "GOBJ\nMETADATA\r\n\032"
32 enum
34 BLOB_TYPE_INVALID,
35 BLOB_TYPE_FUNCTION,
36 BLOB_TYPE_CALLBACK,
37 BLOB_TYPE_STRUCT,
38 BLOB_TYPE_BOXED,
39 BLOB_TYPE_ENUM,
40 BLOB_TYPE_FLAGS,
41 BLOB_TYPE_OBJECT,
42 BLOB_TYPE_INTERFACE,
43 BLOB_TYPE_CONSTANT,
44 BLOB_TYPE_ERROR_DOMAIN,
45 BLOB_TYPE_UNION
48 typedef struct
50 gchar magic[16];
51 guint8 major_version;
52 guint8 minor_version;
53 guint16 reserved;
54 guint16 n_entries;
55 guint16 n_local_entries;
56 guint32 directory;
57 guint32 n_annotations;
58 guint32 annotations;
60 guint32 size;
61 guint32 namespace;
62 guint32 shared_library;
64 guint16 entry_blob_size;
65 guint16 function_blob_size;
66 guint16 callback_blob_size;
67 guint16 signal_blob_size;
68 guint16 vfunc_blob_size;
69 guint16 arg_blob_size;
70 guint16 property_blob_size;
71 guint16 field_blob_size;
72 guint16 value_blob_size;
73 guint16 annotation_blob_size;
74 guint16 constant_blob_size;
75 guint16 error_domain_blob_size;
77 guint16 signature_blob_size;
78 guint16 enum_blob_size;
79 guint16 struct_blob_size;
80 guint16 object_blob_size;
81 guint16 interface_blob_size;
82 guint16 union_blob_size;
84 guint16 padding[7];
85 } Header;
87 typedef struct
89 guint16 blob_type;
91 guint local : 1;
92 guint reserved :15;
94 guint32 name;
95 guint32 offset;
96 } DirEntry;
99 #define TYPE_POINTER_MASK 1 << 7
100 #define TYPE_TAG_MASK 63
102 typedef enum
104 TYPE_TAG_VOID = 0,
105 TYPE_TAG_BOOLEAN = 1,
106 TYPE_TAG_INT8 = 2,
107 TYPE_TAG_UINT8 = 3,
108 TYPE_TAG_INT16 = 4,
109 TYPE_TAG_UINT16 = 5,
110 TYPE_TAG_INT32 = 6,
111 TYPE_TAG_UINT32 = 7,
112 TYPE_TAG_INT64 = 8,
113 TYPE_TAG_UINT64 = 9,
114 TYPE_TAG_INT = 10,
115 TYPE_TAG_UINT = 11,
116 TYPE_TAG_LONG = 12,
117 TYPE_TAG_ULONG = 13,
118 TYPE_TAG_SSIZE = 14,
119 TYPE_TAG_SIZE = 15,
120 TYPE_TAG_FLOAT = 16,
121 TYPE_TAG_DOUBLE = 17,
122 TYPE_TAG_UTF8 = 18,
123 TYPE_TAG_FILENAME = 19,
124 TYPE_TAG_ARRAY = 20,
125 TYPE_TAG_INTERFACE = 21,
126 TYPE_TAG_LIST = 22,
127 TYPE_TAG_SLIST = 23,
128 TYPE_TAG_HASH = 24,
129 TYPE_TAG_ERROR = 25
130 } TypeTag;
132 typedef union
134 struct
136 guint reserved : 8;
137 guint reserved2 :16;
138 guint pointer : 1;
139 guint reserved3 : 2;
140 guint tag : 5;
142 guint32 offset;
143 } SimpleTypeBlob;
146 typedef struct
148 guint32 name;
150 guint in : 1;
151 guint out : 1;
152 guint dipper : 1;
153 guint null_ok : 1;
154 guint optional : 1;
155 guint transfer_ownership : 1;
156 guint transfer_container_ownership : 1;
157 guint return_value : 1;
158 guint reserved :24;
160 SimpleTypeBlob arg_type;
161 } ArgBlob;
163 typedef struct
165 SimpleTypeBlob return_type;
167 guint may_return_null : 1;
168 guint caller_owns_return_value : 1;
169 guint caller_owns_return_container : 1;
170 guint reserved :13;
172 guint16 n_arguments;
174 ArgBlob arguments[];
175 } SignatureBlob;
177 typedef struct
179 guint16 blob_type; /* 1 */
181 guint deprecated : 1;
182 guint reserved :15;
184 guint32 name;
185 } CommonBlob;
187 typedef struct
189 guint16 blob_type; /* 1 */
191 guint deprecated : 1;
192 guint setter : 1;
193 guint getter : 1;
194 guint constructor : 1;
195 guint wraps_vfunc : 1;
196 guint reserved : 1;
197 guint index :10;
199 guint32 name;
200 guint32 symbol;
201 guint32 signature;
202 } FunctionBlob;
204 typedef struct
206 guint16 blob_type; /* 2 */
208 guint deprecated : 1;
209 guint reserved :15;
211 guint32 name;
212 guint32 signature;
213 } CallbackBlob;
215 typedef struct
217 guint pointer :1;
218 guint reserved :2;
219 guint tag :5;
220 guint8 reserved2;
221 guint16 interface;
222 } InterfaceTypeBlob;
224 typedef struct
226 guint pointer :1;
227 guint reserved :2;
228 guint tag :5;
230 guint zero_terminated :1;
231 guint has_length :1;
232 guint reserved2 :6;
234 guint16 length;
236 SimpleTypeBlob type;
237 } ArrayTypeBlob;
239 typedef struct
241 guint pointer :1;
242 guint reserved :2;
243 guint tag :5;
245 guint8 reserved2;
246 guint16 n_types;
248 SimpleTypeBlob type[];
249 } ParamTypeBlob;
251 typedef struct
253 guint pointer :1;
254 guint reserved :2;
255 guint tag :5;
257 guint8 reserved2;
258 guint16 n_domains;
260 guint16 domains[];
261 } ErrorTypeBlob;
263 typedef struct
265 guint16 blob_type; /* 10 */
267 guint deprecated : 1;
268 guint reserved :15;
270 guint32 name;
272 guint32 get_quark;
273 guint16 error_codes;
274 guint16 reserved2;
275 } ErrorDomainBlob;
277 typedef struct
279 guint deprecated : 1;
280 guint reserved :31;
281 guint32 name;
282 guint32 value;
283 } ValueBlob;
285 typedef struct
287 guint32 name;
289 guint readable : 1;
290 guint writable : 1;
291 guint reserved : 6;
292 guint8 bits;
294 guint16 struct_offset;
296 SimpleTypeBlob type;
297 } FieldBlob;
299 typedef struct
301 guint16 blob_type;
302 guint deprecated : 1;
303 guint unregistered :15;
304 guint32 name;
306 guint32 gtype_name;
307 guint32 gtype_init;
308 } RegisteredTypeBlob;
310 typedef struct
312 guint16 blob_type;
314 guint deprecated : 1;
315 guint unregistered : 1;
316 guint reserved :14;
318 guint32 name;
320 guint32 gtype_name;
321 guint32 gtype_init;
323 guint16 n_fields;
324 guint16 n_methods;
326 #if 0
327 /* variable-length parts of the blob */
328 FieldBlob fields[];
329 FunctionBlob methods[];
330 #endif
331 } StructBlob;
333 typedef struct
335 guint16 blob_type;
336 guint deprecated : 1;
337 guint unregistered : 1;
338 guint discriminated : 1;
339 guint reserved :13;
340 guint32 name;
342 guint32 gtype_name;
343 guint32 gtype_init;
345 guint16 n_fields;
346 guint16 n_functions;
348 gint32 discriminator_offset;
349 SimpleTypeBlob discriminator_type;
351 #if 0
352 FieldBlob fields[];
353 FunctionBlob functions[];
354 ConstantBlob discriminator_values[]
355 #endif
356 } UnionBlob;
358 typedef struct
360 guint16 blob_type;
362 guint deprecated : 1;
363 guint unregistered : 1;
364 guint reserved :14;
366 guint32 name;
368 guint32 gtype_name;
369 guint32 gtype_init;
371 guint16 n_values;
372 guint16 reserved2;
374 ValueBlob values[];
375 } EnumBlob;
377 typedef struct
379 guint32 name;
381 guint deprecated : 1;
382 guint readable : 1;
383 guint writable : 1;
384 guint construct : 1;
385 guint construct_only : 1;
386 guint reserved :27;
388 SimpleTypeBlob type;
390 } PropertyBlob;
392 typedef struct
394 guint deprecated : 1;
395 guint run_first : 1;
396 guint run_last : 1;
397 guint run_cleanup : 1;
398 guint no_recurse : 1;
399 guint detailed : 1;
400 guint action : 1;
401 guint no_hooks : 1;
402 guint has_class_closure : 1;
403 guint true_stops_emit : 1;
404 guint reserved : 6;
406 guint16 class_closure;
408 guint32 name;
410 guint32 signature;
411 } SignalBlob;
413 typedef struct
415 guint32 name;
417 guint must_chain_up : 1;
418 guint must_be_implemented : 1;
419 guint must_not_be_implemented : 1;
420 guint class_closure : 1;
421 guint reserved :12;
422 guint16 signal;
424 guint16 struct_offset;
425 guint16 reserved2;
426 guint32 signature;
427 } VFuncBlob;
429 typedef struct
431 guint16 blob_type; /* 7 */
432 guint deprecated : 1;
433 guint reserved :15;
434 guint32 name;
436 guint32 gtype_name;
437 guint32 gtype_init;
439 guint16 parent;
441 guint16 n_interfaces;
442 guint16 n_fields;
443 guint16 n_properties;
444 guint16 n_methods;
445 guint16 n_signals;
446 guint16 n_vfuncs;
447 guint16 n_constants;
449 guint16 interfaces[];
451 #if 0
452 /* variable-length parts of the blob */
453 FieldBlob fields[];
454 PropertyBlob properties[];
455 FunctionBlob methods[];
456 SignalBlob signals[];
457 VFuncBlob vfuncs[];
458 ConstantBlob constants[];
459 #endif
460 } ObjectBlob;
462 typedef struct
464 guint16 blob_type;
465 guint deprecated : 1;
466 guint reserved :15;
467 guint32 name;
469 guint32 gtype_name;
470 guint32 gtype_init;
472 guint16 n_prerequisites;
473 guint16 n_properties;
474 guint16 n_methods;
475 guint16 n_signals;
476 guint16 n_vfuncs;
477 guint16 n_constants;
479 guint16 prerequisites[];
481 #if 0
482 /* variable-length parts of the blob */
483 PropertyBlob properties[];
484 FunctionBlob methods[];
485 SignalBlob signals[];
486 VFuncBlob vfuncs[];
487 ConstantBlob constants[];
488 #endif
489 } InterfaceBlob;
492 typedef struct
494 guint16 blob_type;
495 guint deprecated : 1;
496 guint reserved :15;
497 guint32 name;
499 SimpleTypeBlob type;
501 guint32 size;
502 guint32 offset;
503 } ConstantBlob;
505 typedef struct
507 guint32 offset;
508 guint32 name;
509 guint32 value;
510 } AnnotationBlob;
513 struct _GMetadata {
514 guchar *data;
515 gsize len;
516 gboolean owns_memory;
517 GMappedFile *mfile;
518 GModule *module;
521 DirEntry *g_metadata_get_dir_entry (GMetadata *metadata,
522 guint16 index);
524 void g_metadata_check_sanity (void);
526 #define g_metadata_get_string(metadata,offset) ((const gchar*)&(metadata->data)[(offset)])
529 typedef enum
531 G_METADATA_ERROR_INVALID,
532 G_METADATA_ERROR_INVALID_HEADER,
533 G_METADATA_ERROR_INVALID_DIRECTORY,
534 G_METADATA_ERROR_INVALID_ENTRY,
535 G_METADATA_ERROR_INVALID_BLOB
536 } GMetadataError;
538 #define G_METADATA_ERROR (g_metadata_error_quark ())
540 GQuark g_metadata_error_quark (void);
542 gboolean g_metadata_validate (GMetadata *metadata,
543 GError **error);
546 G_END_DECLS
548 #endif /* __G_METADATA_H__ */