Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 : : * GObject introspection: struct definitions for the binary
3 : : * typelib format, validation
4 : : *
5 : : * Copyright (C) 2005 Matthias Clasen
6 : : * Copyright (C) 2008,2009 Red Hat, Inc.
7 : : *
8 : : * SPDX-License-Identifier: LGPL-2.1-or-later
9 : : *
10 : : * This library is free software; you can redistribute it and/or
11 : : * modify it under the terms of the GNU Lesser General Public
12 : : * License as published by the Free Software Foundation; either
13 : : * version 2 of the License, or (at your option) any later version.
14 : : *
15 : : * This library is distributed in the hope that it will be useful,
16 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 : : * Lesser General Public License for more details.
19 : : *
20 : : * You should have received a copy of the GNU Lesser General Public
21 : : * License along with this library; if not, write to the
22 : : * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 : : * Boston, MA 02111-1307, USA.
24 : : */
25 : :
26 : : #pragma once
27 : :
28 : : #include <gmodule.h>
29 : : #include "girepository.h"
30 : :
31 : : G_BEGIN_DECLS
32 : :
33 : : /**
34 : : * SECTION:gitypelib-internal
35 : : * @title: GITypelib Internals
36 : : * @short_description: Layout and accessors for typelib
37 : : * @stability: Stable
38 : : *
39 : : * The ‘typelib’ is a binary, readonly, memory-mappable database
40 : : * containing reflective information about a GObject library.
41 : : *
42 : : * What the typelib describes and the types used are the same for every
43 : : * platform so, apart the endianness of its scalar values, the typelib
44 : : * database must be considered architecture-independent.
45 : : *
46 : : * The format of GObject typelib is strongly influenced by the Mozilla XPCOM
47 : : * format.
48 : : *
49 : : * Some of the differences to XPCOM include:
50 : : *
51 : : * - Type information is stored not quite as compactly (XPCOM stores it inline
52 : : * in function descriptions in variable-sized blobs of 1 to n bytes. We store
53 : : * 16 bits of type information for each parameter, which is enough to encode
54 : : * simple types inline. Complex (e.g. recursive) types are stored out of line
55 : : * in a separate list of types.
56 : : * - String and complex type data is stored outside of typelib entry blobs,
57 : : * references are stored as offsets relative to the start of the typelib.
58 : : * One possibility is to store the strings and types in a pools at the end
59 : : * of the typelib.
60 : : *
61 : : * The typelib has the following general format:
62 : : *
63 : : * ```
64 : : * typelib ::= header, section-index, directory, blobs, attributes, attributedata
65 : : *
66 : : * directory ::= list of entries
67 : : *
68 : : * entry ::= blob type, name, namespace, offset
69 : : * blob ::= function|callback|struct|boxed|enum|flags|object|interface|constant|union
70 : : * attribute ::= offset, key, value
71 : : * attributedata ::= string data for attributes
72 : : * ```
73 : : *
74 : : * ## Details
75 : : *
76 : : * We describe the fragments that make up the typelib in the form of C structs
77 : : * (although some fall short of being valid C structs since they contain
78 : : * multiple flexible arrays).
79 : : *
80 : : * Since: 2.80
81 : : */
82 : :
83 : : /*
84 : : TYPELIB HISTORY
85 : : -----
86 : :
87 : : Version 1.1
88 : : - Add ref/unref/set-value/get-value functions to Object, to be able
89 : : to support instantiatable fundamental types which are not GObject based.
90 : :
91 : : Version 1.0
92 : : - Rename class_struct to gtype_struct, add to interfaces
93 : :
94 : : Changes since 0.9:
95 : : - Add padding to structures
96 : :
97 : : Changes since 0.8:
98 : : - Add class struct concept to ObjectBlob
99 : : - Add is_class_struct bit to StructBlob
100 : :
101 : : Changes since 0.7:
102 : : - Add dependencies
103 : :
104 : : Changes since 0.6:
105 : : - rename metadata to typelib, to follow xpcom terminology
106 : :
107 : : Changes since 0.5:
108 : : - basic type cleanup:
109 : : + remove GString
110 : : + add [u]int, [u]long, [s]size_t
111 : : + rename string to utf8, add filename
112 : : - allow blob_type to be zero for non-local entries
113 : :
114 : : Changes since 0.4:
115 : : - add a UnionBlob
116 : :
117 : : Changes since 0.3:
118 : : - drop short_name for ValueBlob
119 : :
120 : : Changes since 0.2:
121 : : - make inline types 4 bytes after all, remove header->types and allow
122 : : types to appear anywhere
123 : : - allow error domains in the directory
124 : :
125 : : Changes since 0.1:
126 : :
127 : : - drop comments about _GOBJ_METADATA
128 : : - drop string pool, strings can appear anywhere
129 : : - use 'blob' as collective name for the various blob types
130 : : - rename 'type' field in blobs to 'blob_type'
131 : : - rename 'type_name' and 'type_init' fields to 'gtype_name', 'gtype_init'
132 : : - shrink directory entries to 12 bytes
133 : : - merge struct and boxed blobs
134 : : - split interface blobs into enum, object and interface blobs
135 : : - add an 'unregistered' flag to struct and enum blobs
136 : : - add a 'wraps_vfunc' flag to function blobs and link them to
137 : : the vfuncs they wrap
138 : : - restrict value blobs to only occur inside enums and flags again
139 : : - add constant blobs, allow them toplevel, in interfaces and in objects
140 : : - rename 'receiver_owns_value' and 'receiver_owns_container' to
141 : : 'transfer_ownership' and 'transfer_container_ownership'
142 : : - add a 'struct_offset' field to virtual function and field blobs
143 : : - add 'dipper' and 'optional' flags to arg blobs
144 : : - add a 'true_stops_emit' flag to signal blobs
145 : : - add variable blob sizes to header
146 : : - store offsets to signature blobs instead of including them directly
147 : : - change the type offset to be measured in words rather than bytes
148 : : */
149 : :
150 : : /**
151 : : * GI_IR_MAGIC:
152 : : *
153 : : * Identifying prefix for the typelib.
154 : : *
155 : : * This was inspired by XPCOM, which in turn borrowed from PNG.
156 : : *
157 : : * Since: 2.80
158 : : */
159 : : #define GI_IR_MAGIC "GOBJ\nMETADATA\r\n\032"
160 : :
161 : : /**
162 : : * GITypelibBlobType:
163 : : * @BLOB_TYPE_INVALID: Should not appear in code
164 : : * @BLOB_TYPE_FUNCTION: A #FunctionBlob
165 : : * @BLOB_TYPE_CALLBACK: A #CallbackBlob
166 : : * @BLOB_TYPE_STRUCT: A #StructBlob
167 : : * @BLOB_TYPE_BOXED: Can be either a #StructBlob or #UnionBlob
168 : : * @BLOB_TYPE_ENUM: An #EnumBlob
169 : : * @BLOB_TYPE_FLAGS: An #EnumBlob
170 : : * @BLOB_TYPE_OBJECT: An #ObjectBlob
171 : : * @BLOB_TYPE_INTERFACE: An #InterfaceBlob
172 : : * @BLOB_TYPE_CONSTANT: A #ConstantBlob
173 : : * @BLOB_TYPE_INVALID_0: Deleted, used to be ErrorDomain.
174 : : * @BLOB_TYPE_UNION: A #UnionBlob
175 : : *
176 : : * The integral value of this enumeration appears in each "Blob" component of
177 : : * a typelib to identify its type.
178 : : *
179 : : * Since: 2.80
180 : : */
181 : : typedef enum {
182 : : /* The values here must be kept in sync with GIInfoType */
183 : : BLOB_TYPE_INVALID,
184 : : BLOB_TYPE_FUNCTION,
185 : : BLOB_TYPE_CALLBACK,
186 : : BLOB_TYPE_STRUCT,
187 : : BLOB_TYPE_BOXED,
188 : : BLOB_TYPE_ENUM,
189 : : BLOB_TYPE_FLAGS,
190 : : BLOB_TYPE_OBJECT,
191 : : BLOB_TYPE_INTERFACE,
192 : : BLOB_TYPE_CONSTANT,
193 : : BLOB_TYPE_INVALID_0,
194 : : BLOB_TYPE_UNION
195 : : } GITypelibBlobType;
196 : :
197 : :
198 : : #if defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE)
199 : :
200 : : G_ALWAYS_INLINE
201 : : static inline gboolean
202 : : _blob_is_registered_type (GITypelibBlobType blob_type)
203 : : {
204 : 5658 : switch (blob_type)
205 : : {
206 : 2140 : case BLOB_TYPE_STRUCT:
207 : : case BLOB_TYPE_UNION:
208 : : case BLOB_TYPE_ENUM:
209 : : case BLOB_TYPE_FLAGS:
210 : : case BLOB_TYPE_OBJECT:
211 : : case BLOB_TYPE_INTERFACE:
212 : 2140 : return TRUE;
213 : 3518 : default:
214 : 3518 : return FALSE;
215 : : }
216 : : }
217 : :
218 : : #define BLOB_IS_REGISTERED_TYPE(blob) \
219 : : _blob_is_registered_type ((GITypelibBlobType) (blob)->blob_type)
220 : :
221 : : #else
222 : :
223 : : #define BLOB_IS_REGISTERED_TYPE(blob) \
224 : : ((blob)->blob_type == BLOB_TYPE_STRUCT || \
225 : : (blob)->blob_type == BLOB_TYPE_UNION || \
226 : : (blob)->blob_type == BLOB_TYPE_ENUM || \
227 : : (blob)->blob_type == BLOB_TYPE_FLAGS || \
228 : : (blob)->blob_type == BLOB_TYPE_OBJECT || \
229 : : (blob)->blob_type == BLOB_TYPE_INTERFACE)
230 : :
231 : : #endif /* defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE) */
232 : :
233 : : /**
234 : : * Header:
235 : : * @magic: See #GI_IR_MAGIC.
236 : : * @major_version: The major version number of the typelib format. Major version
237 : : * number changes indicate incompatible changes to the tyeplib format.
238 : : * @minor_version: The minor version number of the typelib format. Minor version
239 : : * number changes indicate compatible changes and should still allow the
240 : : * typelib to be parsed by a parser designed for the same @major_version.
241 : : * @reserved: Reserved for future use.
242 : : * @n_entries: The number of entries in the directory.
243 : : * @n_local_entries: The number of entries referring to blobs in this typelib.
244 : : * The local entries must occur before the unresolved entries.
245 : : * @directory: Offset of the directory in the typelib.
246 : : * @n_attributes: Number of attribute blocks
247 : : * @attributes: Offset of the list of attributes in the typelib.
248 : : * @dependencies: Offset of a single string, which is the list of immediate
249 : : * dependencies, separated by the '|' character. The dependencies are
250 : : * required in order to avoid having programs consuming a typelib check for
251 : : * an "Unresolved" type return from every API call.
252 : : * @size: The size in bytes of the typelib.
253 : : * @namespace: Offset of the namespace string in the typelib.
254 : : * @nsversion: Offset of the namespace version string in the typelib.
255 : : * @shared_library: This field is the set of shared libraries associated with
256 : : * the typelib. The entries are separated by the '|' (pipe) character.
257 : : * @c_prefix: The prefix for the function names of the library
258 : : * @entry_blob_size: The sizes of fixed-size blobs. Recording this information
259 : : * here allows to write parser which continue to work if the format is
260 : : * extended by adding new fields to the end of the fixed-size blobs.
261 : : * @function_blob_size: See @entry_blob_size.
262 : : * @callback_blob_size: See @entry_blob_size.
263 : : * @signal_blob_size: See @entry_blob_size.
264 : : * @vfunc_blob_size: See @entry_blob_size.
265 : : * @arg_blob_size: See @entry_blob_size.
266 : : * @property_blob_size: See @entry_blob_size.
267 : : * @field_blob_size: See @entry_blob_size.
268 : : * @value_blob_size: See @entry_blob_size.
269 : : * @attribute_blob_size: See @entry_blob_size.
270 : : * @constant_blob_size: See @entry_blob_size.
271 : : * @error_domain_blob_size: See @entry_blob_size.
272 : : * @signature_blob_size: See @entry_blob_size.
273 : : * @enum_blob_size: See @entry_blob_size.
274 : : * @struct_blob_size: See @entry_blob_size.
275 : : * @object_blob_size: See @entry_blob_size.
276 : : * @interface_blob_size: For variable-size blobs, the size of the struct up to
277 : : * the first flexible array member. Recording this information here allows
278 : : * to write parser which continue to work if the format is extended by
279 : : * adding new fields before the first flexible array member in
280 : : * variable-size blobs.
281 : : * @union_blob_size: See @entry_blob_size.
282 : : * @sections: Offset of section blob array
283 : : * @padding: TODO
284 : : *
285 : : * The header structure appears exactly once at the beginning of a typelib. It is a
286 : : * collection of meta-information, such as the number of entries and dependencies.
287 : : *
288 : : * Since: 2.80
289 : : */
290 : : typedef struct {
291 : : char magic[16];
292 : : uint8_t major_version;
293 : : uint8_t minor_version;
294 : : uint16_t reserved;
295 : : uint16_t n_entries;
296 : : uint16_t n_local_entries;
297 : : uint32_t directory;
298 : : uint32_t n_attributes;
299 : : uint32_t attributes;
300 : :
301 : : uint32_t dependencies;
302 : :
303 : : uint32_t size;
304 : : uint32_t namespace;
305 : : uint32_t nsversion;
306 : : uint32_t shared_library;
307 : : uint32_t c_prefix;
308 : :
309 : : uint16_t entry_blob_size;
310 : : uint16_t function_blob_size;
311 : : uint16_t callback_blob_size;
312 : : uint16_t signal_blob_size;
313 : : uint16_t vfunc_blob_size;
314 : : uint16_t arg_blob_size;
315 : : uint16_t property_blob_size;
316 : : uint16_t field_blob_size;
317 : : uint16_t value_blob_size;
318 : : uint16_t attribute_blob_size;
319 : : uint16_t constant_blob_size;
320 : : uint16_t error_domain_blob_size;
321 : :
322 : : uint16_t signature_blob_size;
323 : : uint16_t enum_blob_size;
324 : : uint16_t struct_blob_size;
325 : : uint16_t object_blob_size;
326 : : uint16_t interface_blob_size;
327 : : uint16_t union_blob_size;
328 : :
329 : : uint32_t sections;
330 : :
331 : : uint16_t padding[6];
332 : : } Header;
333 : :
334 : : /**
335 : : * SectionType:
336 : : * @GI_SECTION_END: TODO
337 : : * @GI_SECTION_DIRECTORY_INDEX: TODO
338 : : *
339 : : * TODO
340 : : *
341 : : * Since: 2.80
342 : : */
343 : : typedef enum {
344 : : GI_SECTION_END = 0,
345 : : GI_SECTION_DIRECTORY_INDEX = 1
346 : : } SectionType;
347 : :
348 : : /**
349 : : * Section:
350 : : * @id: A #SectionType
351 : : * @offset: Integer offset for this section
352 : : *
353 : : * A section is a blob of data that's (at least theoretically) optional,
354 : : * and may or may not be present in the typelib. Presently, just used
355 : : * for the directory index. This allows a form of dynamic extensibility
356 : : * with different tradeoffs from the format minor version.
357 : : *
358 : : * Since: 2.80
359 : : */
360 : : typedef struct {
361 : : uint32_t id;
362 : : uint32_t offset;
363 : : } Section;
364 : :
365 : :
366 : : /**
367 : : * DirEntry:
368 : : * @blob_type: A #GITypelibBlobType
369 : : * @local: Whether this entry refers to a blob in this typelib.
370 : : * @reserved: Reserved for future use.
371 : : * @name: The name of the entry.
372 : : * @offset: If is_local is set, this is the offset of the blob in the typelib.
373 : : * Otherwise, it is the offset of the namespace in which the blob has to be
374 : : * looked up by name.
375 : : *
376 : : * References to directory entries are stored as 1-based 16-bit indexes.
377 : : *
378 : : * All blobs pointed to by a directory entry start with the same layout for
379 : : * the first 8 bytes (the reserved flags may be used by some blob types)
380 : : *
381 : : * Since: 2.80
382 : : */
383 : : typedef struct {
384 : : uint16_t blob_type;
385 : :
386 : : uint16_t local : 1;
387 : : uint16_t reserved :15;
388 : : uint32_t name;
389 : : uint32_t offset;
390 : : } DirEntry;
391 : :
392 : : /**
393 : : * SimpleTypeBlobFlags:
394 : : * @reserved: Reserved for future use.
395 : : * @reserved2: Reserved for future use.
396 : : * @pointer: TODO
397 : : * @reserved3: Reserved for future use.
398 : : * @tag: A #GITypeTag
399 : : *
400 : : * TODO
401 : : *
402 : : * Since: 2.80
403 : : */
404 : : typedef struct {
405 : : unsigned reserved : 8;
406 : : unsigned reserved2 :16;
407 : : unsigned pointer : 1;
408 : : unsigned reserved3 : 2;
409 : : unsigned tag : 5;
410 : : } SimpleTypeBlobFlags;
411 : :
412 : : union _SimpleTypeBlob
413 : : {
414 : : SimpleTypeBlobFlags flags;
415 : : uint32_t offset;
416 : : };
417 : :
418 : : /**
419 : : * SimpleTypeBlob:
420 : : * @flags: TODO
421 : : * @offset: Offset relative to header->types that points to a TypeBlob.
422 : : * Unlike other offsets, this is in words (ie 32bit units) rather
423 : : * than bytes.
424 : : *
425 : : * The SimpleTypeBlob is the general purpose "reference to a type" construct,
426 : : * used in method parameters, returns, callback definitions, fields, constants,
427 : : * etc. It's actually just a 32 bit integer which you can see from the union
428 : : * definition. This is for efficiency reasons, since there are so many
429 : : * references to types.
430 : : *
431 : : * SimpleTypeBlob is divided into two cases; first, if "reserved" and
432 : : * "reserved2" are both zero, the type tag for a basic type is embedded in the
433 : : * "tag" bits. This allows e.g. GI_TYPE_TAG_UTF8, GI_TYPE_TAG_INT and the like
434 : : * to be embedded directly without taking up extra space.
435 : : *
436 : : * References to "interfaces" (objects, interfaces) are more complicated;
437 : : * In this case, the integer is actually an offset into the directory (see
438 : : * above). Because the header is larger than 2^8=256 bits, all offsets will
439 : : * have one of the upper 24 bits set.
440 : : *
441 : : * Since: 2.80
442 : : */
443 : : typedef union _SimpleTypeBlob SimpleTypeBlob;
444 : :
445 : : /**
446 : : * ArgBlob:
447 : : * @name: A suggested name for the parameter.
448 : : * @in: The parameter is an input to the function
449 : : * @out: The parameter is used to return an output of the function. Parameters
450 : : * can be both in and out. Out parameters implicitly add another level of
451 : : * indirection to the parameter type. Ie if the type is uint32 in an out
452 : : * parameter, the function actually takes a uint32*.
453 : : * @caller_allocates: The parameter is a pointer to a struct or object that
454 : : * will receive an output of the function.
455 : : * @nullable: Only meaningful for types which are passed as pointers. For an
456 : : * in parameter, indicates if it is ok to pass NULL in. Gor an out
457 : : * parameter, indicates whether it may return NULL. Note that NULL is a
458 : : * valid GList and GSList value, thus allow_none will normally be set
459 : : * for parameters of these types.
460 : : * @optional: For an out parameter, indicates that NULL may be passed in
461 : : * if the value is not needed.
462 : : * @transfer_ownership: For an in parameter, indicates that the function takes
463 : : * over ownership of the parameter value. For an out parameter, it indicates
464 : : * that the caller is responsible for freeing the return value.
465 : : * @transfer_container_ownership: For container types, indicates that the
466 : : * ownership of the container, but not of its contents is transferred.
467 : : * This is typically the case for out parameters returning lists of
468 : : * statically allocated things.
469 : : * @return_value: The parameter should be considered the return value of the
470 : : * function. Only out parameters can be marked as return value, and there
471 : : * can be at most one per function call. If an out parameter is marked as
472 : : * return value, the actual return value of the function should be either
473 : : * void or a boolean indicating the success of the call.
474 : : * @scope: A #GIScopeType. If the parameter is of a callback type, this denotes
475 : : * the scope of the user_data and the callback function pointer itself
476 : : * (for languages that emit code at run-time).
477 : : * @skip: Indicates that the parameter is only useful in C and should be skipped.
478 : : * @reserved: Reserved for future use.
479 : : * @closure: Index of the closure (user_data) parameter associated with the
480 : : * callback, or -1.
481 : : * @destroy: Index of the destroy notification callback parameter associated
482 : : * with the callback, or -1.
483 : : * @padding: TODO
484 : : * @arg_type: Describes the type of the parameter. See details below.
485 : : *
486 : : * Types are specified by four bytes. If the three high bytes are zero,
487 : : * the low byte describes a basic type, otherwise the 32bit number is an
488 : : * offset which points to a TypeBlob.
489 : : *
490 : : * Since: 2.80
491 : : */
492 : : typedef struct {
493 : : uint32_t name;
494 : :
495 : : unsigned in : 1;
496 : : unsigned out : 1;
497 : : unsigned caller_allocates : 1;
498 : : unsigned nullable : 1;
499 : : unsigned optional : 1;
500 : : unsigned transfer_ownership : 1;
501 : : unsigned transfer_container_ownership : 1;
502 : : unsigned return_value : 1;
503 : : unsigned scope : 3;
504 : : unsigned skip : 1;
505 : : unsigned reserved :20;
506 : : int8_t closure;
507 : : int8_t destroy;
508 : :
509 : : uint16_t padding;
510 : :
511 : : SimpleTypeBlob arg_type;
512 : : } ArgBlob;
513 : :
514 : : /**
515 : : * SignatureBlob:
516 : : * @return_type: Describes the type of the return value. See details below.
517 : : * @may_return_null: Only relevant for pointer types. Indicates whether the
518 : : * caller must expect NULL as a return value.
519 : : * @caller_owns_return_value: If set, the caller is responsible for freeing
520 : : * the return value if it is no longer needed.
521 : : * @caller_owns_return_container: This flag is only relevant if the return type
522 : : * is a container type. If the flag is set, the caller is resonsible for
523 : : * freeing the container, but not its contents.
524 : : * @skip_return: Indicates that the return value is only useful in C and should
525 : : * be skipped.
526 : : * @instance_transfer_ownership: When calling, the function assumes ownership of
527 : : * the instance parameter.
528 : : * @throws: Denotes the signature takes an additional #GError argument beyond
529 : : * the annotated arguments.
530 : : * @reserved: Reserved for future use.
531 : : * @n_arguments: The number of arguments that this function expects, also the
532 : : * length of the array of ArgBlobs.
533 : : * @arguments: An array of ArgBlob for the arguments of the function.
534 : : *
535 : : * TODO
536 : : *
537 : : * Since: 2.80
538 : : */
539 : : typedef struct {
540 : : SimpleTypeBlob return_type;
541 : :
542 : : uint16_t may_return_null : 1;
543 : : uint16_t caller_owns_return_value : 1;
544 : : uint16_t caller_owns_return_container : 1;
545 : : uint16_t skip_return : 1;
546 : : uint16_t instance_transfer_ownership : 1;
547 : : uint16_t throws : 1;
548 : : uint16_t reserved :10;
549 : :
550 : : uint16_t n_arguments;
551 : :
552 : : ArgBlob arguments[];
553 : : } SignatureBlob;
554 : :
555 : : /**
556 : : * CommonBlob:
557 : : * @blob_type: A #GITypelibBlobType
558 : : * @deprecated: Whether the blob is deprecated.
559 : : * @reserved: Reserved for future use.
560 : : * @name: The name of the blob.
561 : : *
562 : : * The #CommonBlob is shared between #FunctionBlob,
563 : : * #CallbackBlob, #SignalBlob.
564 : : *
565 : : * TODO
566 : : *
567 : : * Since: 2.80
568 : : */
569 : : typedef struct {
570 : : uint16_t blob_type; /* 1 */
571 : :
572 : : uint16_t deprecated : 1;
573 : : uint16_t reserved :15;
574 : : uint32_t name;
575 : : } CommonBlob;
576 : :
577 : : /**
578 : : * FunctionBlob:
579 : : * @blob_type: #BLOB_TYPE_FUNCTION
580 : : * @deprecated: The function is deprecated.
581 : : * @setter: The function is a setter for a property. Language bindings may
582 : : * prefer to not bind individual setters and rely on the generic
583 : : * g_object_set().
584 : : * @getter: The function is a getter for a property. Language bindings may
585 : : * prefer to not bind individual getters and rely on the generic
586 : : * g_object_get().
587 : : * @constructor: The function acts as a constructor for the object it is
588 : : * contained in.
589 : : * @wraps_vfunc: The function is a simple wrapper for a virtual function.
590 : : * @throws: This is now additionally stored in the #SignatureBlob. (deprecated)
591 : : * @index: Index of the property that this function is a setter or getter of
592 : : * in the array of properties of the containing interface, or index
593 : : * of the virtual function that this function wraps.
594 : : * @name: TODO
595 : : * @symbol: The symbol which can be used to obtain the function pointer with
596 : : * dlsym().
597 : : * @signature: Offset of the SignatureBlob describing the parameter types and the
598 : : * return value type.
599 : : * @is_static: The function is a "static method"; in other words it's a pure
600 : : * function whose name is conceptually scoped to the object.
601 : : * @is_async: Whether the function is asynchronous
602 : : * @sync_or_async: The index of the synchronous version of the function if is_async is TRUE,
603 : : * otherwise, the index of the asynchronous version.
604 : : * @reserved: Reserved for future use.
605 : : * @finish: The index of the finish function if is_async is TRUE, otherwise ASYNC_SENTINEL
606 : : * @reserved2: Reserved for future use.
607 : : *
608 : : * TODO
609 : : *
610 : : * Since: 2.80
611 : : */
612 : : typedef struct {
613 : : uint16_t blob_type; /* 1 */
614 : :
615 : : uint16_t deprecated : 1;
616 : : uint16_t setter : 1;
617 : : uint16_t getter : 1;
618 : : uint16_t constructor : 1;
619 : : uint16_t wraps_vfunc : 1;
620 : : uint16_t throws : 1;
621 : : uint16_t index : 10;
622 : : /* Note the bits above need to match CommonBlob
623 : : * and are thus exhausted, extend things using
624 : : * the reserved block below. */
625 : :
626 : : uint32_t name;
627 : : uint32_t symbol;
628 : : uint32_t signature;
629 : :
630 : : uint16_t is_static : 1;
631 : : uint16_t is_async : 1;
632 : : uint16_t sync_or_async : 10;
633 : : uint16_t reserved : 4;
634 : :
635 : : uint16_t finish : 10;
636 : : uint16_t reserved2 : 6;
637 : : } FunctionBlob;
638 : :
639 : : /**
640 : : * CallbackBlob:
641 : : * @blob_type: TODO
642 : : * @deprecated: TODO
643 : : * @reserved: Reserved for future use.
644 : : * @name: TODO
645 : : * @signature: Offset of the #SignatureBlob describing the parameter types and
646 : : * the return value type.
647 : : *
648 : : * TODO
649 : : *
650 : : * Since: 2.80
651 : : */
652 : : typedef struct {
653 : : uint16_t blob_type; /* 2 */
654 : :
655 : : uint16_t deprecated : 1;
656 : : uint16_t reserved :15;
657 : : uint32_t name;
658 : : uint32_t signature;
659 : : } CallbackBlob;
660 : :
661 : : /**
662 : : * InterfaceTypeBlob:
663 : : * @pointer: Whether this type represents an indirection
664 : : * @reserved: Reserved for future use.
665 : : * @tag: A #GITypeTag
666 : : * @reserved2: Reserved for future use.
667 : : * @interface: Index of the directory entry for the interface.
668 : : *
669 : : * If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1.
670 : : *
671 : : * Since: 2.80
672 : : */
673 : : typedef struct {
674 : : uint8_t pointer :1;
675 : : uint8_t reserved :2;
676 : : uint8_t tag :5;
677 : : uint8_t reserved2;
678 : : uint16_t interface;
679 : : } InterfaceTypeBlob;
680 : :
681 : : /**
682 : : * ArrayTypeDimension:
683 : : * @length: TODO
684 : : * @size: TODO
685 : : *
686 : : * TODO
687 : : *
688 : : * Since: 2.80
689 : : */
690 : : typedef union {
691 : : uint16_t length;
692 : : uint16_t size;
693 : : } ArrayTypeDimension;
694 : :
695 : : /**
696 : : * ArrayTypeBlob:
697 : : * @pointer: TODO
698 : : * @reserved: Reserved for future use.
699 : : * @tag: TODO
700 : : * @zero_terminated: Indicates that the array must be terminated by a suitable
701 : : * #NULL value.
702 : : * @has_length: Indicates that length points to a parameter specifying the
703 : : * length of the array. If both has_length and zero_terminated are set, the
704 : : * convention is to pass -1 for the length if the array is zero-terminated.
705 : : * @has_size: Indicates that size is the fixed size of the array.
706 : : * @array_type: Indicates whether this is a C array, GArray, GPtrArray, or
707 : : * GByteArray. If something other than a C array, the length and element
708 : : * size are implicit in the structure.
709 : : * @reserved2: Reserved for future use.
710 : : * @dimensions: TODO
711 : : * @type: TODO
712 : : *
713 : : * TODO
714 : : *
715 : : * Since: 2.80
716 : : */
717 : : typedef struct {
718 : : uint16_t pointer :1;
719 : : uint16_t reserved :2;
720 : : uint16_t tag :5;
721 : :
722 : : uint16_t zero_terminated :1;
723 : : uint16_t has_length :1;
724 : : uint16_t has_size :1;
725 : : uint16_t array_type :2;
726 : : uint16_t reserved2 :3;
727 : :
728 : : ArrayTypeDimension dimensions;
729 : :
730 : : SimpleTypeBlob type;
731 : : } ArrayTypeBlob;
732 : :
733 : : /**
734 : : * ParamTypeBlob:
735 : : * @pointer: TODO
736 : : * @reserved: Reserved for future use.
737 : : * @tag: TODO
738 : : * @reserved2: Reserved for future use.
739 : : * @n_types: The number of parameter types to follow.
740 : : * @type: Describes the type of the list elements.
741 : : *
742 : : * TODO
743 : : *
744 : : * Since: 2.80
745 : : */
746 : : typedef struct {
747 : : uint8_t pointer :1;
748 : : uint8_t reserved :2;
749 : : uint8_t tag :5;
750 : :
751 : : uint8_t reserved2;
752 : : uint16_t n_types;
753 : :
754 : : SimpleTypeBlob type[];
755 : : } ParamTypeBlob;
756 : :
757 : : /**
758 : : * ErrorTypeBlob:
759 : : * @pointer: TODO
760 : : * @reserved: TODO
761 : : * @tag: TODO
762 : : * @reserved2: TODO
763 : : * @n_domains: TODO: must be 0
764 : : * @domains: TODO
765 : : *
766 : : * TODO
767 : : *
768 : : * Since: 2.80
769 : : */
770 : : typedef struct {
771 : : uint8_t pointer :1;
772 : : uint8_t reserved :2;
773 : : uint8_t tag :5;
774 : :
775 : : uint8_t reserved2;
776 : :
777 : : uint16_t n_domains; /* Must be 0 */
778 : : uint16_t domains[];
779 : : } ErrorTypeBlob;
780 : :
781 : : /**
782 : : * ValueBlob:
783 : : * @deprecated: Whether this value is deprecated
784 : : * @unsigned_value: if set, value is a 32-bit unsigned integer cast to int32_t
785 : : * @reserved: Reserved for future use.
786 : : * @name: Name of blob
787 : : * @value: The numerical value
788 : : *
789 : : * Values commonly occur in enums and flags.
790 : : *
791 : : * Since: 2.80
792 : : */
793 : : typedef struct {
794 : : uint32_t deprecated : 1;
795 : : uint32_t unsigned_value : 1;
796 : : uint32_t reserved :30;
797 : : uint32_t name;
798 : : int32_t value;
799 : : } ValueBlob;
800 : :
801 : : /**
802 : : * FieldBlob:
803 : : * @name: The name of the field.
804 : : * @readable: TODO
805 : : * @writable: How the field may be accessed.
806 : : * @has_embedded_type: An anonymous type follows the FieldBlob.
807 : : * @reserved: Reserved for future use.
808 : : * @bits: If this field is part of a bitfield, the number of bits which it
809 : : * uses, otherwise 0.
810 : : * @struct_offset: The offset of the field in the struct. The value 0xFFFF
811 : : * indicates that the struct offset is unknown.
812 : : * @reserved2: Reserved for future use.
813 : : * @type: The type of the field.
814 : : *
815 : : * TODO
816 : : *
817 : : * Since: 2.80
818 : : */
819 : : typedef struct {
820 : : uint32_t name;
821 : :
822 : : uint8_t readable :1;
823 : : uint8_t writable :1;
824 : : uint8_t has_embedded_type :1;
825 : : uint8_t reserved :5;
826 : : uint8_t bits;
827 : :
828 : : uint16_t struct_offset;
829 : :
830 : : uint32_t reserved2;
831 : :
832 : : SimpleTypeBlob type;
833 : : } FieldBlob;
834 : :
835 : : /**
836 : : * RegisteredTypeBlob:
837 : : * @blob_type: TODO
838 : : * @deprecated: TODO
839 : : * @unregistered: TODO
840 : : * @reserved: Reserved for future use.
841 : : * @name: TODO
842 : : * @gtype_name: The name under which the type is registered with GType.
843 : : * @gtype_init: The symbol name of the get_type<!-- -->() function which registers the
844 : : * type.
845 : : *
846 : : * TODO
847 : : *
848 : : * Since: 2.80
849 : : */
850 : : typedef struct {
851 : : uint16_t blob_type;
852 : : uint16_t deprecated : 1;
853 : : uint16_t unregistered : 1;
854 : : uint16_t reserved :14;
855 : : uint32_t name;
856 : :
857 : : uint32_t gtype_name;
858 : : uint32_t gtype_init;
859 : : } RegisteredTypeBlob;
860 : :
861 : : /**
862 : : * StructBlob:
863 : : * @blob_type: #BLOB_TYPE_STRUCT
864 : : * @deprecated: Whether this structure is deprecated
865 : : * @unregistered: If this is set, the type is not registered with GType.
866 : : * @is_gtype_struct: Whether this structure is the class or interface layout
867 : : * for a GObject
868 : : * @alignment: The byte boundary that the struct is aligned to in memory
869 : : * @foreign: If the type is foreign, eg if it's expected to be overridden by
870 : : * a native language binding instead of relying of introspected bindings.
871 : : * @reserved: Reserved for future use.
872 : : * @name: TODO
873 : : * @gtype_name: String name of the associated #GType
874 : : * @gtype_init: String naming the symbol which gets the runtime #GType
875 : : * @size: The size of the struct in bytes.
876 : : * @n_fields: TODO
877 : : * @n_methods: TODO
878 : : * @copy_func: String pointing to a function which can be called to copy
879 : : * the contents of this struct type
880 : : * @free_func: String pointing to a function which can be called to free
881 : : * the contents of this struct type
882 : : *
883 : : * TODO
884 : : *
885 : : * Since: 2.80
886 : : */
887 : : typedef struct {
888 : : uint16_t blob_type;
889 : :
890 : : uint16_t deprecated : 1;
891 : : uint16_t unregistered : 1;
892 : : uint16_t is_gtype_struct : 1;
893 : : uint16_t alignment : 6;
894 : : uint16_t foreign : 1;
895 : : uint16_t reserved : 6;
896 : :
897 : : uint32_t name;
898 : :
899 : : uint32_t gtype_name;
900 : : uint32_t gtype_init;
901 : :
902 : : uint32_t size;
903 : :
904 : : uint16_t n_fields;
905 : : uint16_t n_methods;
906 : :
907 : : uint32_t copy_func;
908 : : uint32_t free_func;
909 : : } StructBlob;
910 : :
911 : : /**
912 : : * UnionBlob:
913 : : * @blob_type: TODO
914 : : * @deprecated: TODO
915 : : * @unregistered: If this is set, the type is not registered with GType.
916 : : * @discriminated: Is set if the union is discriminated
917 : : * @alignment: The byte boundary that the union is aligned to in memory
918 : : * @reserved: Reserved for future use.
919 : : * @name: TODO
920 : : * @gtype_name: String name of the associated #GType
921 : : * @gtype_init: String naming the symbol which gets the runtime #GType
922 : : * @size: TODO
923 : : * @n_fields: Length of the arrays
924 : : * @n_functions: TODO
925 : : * @copy_func: String pointing to a function which can be called to copy
926 : : * the contents of this union type
927 : : * @free_func: String pointing to a function which can be called to free
928 : : * the contents of this union type
929 : : * @discriminator_offset: Offset from the beginning of the union where the
930 : : * discriminator of a discriminated union is located. The value 0xFFFF
931 : : * indicates that the discriminator offset is unknown.
932 : : * @discriminator_type: Type of the discriminator
933 : : *
934 : : * TODO
935 : : *
936 : : * Since: 2.80
937 : : */
938 : : typedef struct {
939 : : uint16_t blob_type;
940 : : uint16_t deprecated : 1;
941 : : uint16_t unregistered : 1;
942 : : uint16_t discriminated : 1;
943 : : uint16_t alignment : 6;
944 : : uint16_t reserved : 7;
945 : : uint32_t name;
946 : :
947 : : uint32_t gtype_name;
948 : : uint32_t gtype_init;
949 : :
950 : : uint32_t size;
951 : :
952 : : uint16_t n_fields;
953 : : uint16_t n_functions;
954 : :
955 : : uint32_t copy_func;
956 : : uint32_t free_func;
957 : :
958 : : int32_t discriminator_offset;
959 : : SimpleTypeBlob discriminator_type;
960 : : } UnionBlob;
961 : :
962 : : /**
963 : : * EnumBlob:
964 : : * @blob_type: TODO
965 : : * @deprecated: TODO
966 : : * @unregistered: If this is set, the type is not registered with GType.
967 : : * @storage_type: The tag of the type used for the enum in the C ABI
968 : : * (will be a signed or unsigned integral type)
969 : : * @reserved: Reserved for future use.
970 : : * @name: TODO
971 : : * @gtype_name: String name of the associated #GType
972 : : * @gtype_init: String naming the symbol which gets the runtime #GType
973 : : * @n_values: The length of the values array.
974 : : * @n_methods: The length of the methods array.
975 : : * @error_domain: String naming the #GError domain this enum is associated with
976 : : * @values: TODO
977 : : *
978 : : * TODO
979 : : *
980 : : * Since: 2.80
981 : : */
982 : : typedef struct {
983 : : uint16_t blob_type;
984 : :
985 : : uint16_t deprecated : 1;
986 : : uint16_t unregistered : 1;
987 : : uint16_t storage_type : 5;
988 : : uint16_t reserved : 9;
989 : :
990 : : uint32_t name;
991 : :
992 : : uint32_t gtype_name;
993 : : uint32_t gtype_init;
994 : :
995 : : uint16_t n_values;
996 : : uint16_t n_methods;
997 : :
998 : : uint32_t error_domain;
999 : :
1000 : : ValueBlob values[];
1001 : : } EnumBlob;
1002 : :
1003 : : #define ACCESSOR_SENTINEL 0x3ff
1004 : : #define ASYNC_SENTINEL 0x3ff
1005 : :
1006 : : /**
1007 : : * PropertyBlob:
1008 : : * @name: The name of the property.
1009 : : * @deprecated: TODO
1010 : : * @readable: TODO
1011 : : * @writable: TODO
1012 : : * @construct: TODO
1013 : : * @construct_only: The ParamFlags used when registering the property.
1014 : : * @transfer_ownership: When writing, the type containing the property takes
1015 : : * ownership of the value. When reading, the returned value needs to be
1016 : : * released by the caller.
1017 : : * @transfer_container_ownership: For container types indicates that the
1018 : : * ownership of the container, but not of its contents, is transferred.
1019 : : * This is typically the case when reading lists of statically allocated
1020 : : * things.
1021 : : * @setter: the index of the setter function for this property, if @writable
1022 : : * is set; if the method is not known, the value will be set to %ACCESSOR_SENTINEL
1023 : : * @getter: ths index of the getter function for this property, if @readable
1024 : : * is set; if the method is not known, the value will be set to %ACCESSOR_SENTINEL
1025 : : * @reserved: Reserved for future use.
1026 : : * @reserved2: Reserved for future use.
1027 : : * @type: Describes the type of the property.
1028 : : *
1029 : : * TODO
1030 : : *
1031 : : * Since: 2.80
1032 : : */
1033 : : typedef struct {
1034 : : uint32_t name;
1035 : :
1036 : : uint32_t deprecated : 1;
1037 : : uint32_t readable : 1;
1038 : : uint32_t writable : 1;
1039 : : uint32_t construct : 1;
1040 : : uint32_t construct_only : 1;
1041 : : uint32_t transfer_ownership : 1;
1042 : : uint32_t transfer_container_ownership : 1;
1043 : : uint32_t setter :10;
1044 : : uint32_t getter :10;
1045 : : uint32_t reserved : 5;
1046 : :
1047 : : uint32_t reserved2;
1048 : :
1049 : : SimpleTypeBlob type;
1050 : : } PropertyBlob;
1051 : :
1052 : : /**
1053 : : * SignalBlob:
1054 : : * @deprecated: TODO
1055 : : * @run_first: TODO
1056 : : * @run_last: TODO
1057 : : * @run_cleanup: TODO
1058 : : * @no_recurse: TODO
1059 : : * @detailed: TODO
1060 : : * @action: TODO
1061 : : * @no_hooks: The flags used when registering the signal.
1062 : : * @has_class_closure: Set if the signal has a class closure.
1063 : : * @true_stops_emit: Whether the signal has true-stops-emit semantics
1064 : : * @reserved: Reserved for future use.
1065 : : * @class_closure: The index of the class closure in the list of virtual
1066 : : * functions of the object or interface on which the signal is defined.
1067 : : * @name: The name of the signal.
1068 : : * @reserved2: Reserved for future use.
1069 : : * @signature: Offset of the SignatureBlob describing the parameter types
1070 : : * and the return value type.
1071 : : *
1072 : : * TODO
1073 : : *
1074 : : * Since: 2.80
1075 : : */
1076 : : typedef struct {
1077 : : uint16_t deprecated : 1;
1078 : : uint16_t run_first : 1;
1079 : : uint16_t run_last : 1;
1080 : : uint16_t run_cleanup : 1;
1081 : : uint16_t no_recurse : 1;
1082 : : uint16_t detailed : 1;
1083 : : uint16_t action : 1;
1084 : : uint16_t no_hooks : 1;
1085 : : uint16_t has_class_closure : 1;
1086 : : uint16_t true_stops_emit : 1;
1087 : : uint16_t reserved : 6;
1088 : :
1089 : : uint16_t class_closure;
1090 : :
1091 : : uint32_t name;
1092 : :
1093 : : uint32_t reserved2;
1094 : :
1095 : : uint32_t signature;
1096 : : } SignalBlob;
1097 : :
1098 : : /**
1099 : : * VFuncBlob:
1100 : : * @name: The name of the virtual function.
1101 : : * @must_chain_up: If set, every implementation of this virtual function must
1102 : : * chain up to the implementation of the parent class.
1103 : : * @must_be_implemented: If set, every derived class must override this virtual
1104 : : * function.
1105 : : * @must_not_be_implemented: If set, derived class must not override this
1106 : : * virtual function.
1107 : : * @class_closure: Set if this virtual function is the class closure of a
1108 : : * signal.
1109 : : * @throws: This is now additionally stored in the #SignatureBlob. (deprecated)
1110 : : * @is_async: Whether the virtual function is asynchronous
1111 : : * @sync_or_async: The index of the synchronous version of the virtual function if is_async is TRUE,
1112 : : * otherwise, the index of the asynchronous version.
1113 : : * @signal: The index of the signal in the list of signals of the object or
1114 : : * interface to which this virtual function belongs.
1115 : : * @struct_offset: The offset of the function pointer in the class struct.
1116 : : * The value 0xFFFF indicates that the struct offset is unknown.
1117 : : * @invoker: If a method invoker for this virtual exists, this is the offset
1118 : : * in the class structure of the method. If no method is known, this value
1119 : : * will be 0x3ff.
1120 : : * @reserved: Reserved for future use.
1121 : : * @finish: The index of the finish function if is_async is TRUE, otherwise ASYNC_SENTINEL
1122 : : * @reserved2: Reserved for future use.
1123 : : * @reserved3: Reserved for future use.
1124 : : * @signature: Offset of the SignatureBlob describing the parameter types and
1125 : : * the return value type.
1126 : : *
1127 : : * TODO
1128 : : *
1129 : : * Since: 2.80
1130 : : */
1131 : : typedef struct {
1132 : : uint32_t name;
1133 : :
1134 : : uint16_t must_chain_up : 1;
1135 : : uint16_t must_be_implemented : 1;
1136 : : uint16_t must_not_be_implemented : 1;
1137 : : uint16_t class_closure : 1;
1138 : : uint16_t throws : 1;
1139 : : uint16_t is_async : 1;
1140 : : uint16_t sync_or_async : 10;
1141 : : uint16_t signal;
1142 : :
1143 : : uint16_t struct_offset;
1144 : : uint16_t invoker : 10; /* Number of bits matches @index in FunctionBlob */
1145 : : uint16_t reserved : 6;
1146 : :
1147 : : uint16_t finish : 10;
1148 : : uint16_t reserved2 : 6;
1149 : : uint16_t reserved3 : 16;
1150 : :
1151 : : uint32_t signature;
1152 : : } VFuncBlob;
1153 : :
1154 : : /**
1155 : : * ObjectBlob:
1156 : : * @blob_type: #BLOB_TYPE_OBJECT
1157 : : * @deprecated: whether the type is deprecated
1158 : : * @abstract: whether the type can be instantiated
1159 : : * @fundamental: this object is not a GObject derived type, instead it's
1160 : : * an additional fundamental type.
1161 : : * @final_: whether the type can be derived
1162 : : * @reserved: Reserved for future use.
1163 : : * @name: TODO
1164 : : * @gtype_name: String name of the associated #GType
1165 : : * @gtype_init: String naming the symbol which gets the runtime #GType
1166 : : * @parent: The directory index of the parent type. This is only set for
1167 : : * objects. If an object does not have a parent, it is zero.
1168 : : * @gtype_struct: TODO
1169 : : * @n_interfaces: TODO
1170 : : * @n_fields: TODO
1171 : : * @n_properties: TODO
1172 : : * @n_methods: TODO
1173 : : * @n_signals: TODO
1174 : : * @n_vfuncs: TODO
1175 : : * @n_constants: The lengths of the arrays.Up to 16bits of padding may be
1176 : : * inserted between the arrays to ensure that they start on a 32bit
1177 : : * boundary.
1178 : : * @n_field_callbacks: The number of n_fields which are also callbacks.
1179 : : * This is used to calculate the fields section size in constant time.
1180 : : * @ref_func: String pointing to a function which can be called to increase
1181 : : * the reference count for an instance of this object type.
1182 : : * @unref_func: String pointing to a function which can be called to decrease
1183 : : * the reference count for an instance of this object type.
1184 : : * @set_value_func: String pointing to a function which can be called to
1185 : : * convert a pointer of this object to a GValue
1186 : : * @get_value_func: String pointing to a function which can be called to
1187 : : * convert extract a pointer to this object from a GValue
1188 : : * @reserved3: Reserved for future use.
1189 : : * @reserved4: Reserved for future use.
1190 : : * @interfaces: An array of indices of directory entries for the implemented
1191 : : * interfaces.
1192 : : *
1193 : : * TODO
1194 : : *
1195 : : * Since: 2.80
1196 : : */
1197 : : typedef struct {
1198 : : uint16_t blob_type; /* 7 */
1199 : : uint16_t deprecated : 1;
1200 : : uint16_t abstract : 1;
1201 : : uint16_t fundamental : 1;
1202 : : uint16_t final_ : 1;
1203 : : uint16_t reserved :12;
1204 : : uint32_t name;
1205 : :
1206 : : uint32_t gtype_name;
1207 : : uint32_t gtype_init;
1208 : :
1209 : : uint16_t parent;
1210 : : uint16_t gtype_struct;
1211 : :
1212 : : uint16_t n_interfaces;
1213 : : uint16_t n_fields;
1214 : : uint16_t n_properties;
1215 : : uint16_t n_methods;
1216 : : uint16_t n_signals;
1217 : : uint16_t n_vfuncs;
1218 : : uint16_t n_constants;
1219 : : uint16_t n_field_callbacks;
1220 : :
1221 : : uint32_t ref_func;
1222 : : uint32_t unref_func;
1223 : : uint32_t set_value_func;
1224 : : uint32_t get_value_func;
1225 : :
1226 : : uint32_t reserved3;
1227 : : uint32_t reserved4;
1228 : :
1229 : : uint16_t interfaces[];
1230 : : } ObjectBlob;
1231 : :
1232 : : /**
1233 : : * InterfaceBlob:
1234 : : * @blob_type: TODO
1235 : : * @deprecated: TODO
1236 : : * @reserved: Reserved for future use.
1237 : : * @name: TODO
1238 : : * @gtype_name: TODO
1239 : : * @gtype_init: TODO
1240 : : * @gtype_struct: Name of the interface "class" C structure
1241 : : * @n_prerequisites: Number of prerequisites
1242 : : * @n_properties: Number of properties
1243 : : * @n_methods: Number of methods
1244 : : * @n_signals: Number of signals
1245 : : * @n_vfuncs: Number of virtual functions
1246 : : * @n_constants: The lengths of the arrays. Up to 16bits of padding may be
1247 : : * inserted between the arrays to ensure that they start on a 32bit
1248 : : * boundary.
1249 : : * @padding: TODO
1250 : : * @reserved2: Reserved for future use.
1251 : : * @reserved3: Reserved for future use.
1252 : : * @prerequisites: An array of indices of directory entries for required
1253 : : * interfaces.
1254 : : *
1255 : : * TODO
1256 : : *
1257 : : * Since: 2.80
1258 : : */
1259 : : typedef struct {
1260 : : uint16_t blob_type;
1261 : : uint16_t deprecated : 1;
1262 : : uint16_t reserved :15;
1263 : : uint32_t name;
1264 : :
1265 : : uint32_t gtype_name;
1266 : : uint32_t gtype_init;
1267 : : uint16_t gtype_struct;
1268 : :
1269 : : uint16_t n_prerequisites;
1270 : : uint16_t n_properties;
1271 : : uint16_t n_methods;
1272 : : uint16_t n_signals;
1273 : : uint16_t n_vfuncs;
1274 : : uint16_t n_constants;
1275 : :
1276 : : uint16_t padding;
1277 : :
1278 : : uint32_t reserved2;
1279 : : uint32_t reserved3;
1280 : :
1281 : : uint16_t prerequisites[];
1282 : : } InterfaceBlob;
1283 : :
1284 : : /**
1285 : : * ConstantBlob:
1286 : : * @blob_type: TODO
1287 : : * @deprecated: TODO
1288 : : * @reserved: Reserved for future use.
1289 : : * @name: TODO
1290 : : * @type: The type of the value. In most cases this should be a numeric type
1291 : : * or string.
1292 : : * @size: The size of the value in bytes.
1293 : : * @offset: The offset of the value in the typelib.
1294 : : * @reserved2: Reserved for future use.
1295 : : *
1296 : : * TODO
1297 : : *
1298 : : * Since: 2.80
1299 : : */
1300 : : typedef struct {
1301 : : uint16_t blob_type;
1302 : : uint16_t deprecated : 1;
1303 : : uint16_t reserved :15;
1304 : : uint32_t name;
1305 : :
1306 : : SimpleTypeBlob type;
1307 : :
1308 : : uint32_t size;
1309 : : uint32_t offset;
1310 : :
1311 : : uint32_t reserved2;
1312 : : } ConstantBlob;
1313 : :
1314 : : /**
1315 : : * AttributeBlob:
1316 : : * @offset: The offset of the typelib entry to which this attribute refers.
1317 : : * Attributes are kept sorted by offset, so that the attributes of an
1318 : : * entry can be found by a binary search.
1319 : : * @name: The name of the attribute, a string.
1320 : : * @value: The value of the attribute (also a string)
1321 : : *
1322 : : * TODO
1323 : : *
1324 : : * Since: 2.80
1325 : : */
1326 : : typedef struct {
1327 : : uint32_t offset;
1328 : : uint32_t name;
1329 : : uint32_t value;
1330 : : } AttributeBlob;
1331 : :
1332 : : struct _GITypelib {
1333 : : /*< private >*/
1334 : : gatomicrefcount ref_count;
1335 : : const uint8_t *data; /* just a cached pointer to inside @bytes */
1336 : : size_t len;
1337 : : GBytes *bytes; /* (owned) */
1338 : : GList *modules;
1339 : : gboolean open_attempted;
1340 : : GPtrArray *library_paths; /* (element-type filename) (owned) (nullable) */
1341 : : };
1342 : :
1343 : : DirEntry *gi_typelib_get_dir_entry (GITypelib *typelib,
1344 : : uint16_t index);
1345 : :
1346 : : DirEntry *gi_typelib_get_dir_entry_by_name (GITypelib *typelib,
1347 : : const char *name);
1348 : :
1349 : : DirEntry *gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib,
1350 : : const char *gtype_name);
1351 : :
1352 : : DirEntry *gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib,
1353 : : GQuark error_domain);
1354 : :
1355 : : gboolean gi_typelib_matches_gtype_name_prefix (GITypelib *typelib,
1356 : : const char *gtype_name);
1357 : :
1358 : :
1359 : : /**
1360 : : * gi_typelib_get_string:
1361 : : * @typelib: TODO
1362 : : * @offset: TODO
1363 : : *
1364 : : * TODO
1365 : : *
1366 : : * Returns: TODO
1367 : : * Since: 2.80
1368 : : */
1369 : : #define gi_typelib_get_string(typelib,offset) ((const char*)&(typelib->data)[(offset)])
1370 : :
1371 : :
1372 : : /**
1373 : : * GITypelibError:
1374 : : * @GI_TYPELIB_ERROR_INVALID: the typelib is invalid
1375 : : * @GI_TYPELIB_ERROR_INVALID_HEADER: the typelib header is invalid
1376 : : * @GI_TYPELIB_ERROR_INVALID_DIRECTORY: the typelib directory is invalid
1377 : : * @GI_TYPELIB_ERROR_INVALID_ENTRY: a typelib entry is invalid
1378 : : * @GI_TYPELIB_ERROR_INVALID_BLOB: a typelib blob is invalid
1379 : : *
1380 : : * An error set while validating the #GITypelib
1381 : : *
1382 : : * Since: 2.80
1383 : : */
1384 : : typedef enum
1385 : : {
1386 : : GI_TYPELIB_ERROR_INVALID,
1387 : : GI_TYPELIB_ERROR_INVALID_HEADER,
1388 : : GI_TYPELIB_ERROR_INVALID_DIRECTORY,
1389 : : GI_TYPELIB_ERROR_INVALID_ENTRY,
1390 : : GI_TYPELIB_ERROR_INVALID_BLOB
1391 : : } GITypelibError;
1392 : :
1393 : : /**
1394 : : * GI_TYPELIB_ERROR:
1395 : : *
1396 : : * TODO
1397 : : *
1398 : : * Since: 2.80
1399 : : */
1400 : : #define GI_TYPELIB_ERROR (gi_typelib_error_quark ())
1401 : :
1402 : : GQuark gi_typelib_error_quark (void);
1403 : :
1404 : :
1405 : : GI_AVAILABLE_IN_ALL
1406 : : gboolean gi_typelib_validate (GITypelib *typelib,
1407 : : GError **error);
1408 : :
1409 : :
1410 : : /* defined in gibaseinfo.c */
1411 : : AttributeBlob *_attribute_blob_find_first (GIBaseInfo *info,
1412 : : uint32_t blob_offset);
1413 : :
1414 : : /**
1415 : : * GITypelibHashBuilder:
1416 : : *
1417 : : * TODO
1418 : : *
1419 : : * Since: 2.80
1420 : : */
1421 : : typedef struct _GITypelibHashBuilder GITypelibHashBuilder;
1422 : :
1423 : : GITypelibHashBuilder * gi_typelib_hash_builder_new (void);
1424 : :
1425 : : void gi_typelib_hash_builder_add_string (GITypelibHashBuilder *builder, const char *str, uint16_t value);
1426 : :
1427 : : gboolean gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder);
1428 : :
1429 : : uint32_t gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder);
1430 : :
1431 : : void gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, uint8_t* mem, uint32_t size);
1432 : :
1433 : : void gi_typelib_hash_builder_destroy (GITypelibHashBuilder *builder);
1434 : :
1435 : : uint16_t gi_typelib_hash_search (uint8_t* memory, const char *str, uint32_t n_entries);
1436 : :
1437 : :
1438 : : G_END_DECLS
|