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 : : inline gboolean
202 : : _blob_is_registered_type (GITypelibBlobType blob_type)
203 : : {
204 [ + + ]: 2991 : switch (blob_type)
205 : : {
206 : 698 : 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 : 698 : return TRUE;
213 : 2293 : default:
214 : 2293 : 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 : : * @reserved: Reserved for future use.
602 : : * @reserved2: Reserved for future use.
603 : : *
604 : : * TODO
605 : : *
606 : : * Since: 2.80
607 : : */
608 : : typedef struct {
609 : : uint16_t blob_type; /* 1 */
610 : :
611 : : uint16_t deprecated : 1;
612 : : uint16_t setter : 1;
613 : : uint16_t getter : 1;
614 : : uint16_t constructor : 1;
615 : : uint16_t wraps_vfunc : 1;
616 : : uint16_t throws : 1;
617 : : uint16_t index :10;
618 : : /* Note the bits above need to match CommonBlob
619 : : * and are thus exhausted, extend things using
620 : : * the reserved block below. */
621 : :
622 : : uint32_t name;
623 : : uint32_t symbol;
624 : : uint32_t signature;
625 : :
626 : : uint16_t is_static : 1;
627 : : uint16_t reserved : 15;
628 : : uint16_t reserved2 : 16;
629 : : } FunctionBlob;
630 : :
631 : : /**
632 : : * CallbackBlob:
633 : : * @blob_type: TODO
634 : : * @deprecated: TODO
635 : : * @reserved: Reserved for future use.
636 : : * @name: TODO
637 : : * @signature: Offset of the #SignatureBlob describing the parameter types and
638 : : * the return value type.
639 : : *
640 : : * TODO
641 : : *
642 : : * Since: 2.80
643 : : */
644 : : typedef struct {
645 : : uint16_t blob_type; /* 2 */
646 : :
647 : : uint16_t deprecated : 1;
648 : : uint16_t reserved :15;
649 : : uint32_t name;
650 : : uint32_t signature;
651 : : } CallbackBlob;
652 : :
653 : : /**
654 : : * InterfaceTypeBlob:
655 : : * @pointer: Whether this type represents an indirection
656 : : * @reserved: Reserved for future use.
657 : : * @tag: A #GITypeTag
658 : : * @reserved2: Reserved for future use.
659 : : * @interface: Index of the directory entry for the interface.
660 : : *
661 : : * If the interface is an enum of flags type, is_pointer is 0, otherwise it is 1.
662 : : *
663 : : * Since: 2.80
664 : : */
665 : : typedef struct {
666 : : uint8_t pointer :1;
667 : : uint8_t reserved :2;
668 : : uint8_t tag :5;
669 : : uint8_t reserved2;
670 : : uint16_t interface;
671 : : } InterfaceTypeBlob;
672 : :
673 : : /**
674 : : * ArrayTypeDimension:
675 : : * @length: TODO
676 : : * @size: TODO
677 : : *
678 : : * TODO
679 : : *
680 : : * Since: 2.80
681 : : */
682 : : typedef union {
683 : : uint16_t length;
684 : : uint16_t size;
685 : : } ArrayTypeDimension;
686 : :
687 : : /**
688 : : * ArrayTypeBlob:
689 : : * @pointer: TODO
690 : : * @reserved: Reserved for future use.
691 : : * @tag: TODO
692 : : * @zero_terminated: Indicates that the array must be terminated by a suitable
693 : : * #NULL value.
694 : : * @has_length: Indicates that length points to a parameter specifying the
695 : : * length of the array. If both has_length and zero_terminated are set, the
696 : : * convention is to pass -1 for the length if the array is zero-terminated.
697 : : * @has_size: Indicates that size is the fixed size of the array.
698 : : * @array_type: Indicates whether this is a C array, GArray, GPtrArray, or
699 : : * GByteArray. If something other than a C array, the length and element
700 : : * size are implicit in the structure.
701 : : * @reserved2: Reserved for future use.
702 : : * @dimensions: TODO
703 : : * @type: TODO
704 : : *
705 : : * TODO
706 : : *
707 : : * Since: 2.80
708 : : */
709 : : typedef struct {
710 : : uint16_t pointer :1;
711 : : uint16_t reserved :2;
712 : : uint16_t tag :5;
713 : :
714 : : uint16_t zero_terminated :1;
715 : : uint16_t has_length :1;
716 : : uint16_t has_size :1;
717 : : uint16_t array_type :2;
718 : : uint16_t reserved2 :3;
719 : :
720 : : ArrayTypeDimension dimensions;
721 : :
722 : : SimpleTypeBlob type;
723 : : } ArrayTypeBlob;
724 : :
725 : : /**
726 : : * ParamTypeBlob:
727 : : * @pointer: TODO
728 : : * @reserved: Reserved for future use.
729 : : * @tag: TODO
730 : : * @reserved2: Reserved for future use.
731 : : * @n_types: The number of parameter types to follow.
732 : : * @type: Describes the type of the list elements.
733 : : *
734 : : * TODO
735 : : *
736 : : * Since: 2.80
737 : : */
738 : : typedef struct {
739 : : uint8_t pointer :1;
740 : : uint8_t reserved :2;
741 : : uint8_t tag :5;
742 : :
743 : : uint8_t reserved2;
744 : : uint16_t n_types;
745 : :
746 : : SimpleTypeBlob type[];
747 : : } ParamTypeBlob;
748 : :
749 : : /**
750 : : * ErrorTypeBlob:
751 : : * @pointer: TODO
752 : : * @reserved: TODO
753 : : * @tag: TODO
754 : : * @reserved2: TODO
755 : : * @n_domains: TODO: must be 0
756 : : * @domains: TODO
757 : : *
758 : : * TODO
759 : : *
760 : : * Since: 2.80
761 : : */
762 : : typedef struct {
763 : : uint8_t pointer :1;
764 : : uint8_t reserved :2;
765 : : uint8_t tag :5;
766 : :
767 : : uint8_t reserved2;
768 : :
769 : : uint16_t n_domains; /* Must be 0 */
770 : : uint16_t domains[];
771 : : } ErrorTypeBlob;
772 : :
773 : : /**
774 : : * ValueBlob:
775 : : * @deprecated: Whether this value is deprecated
776 : : * @unsigned_value: if set, value is a 32-bit unsigned integer cast to int32_t
777 : : * @reserved: Reserved for future use.
778 : : * @name: Name of blob
779 : : * @value: The numerical value
780 : : *
781 : : * Values commonly occur in enums and flags.
782 : : *
783 : : * Since: 2.80
784 : : */
785 : : typedef struct {
786 : : uint32_t deprecated : 1;
787 : : uint32_t unsigned_value : 1;
788 : : uint32_t reserved :30;
789 : : uint32_t name;
790 : : int32_t value;
791 : : } ValueBlob;
792 : :
793 : : /**
794 : : * FieldBlob:
795 : : * @name: The name of the field.
796 : : * @readable: TODO
797 : : * @writable: How the field may be accessed.
798 : : * @has_embedded_type: An anonymous type follows the FieldBlob.
799 : : * @reserved: Reserved for future use.
800 : : * @bits: If this field is part of a bitfield, the number of bits which it
801 : : * uses, otherwise 0.
802 : : * @struct_offset: The offset of the field in the struct. The value 0xFFFF
803 : : * indicates that the struct offset is unknown.
804 : : * @reserved2: Reserved for future use.
805 : : * @type: The type of the field.
806 : : *
807 : : * TODO
808 : : *
809 : : * Since: 2.80
810 : : */
811 : : typedef struct {
812 : : uint32_t name;
813 : :
814 : : uint8_t readable :1;
815 : : uint8_t writable :1;
816 : : uint8_t has_embedded_type :1;
817 : : uint8_t reserved :5;
818 : : uint8_t bits;
819 : :
820 : : uint16_t struct_offset;
821 : :
822 : : uint32_t reserved2;
823 : :
824 : : SimpleTypeBlob type;
825 : : } FieldBlob;
826 : :
827 : : /**
828 : : * RegisteredTypeBlob:
829 : : * @blob_type: TODO
830 : : * @deprecated: TODO
831 : : * @unregistered: TODO
832 : : * @reserved: Reserved for future use.
833 : : * @name: TODO
834 : : * @gtype_name: The name under which the type is registered with GType.
835 : : * @gtype_init: The symbol name of the get_type<!-- -->() function which registers the
836 : : * type.
837 : : *
838 : : * TODO
839 : : *
840 : : * Since: 2.80
841 : : */
842 : : typedef struct {
843 : : uint16_t blob_type;
844 : : uint16_t deprecated : 1;
845 : : uint16_t unregistered : 1;
846 : : uint16_t reserved :14;
847 : : uint32_t name;
848 : :
849 : : uint32_t gtype_name;
850 : : uint32_t gtype_init;
851 : : } RegisteredTypeBlob;
852 : :
853 : : /**
854 : : * StructBlob:
855 : : * @blob_type: #BLOB_TYPE_STRUCT
856 : : * @deprecated: Whether this structure is deprecated
857 : : * @unregistered: If this is set, the type is not registered with GType.
858 : : * @is_gtype_struct: Whether this structure is the class or interface layout
859 : : * for a GObject
860 : : * @alignment: The byte boundary that the struct is aligned to in memory
861 : : * @foreign: If the type is foreign, eg if it's expected to be overridden by
862 : : * a native language binding instead of relying of introspected bindings.
863 : : * @reserved: Reserved for future use.
864 : : * @name: TODO
865 : : * @gtype_name: String name of the associated #GType
866 : : * @gtype_init: String naming the symbol which gets the runtime #GType
867 : : * @size: The size of the struct in bytes.
868 : : * @n_fields: TODO
869 : : * @n_methods: TODO
870 : : * @copy_func: String pointing to a function which can be called to copy
871 : : * the contents of this struct type
872 : : * @free_func: String pointing to a function which can be called to free
873 : : * the contents of this struct type
874 : : *
875 : : * TODO
876 : : *
877 : : * Since: 2.80
878 : : */
879 : : typedef struct {
880 : : uint16_t blob_type;
881 : :
882 : : uint16_t deprecated : 1;
883 : : uint16_t unregistered : 1;
884 : : uint16_t is_gtype_struct : 1;
885 : : uint16_t alignment : 6;
886 : : uint16_t foreign : 1;
887 : : uint16_t reserved : 6;
888 : :
889 : : uint32_t name;
890 : :
891 : : uint32_t gtype_name;
892 : : uint32_t gtype_init;
893 : :
894 : : uint32_t size;
895 : :
896 : : uint16_t n_fields;
897 : : uint16_t n_methods;
898 : :
899 : : uint32_t copy_func;
900 : : uint32_t free_func;
901 : : } StructBlob;
902 : :
903 : : /**
904 : : * UnionBlob:
905 : : * @blob_type: TODO
906 : : * @deprecated: TODO
907 : : * @unregistered: If this is set, the type is not registered with GType.
908 : : * @discriminated: Is set if the union is discriminated
909 : : * @alignment: The byte boundary that the union is aligned to in memory
910 : : * @reserved: Reserved for future use.
911 : : * @name: TODO
912 : : * @gtype_name: String name of the associated #GType
913 : : * @gtype_init: String naming the symbol which gets the runtime #GType
914 : : * @size: TODO
915 : : * @n_fields: Length of the arrays
916 : : * @n_functions: TODO
917 : : * @copy_func: String pointing to a function which can be called to copy
918 : : * the contents of this union type
919 : : * @free_func: String pointing to a function which can be called to free
920 : : * the contents of this union type
921 : : * @discriminator_offset: Offset from the beginning of the union where the
922 : : * discriminator of a discriminated union is located. The value 0xFFFF
923 : : * indicates that the discriminator offset is unknown.
924 : : * @discriminator_type: Type of the discriminator
925 : : *
926 : : * TODO
927 : : *
928 : : * Since: 2.80
929 : : */
930 : : typedef struct {
931 : : uint16_t blob_type;
932 : : uint16_t deprecated : 1;
933 : : uint16_t unregistered : 1;
934 : : uint16_t discriminated : 1;
935 : : uint16_t alignment : 6;
936 : : uint16_t reserved : 7;
937 : : uint32_t name;
938 : :
939 : : uint32_t gtype_name;
940 : : uint32_t gtype_init;
941 : :
942 : : uint32_t size;
943 : :
944 : : uint16_t n_fields;
945 : : uint16_t n_functions;
946 : :
947 : : uint32_t copy_func;
948 : : uint32_t free_func;
949 : :
950 : : int32_t discriminator_offset;
951 : : SimpleTypeBlob discriminator_type;
952 : : } UnionBlob;
953 : :
954 : : /**
955 : : * EnumBlob:
956 : : * @blob_type: TODO
957 : : * @deprecated: TODO
958 : : * @unregistered: If this is set, the type is not registered with GType.
959 : : * @storage_type: The tag of the type used for the enum in the C ABI
960 : : * (will be a signed or unsigned integral type)
961 : : * @reserved: Reserved for future use.
962 : : * @name: TODO
963 : : * @gtype_name: String name of the associated #GType
964 : : * @gtype_init: String naming the symbol which gets the runtime #GType
965 : : * @n_values: The length of the values array.
966 : : * @n_methods: The length of the methods array.
967 : : * @error_domain: String naming the #GError domain this enum is associated with
968 : : * @values: TODO
969 : : *
970 : : * TODO
971 : : *
972 : : * Since: 2.80
973 : : */
974 : : typedef struct {
975 : : uint16_t blob_type;
976 : :
977 : : uint16_t deprecated : 1;
978 : : uint16_t unregistered : 1;
979 : : uint16_t storage_type : 5;
980 : : uint16_t reserved : 9;
981 : :
982 : : uint32_t name;
983 : :
984 : : uint32_t gtype_name;
985 : : uint32_t gtype_init;
986 : :
987 : : uint16_t n_values;
988 : : uint16_t n_methods;
989 : :
990 : : uint32_t error_domain;
991 : :
992 : : ValueBlob values[];
993 : : } EnumBlob;
994 : :
995 : : #define ACCESSOR_SENTINEL 0x3ff
996 : :
997 : : /**
998 : : * PropertyBlob:
999 : : * @name: The name of the property.
1000 : : * @deprecated: TODO
1001 : : * @readable: TODO
1002 : : * @writable: TODO
1003 : : * @construct: TODO
1004 : : * @construct_only: The ParamFlags used when registering the property.
1005 : : * @transfer_ownership: When writing, the type containing the property takes
1006 : : * ownership of the value. When reading, the returned value needs to be
1007 : : * released by the caller.
1008 : : * @transfer_container_ownership: For container types indicates that the
1009 : : * ownership of the container, but not of its contents, is transferred.
1010 : : * This is typically the case when reading lists of statically allocated
1011 : : * things.
1012 : : * @setter: the index of the setter function for this property, if @writable
1013 : : * is set; if the method is not known, the value will be set to %ACCESSOR_SENTINEL
1014 : : * @getter: ths index of the getter function for this property, if @readable
1015 : : * is set; if the method is not known, the value will be set to %ACCESSOR_SENTINEL
1016 : : * @reserved: Reserved for future use.
1017 : : * @reserved2: Reserved for future use.
1018 : : * @type: Describes the type of the property.
1019 : : *
1020 : : * TODO
1021 : : *
1022 : : * Since: 2.80
1023 : : */
1024 : : typedef struct {
1025 : : uint32_t name;
1026 : :
1027 : : uint32_t deprecated : 1;
1028 : : uint32_t readable : 1;
1029 : : uint32_t writable : 1;
1030 : : uint32_t construct : 1;
1031 : : uint32_t construct_only : 1;
1032 : : uint32_t transfer_ownership : 1;
1033 : : uint32_t transfer_container_ownership : 1;
1034 : : uint32_t setter :10;
1035 : : uint32_t getter :10;
1036 : : uint32_t reserved : 5;
1037 : :
1038 : : uint32_t reserved2;
1039 : :
1040 : : SimpleTypeBlob type;
1041 : : } PropertyBlob;
1042 : :
1043 : : /**
1044 : : * SignalBlob:
1045 : : * @deprecated: TODO
1046 : : * @run_first: TODO
1047 : : * @run_last: TODO
1048 : : * @run_cleanup: TODO
1049 : : * @no_recurse: TODO
1050 : : * @detailed: TODO
1051 : : * @action: TODO
1052 : : * @no_hooks: The flags used when registering the signal.
1053 : : * @has_class_closure: Set if the signal has a class closure.
1054 : : * @true_stops_emit: Whether the signal has true-stops-emit semantics
1055 : : * @reserved: Reserved for future use.
1056 : : * @class_closure: The index of the class closure in the list of virtual
1057 : : * functions of the object or interface on which the signal is defined.
1058 : : * @name: The name of the signal.
1059 : : * @reserved2: Reserved for future use.
1060 : : * @signature: Offset of the SignatureBlob describing the parameter types
1061 : : * and the return value type.
1062 : : *
1063 : : * TODO
1064 : : *
1065 : : * Since: 2.80
1066 : : */
1067 : : typedef struct {
1068 : : uint16_t deprecated : 1;
1069 : : uint16_t run_first : 1;
1070 : : uint16_t run_last : 1;
1071 : : uint16_t run_cleanup : 1;
1072 : : uint16_t no_recurse : 1;
1073 : : uint16_t detailed : 1;
1074 : : uint16_t action : 1;
1075 : : uint16_t no_hooks : 1;
1076 : : uint16_t has_class_closure : 1;
1077 : : uint16_t true_stops_emit : 1;
1078 : : uint16_t reserved : 6;
1079 : :
1080 : : uint16_t class_closure;
1081 : :
1082 : : uint32_t name;
1083 : :
1084 : : uint32_t reserved2;
1085 : :
1086 : : uint32_t signature;
1087 : : } SignalBlob;
1088 : :
1089 : : /**
1090 : : * VFuncBlob:
1091 : : * @name: The name of the virtual function.
1092 : : * @must_chain_up: If set, every implementation of this virtual function must
1093 : : * chain up to the implementation of the parent class.
1094 : : * @must_be_implemented: If set, every derived class must override this virtual
1095 : : * function.
1096 : : * @must_not_be_implemented: If set, derived class must not override this
1097 : : * virtual function.
1098 : : * @class_closure: Set if this virtual function is the class closure of a
1099 : : * signal.
1100 : : * @throws: This is now additionally stored in the #SignatureBlob. (deprecated)
1101 : : * @reserved: Reserved for future use.
1102 : : * @signal: The index of the signal in the list of signals of the object or
1103 : : * interface to which this virtual function belongs.
1104 : : * @struct_offset: The offset of the function pointer in the class struct.
1105 : : * The value 0xFFFF indicates that the struct offset is unknown.
1106 : : * @invoker: If a method invoker for this virtual exists, this is the offset
1107 : : * in the class structure of the method. If no method is known, this value
1108 : : * will be 0x3ff.
1109 : : * @reserved2: Reserved for future use.
1110 : : * @reserved3: Reserved for future use.
1111 : : * @signature: Offset of the SignatureBlob describing the parameter types and
1112 : : * the return value type.
1113 : : *
1114 : : * TODO
1115 : : *
1116 : : * Since: 2.80
1117 : : */
1118 : : typedef struct {
1119 : : uint32_t name;
1120 : :
1121 : : uint16_t must_chain_up : 1;
1122 : : uint16_t must_be_implemented : 1;
1123 : : uint16_t must_not_be_implemented : 1;
1124 : : uint16_t class_closure : 1;
1125 : : uint16_t throws : 1;
1126 : : uint16_t reserved :11;
1127 : : uint16_t signal;
1128 : :
1129 : : uint16_t struct_offset;
1130 : : uint16_t invoker : 10; /* Number of bits matches @index in FunctionBlob */
1131 : : uint16_t reserved2 : 6;
1132 : :
1133 : : uint32_t reserved3;
1134 : : uint32_t signature;
1135 : : } VFuncBlob;
1136 : :
1137 : : /**
1138 : : * ObjectBlob:
1139 : : * @blob_type: #BLOB_TYPE_OBJECT
1140 : : * @deprecated: whether the type is deprecated
1141 : : * @abstract: whether the type can be instantiated
1142 : : * @fundamental: this object is not a GObject derived type, instead it's
1143 : : * an additional fundamental type.
1144 : : * @final_: whether the type can be derived
1145 : : * @reserved: Reserved for future use.
1146 : : * @name: TODO
1147 : : * @gtype_name: String name of the associated #GType
1148 : : * @gtype_init: String naming the symbol which gets the runtime #GType
1149 : : * @parent: The directory index of the parent type. This is only set for
1150 : : * objects. If an object does not have a parent, it is zero.
1151 : : * @gtype_struct: TODO
1152 : : * @n_interfaces: TODO
1153 : : * @n_fields: TODO
1154 : : * @n_properties: TODO
1155 : : * @n_methods: TODO
1156 : : * @n_signals: TODO
1157 : : * @n_vfuncs: TODO
1158 : : * @n_constants: The lengths of the arrays.Up to 16bits of padding may be
1159 : : * inserted between the arrays to ensure that they start on a 32bit
1160 : : * boundary.
1161 : : * @n_field_callbacks: The number of n_fields which are also callbacks.
1162 : : * This is used to calculate the fields section size in constant time.
1163 : : * @ref_func: String pointing to a function which can be called to increase
1164 : : * the reference count for an instance of this object type.
1165 : : * @unref_func: String pointing to a function which can be called to decrease
1166 : : * the reference count for an instance of this object type.
1167 : : * @set_value_func: String pointing to a function which can be called to
1168 : : * convert a pointer of this object to a GValue
1169 : : * @get_value_func: String pointing to a function which can be called to
1170 : : * convert extract a pointer to this object from a GValue
1171 : : * @reserved3: Reserved for future use.
1172 : : * @reserved4: Reserved for future use.
1173 : : * @interfaces: An array of indices of directory entries for the implemented
1174 : : * interfaces.
1175 : : *
1176 : : * TODO
1177 : : *
1178 : : * Since: 2.80
1179 : : */
1180 : : typedef struct {
1181 : : uint16_t blob_type; /* 7 */
1182 : : uint16_t deprecated : 1;
1183 : : uint16_t abstract : 1;
1184 : : uint16_t fundamental : 1;
1185 : : uint16_t final_ : 1;
1186 : : uint16_t reserved :12;
1187 : : uint32_t name;
1188 : :
1189 : : uint32_t gtype_name;
1190 : : uint32_t gtype_init;
1191 : :
1192 : : uint16_t parent;
1193 : : uint16_t gtype_struct;
1194 : :
1195 : : uint16_t n_interfaces;
1196 : : uint16_t n_fields;
1197 : : uint16_t n_properties;
1198 : : uint16_t n_methods;
1199 : : uint16_t n_signals;
1200 : : uint16_t n_vfuncs;
1201 : : uint16_t n_constants;
1202 : : uint16_t n_field_callbacks;
1203 : :
1204 : : uint32_t ref_func;
1205 : : uint32_t unref_func;
1206 : : uint32_t set_value_func;
1207 : : uint32_t get_value_func;
1208 : :
1209 : : uint32_t reserved3;
1210 : : uint32_t reserved4;
1211 : :
1212 : : uint16_t interfaces[];
1213 : : } ObjectBlob;
1214 : :
1215 : : /**
1216 : : * InterfaceBlob:
1217 : : * @blob_type: TODO
1218 : : * @deprecated: TODO
1219 : : * @reserved: Reserved for future use.
1220 : : * @name: TODO
1221 : : * @gtype_name: TODO
1222 : : * @gtype_init: TODO
1223 : : * @gtype_struct: Name of the interface "class" C structure
1224 : : * @n_prerequisites: Number of prerequisites
1225 : : * @n_properties: Number of properties
1226 : : * @n_methods: Number of methods
1227 : : * @n_signals: Number of signals
1228 : : * @n_vfuncs: Number of virtual functions
1229 : : * @n_constants: The lengths of the arrays. Up to 16bits of padding may be
1230 : : * inserted between the arrays to ensure that they start on a 32bit
1231 : : * boundary.
1232 : : * @padding: TODO
1233 : : * @reserved2: Reserved for future use.
1234 : : * @reserved3: Reserved for future use.
1235 : : * @prerequisites: An array of indices of directory entries for required
1236 : : * interfaces.
1237 : : *
1238 : : * TODO
1239 : : *
1240 : : * Since: 2.80
1241 : : */
1242 : : typedef struct {
1243 : : uint16_t blob_type;
1244 : : uint16_t deprecated : 1;
1245 : : uint16_t reserved :15;
1246 : : uint32_t name;
1247 : :
1248 : : uint32_t gtype_name;
1249 : : uint32_t gtype_init;
1250 : : uint16_t gtype_struct;
1251 : :
1252 : : uint16_t n_prerequisites;
1253 : : uint16_t n_properties;
1254 : : uint16_t n_methods;
1255 : : uint16_t n_signals;
1256 : : uint16_t n_vfuncs;
1257 : : uint16_t n_constants;
1258 : :
1259 : : uint16_t padding;
1260 : :
1261 : : uint32_t reserved2;
1262 : : uint32_t reserved3;
1263 : :
1264 : : uint16_t prerequisites[];
1265 : : } InterfaceBlob;
1266 : :
1267 : : /**
1268 : : * ConstantBlob:
1269 : : * @blob_type: TODO
1270 : : * @deprecated: TODO
1271 : : * @reserved: Reserved for future use.
1272 : : * @name: TODO
1273 : : * @type: The type of the value. In most cases this should be a numeric type
1274 : : * or string.
1275 : : * @size: The size of the value in bytes.
1276 : : * @offset: The offset of the value in the typelib.
1277 : : * @reserved2: Reserved for future use.
1278 : : *
1279 : : * TODO
1280 : : *
1281 : : * Since: 2.80
1282 : : */
1283 : : typedef struct {
1284 : : uint16_t blob_type;
1285 : : uint16_t deprecated : 1;
1286 : : uint16_t reserved :15;
1287 : : uint32_t name;
1288 : :
1289 : : SimpleTypeBlob type;
1290 : :
1291 : : uint32_t size;
1292 : : uint32_t offset;
1293 : :
1294 : : uint32_t reserved2;
1295 : : } ConstantBlob;
1296 : :
1297 : : /**
1298 : : * AttributeBlob:
1299 : : * @offset: The offset of the typelib entry to which this attribute refers.
1300 : : * Attributes are kept sorted by offset, so that the attributes of an
1301 : : * entry can be found by a binary search.
1302 : : * @name: The name of the attribute, a string.
1303 : : * @value: The value of the attribute (also a string)
1304 : : *
1305 : : * TODO
1306 : : *
1307 : : * Since: 2.80
1308 : : */
1309 : : typedef struct {
1310 : : uint32_t offset;
1311 : : uint32_t name;
1312 : : uint32_t value;
1313 : : } AttributeBlob;
1314 : :
1315 : : struct _GITypelib {
1316 : : /*< private >*/
1317 : : gatomicrefcount ref_count;
1318 : : const uint8_t *data; /* just a cached pointer to inside @bytes */
1319 : : size_t len;
1320 : : GBytes *bytes; /* (owned) */
1321 : : GList *modules;
1322 : : gboolean open_attempted;
1323 : : GPtrArray *library_paths; /* (element-type filename) (owned) (nullable) */
1324 : : };
1325 : :
1326 : : DirEntry *gi_typelib_get_dir_entry (GITypelib *typelib,
1327 : : uint16_t index);
1328 : :
1329 : : DirEntry *gi_typelib_get_dir_entry_by_name (GITypelib *typelib,
1330 : : const char *name);
1331 : :
1332 : : DirEntry *gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib,
1333 : : const char *gtype_name);
1334 : :
1335 : : DirEntry *gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib,
1336 : : GQuark error_domain);
1337 : :
1338 : : gboolean gi_typelib_matches_gtype_name_prefix (GITypelib *typelib,
1339 : : const char *gtype_name);
1340 : :
1341 : :
1342 : : /**
1343 : : * gi_typelib_get_string:
1344 : : * @typelib: TODO
1345 : : * @offset: TODO
1346 : : *
1347 : : * TODO
1348 : : *
1349 : : * Returns: TODO
1350 : : * Since: 2.80
1351 : : */
1352 : : #define gi_typelib_get_string(typelib,offset) ((const char*)&(typelib->data)[(offset)])
1353 : :
1354 : :
1355 : : /**
1356 : : * GITypelibError:
1357 : : * @GI_TYPELIB_ERROR_INVALID: the typelib is invalid
1358 : : * @GI_TYPELIB_ERROR_INVALID_HEADER: the typelib header is invalid
1359 : : * @GI_TYPELIB_ERROR_INVALID_DIRECTORY: the typelib directory is invalid
1360 : : * @GI_TYPELIB_ERROR_INVALID_ENTRY: a typelib entry is invalid
1361 : : * @GI_TYPELIB_ERROR_INVALID_BLOB: a typelib blob is invalid
1362 : : *
1363 : : * An error set while validating the #GITypelib
1364 : : *
1365 : : * Since: 2.80
1366 : : */
1367 : : typedef enum
1368 : : {
1369 : : GI_TYPELIB_ERROR_INVALID,
1370 : : GI_TYPELIB_ERROR_INVALID_HEADER,
1371 : : GI_TYPELIB_ERROR_INVALID_DIRECTORY,
1372 : : GI_TYPELIB_ERROR_INVALID_ENTRY,
1373 : : GI_TYPELIB_ERROR_INVALID_BLOB
1374 : : } GITypelibError;
1375 : :
1376 : : /**
1377 : : * GI_TYPELIB_ERROR:
1378 : : *
1379 : : * TODO
1380 : : *
1381 : : * Since: 2.80
1382 : : */
1383 : : #define GI_TYPELIB_ERROR (gi_typelib_error_quark ())
1384 : :
1385 : : GQuark gi_typelib_error_quark (void);
1386 : :
1387 : :
1388 : : GI_AVAILABLE_IN_ALL
1389 : : gboolean gi_typelib_validate (GITypelib *typelib,
1390 : : GError **error);
1391 : :
1392 : :
1393 : : /* defined in gibaseinfo.c */
1394 : : AttributeBlob *_attribute_blob_find_first (GIBaseInfo *info,
1395 : : uint32_t blob_offset);
1396 : :
1397 : : /**
1398 : : * GITypelibHashBuilder:
1399 : : *
1400 : : * TODO
1401 : : *
1402 : : * Since: 2.80
1403 : : */
1404 : : typedef struct _GITypelibHashBuilder GITypelibHashBuilder;
1405 : :
1406 : : GITypelibHashBuilder * gi_typelib_hash_builder_new (void);
1407 : :
1408 : : void gi_typelib_hash_builder_add_string (GITypelibHashBuilder *builder, const char *str, uint16_t value);
1409 : :
1410 : : gboolean gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder);
1411 : :
1412 : : uint32_t gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder);
1413 : :
1414 : : void gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, uint8_t* mem, uint32_t size);
1415 : :
1416 : : void gi_typelib_hash_builder_destroy (GITypelibHashBuilder *builder);
1417 : :
1418 : : uint16_t gi_typelib_hash_search (uint8_t* memory, const char *str, uint32_t n_entries);
1419 : :
1420 : :
1421 : : G_END_DECLS
|