removed enum GTypeFundamentals. use macros to provide the constant
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / gtype.sgml
1 <!-- ##### SECTION Title ##### -->
2 GType
3
4 <!-- ##### SECTION Short_Description ##### -->
5 The GLib Runtime type identification and management system
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 The GType API is the foundation of the GObject system.  It provides the
10 facilities for registering and managing all fundamental data types,
11 user-defined object and interface types.  Before using any GType
12 or GObject functions, g_type_init() must be called to initialize the
13 type system.
14 </para>
15 <para>
16 For type creation and registration purposes, all types fall into one of
17 two categories: static or dynamic.  Static types are never loaded or
18 unloaded at run-time as dynamic types may be.  Static types are created
19 with g_type_register_static() that gets type specific information passed
20 in via a #GTypeInfo structure.
21 Dynamic types are created with g_type_register_dynamic() which takes a
22 #GTypePlugin structure instead. The remaining type information (the
23 #GTypeInfo structure) is retrived during runtime through #GTypePlugin
24 and the g_type_plugin_*() API.
25 These registration functions are usually called only once from a 
26 function whose only purpose is to return the type identifier for a 
27 specific class.  Once the type (or class or interface) is registered,
28 it may be instantiated, inherited, or implemented depending on exactly
29 what sort of type it is.
30 There is also a third registration function for registering fundamental
31 types called g_type_register_fundamental() which requires both a #GTypeInfo
32 structure and a GTypeFundamentalInfo structure but it is seldom used
33 since most fundamental types are predefined rather than user-defined.
34 </para>
35
36 <!-- ##### SECTION See_Also ##### -->
37 <para>
38
39 </para>
40
41 <!-- ##### TYPEDEF GType ##### -->
42 <para>
43 A numerical value which represents the unique identifier of a registered
44 type.
45 </para>
46
47
48 <!-- ##### MACRO G_TYPE_FUNDAMENTAL ##### -->
49 <para>
50 Returns #TRUE if @type is a fundamental data type such as #G_TYPE_INT or
51 #G_TYPE_POINTER. Fundamental types are types that serve as fundaments for
52 the derived types, thus they are the roots of distinct inheritance hierarchies.
53 </para>
54
55 @type: A #GType value.
56
57
58 <!-- ##### MACRO G_TYPE_FUNDAMENTAL_MAX ##### -->
59 <para>
60 An integer constant that represents the number of identifiers reserved
61 for types that are assigned at compile-time.
62 </para>
63
64
65
66 <!-- ##### MACRO G_TYPE_FUNDAMENTAL_SHIFT ##### -->
67 <para>
68
69 </para>
70
71
72
73 <!-- ##### MACRO G_TYPE_IS_ABSTRACT ##### -->
74 <para>
75 Returns #TRUE if @type is an abstract type.  An abstract type can not be
76 instantiated and is normally used as an abstract base class for
77 derived classes.
78 </para>
79
80 @type: A #GType value.
81
82
83 <!-- ##### MACRO G_TYPE_IS_DERIVED ##### -->
84 <para>
85 Returns #TRUE if @type is derived (or in object-oriented terminology:
86 inherited) from another type (this holds true for all non-fundamental
87 types).
88 </para>
89
90 @type: A #GType value.
91
92
93 <!-- ##### MACRO G_TYPE_IS_FUNDAMENTAL ##### -->
94 <para>
95 Returns #TRUE if @type is a fundamental type.
96 </para>
97
98 @type: A #GType value.
99
100
101 <!-- ##### MACRO G_TYPE_IS_VALUE_TYPE ##### -->
102 <para>
103
104 </para>
105
106 @type: A #GType value.
107
108
109 <!-- ##### MACRO G_TYPE_HAS_VALUE_TABLE ##### -->
110 <para>
111
112 </para>
113
114 @type: 
115
116
117 <!-- ##### MACRO G_TYPE_IS_CLASSED ##### -->
118 <para>
119 Returns #TRUE if @type is a classed type.
120 </para>
121
122 @type: A #GType value.
123
124
125 <!-- ##### MACRO G_TYPE_IS_INSTANTIATABLE ##### -->
126 <para>
127 Returns #TRUE if @type can be instantiated.  Instantiation is the
128 process of creating an instance (object) of this type.
129 </para>
130
131 @type: A #GType value.
132
133
134 <!-- ##### MACRO G_TYPE_IS_DERIVABLE ##### -->
135 <para>
136 Returns #TRUE if @type is a derivable type.  A derivable type can
137 be used as the base class of a flat (single-level) class hierarchy.
138 </para>
139
140 @type: A #GType value.
141
142
143 <!-- ##### MACRO G_TYPE_IS_DEEP_DERIVABLE ##### -->
144 <para>
145 Returns #TRUE if @type is a deep derivable type.  A deep derivable type
146 can be used as the base class of a deep (multi-level) class hierarchy.
147 </para>
148
149 @type: A #GType value.
150
151
152 <!-- ##### MACRO G_TYPE_IS_INTERFACE ##### -->
153 <para>
154 Returns #TRUE if @type is an interface type.
155 Interface types are types that provide pure APIs, the implementation
156 of which is provided by another type (which is then said to conform
157 to the interface).  GLib interfaces are somewhat analogous to Java
158 interfaces and C++ classes containing only pure virtual functions.
159 </para>
160
161 @type: A #GType value.
162
163
164 <!-- ##### ENUM GTypeFundamentals ##### -->
165 <para>
166 The predefined identifiers of the reserved fundamental types.
167 </para>
168
169 @G_TYPE_INVALID:                Usually a return value indicating an error.
170 @G_TYPE_NONE:                   A synonym for the "void" type in C.
171 @G_TYPE_INTERFACE:              Root type of all interface types.
172 @G_TYPE_CHAR:                   Identifier for the built-in type "gchar".
173 @G_TYPE_UCHAR:                  Identifier for the built-in type "guchar".
174 @G_TYPE_BOOLEAN:                Identifier for the built-in type "gboolean".
175 @G_TYPE_INT:                    Identifier for the built-in type "gint".
176 @G_TYPE_UINT:                   Identifier for the built-in type "guint".
177 @G_TYPE_LONG:                   Identifier for the built-in type "glong".
178 @G_TYPE_ULONG:                  Identifier for the built-in type "gulong".
179 @G_TYPE_INT64: 
180 @G_TYPE_UINT64: 
181 @G_TYPE_ENUM:                   Identifier for the "#GEnum" type.
182 @G_TYPE_FLAGS:                  Identifier for the "#GFlags" type.
183 @G_TYPE_FLOAT:                  Identifier for the built-in type "gfloat".
184 @G_TYPE_DOUBLE:                 Identifier for the built-in type "gdouble".
185 @G_TYPE_STRING:                 Identifier for a pointer to a null-terminated string "gchar*".
186 @G_TYPE_POINTER:                Identifier for anonymous pointers "void*".
187 @G_TYPE_BOXED:                  Identifier for the "#GBoxed" type.
188 @G_TYPE_PARAM:                  Identifier for the "#GParam" type.
189 @G_TYPE_OBJECT:                 Identifier for the "#GObject" type.
190 @G_TYPE_RESERVED_BSE_FIRST:     First fundamental type ID reserved for BSE.
191 @G_TYPE_RESERVED_BSE_LAST:      Last fundamental type ID reserved for BSE.
192 @G_TYPE_RESERVED_LAST_FUNDAMENTAL: 
193 @G_TYPE_CONSTANT_TYPES: 
194 @G_TYPE_CLOSURE: 
195 @G_TYPE_VALUE: 
196 @G_TYPE_VALUE_ARRAY: 
197 @G_TYPE_GSTRING: 
198 @G_TYPE_PARAM_CHAR: 
199 @G_TYPE_PARAM_UCHAR: 
200 @G_TYPE_PARAM_BOOLEAN: 
201 @G_TYPE_PARAM_INT: 
202 @G_TYPE_PARAM_UINT: 
203 @G_TYPE_PARAM_LONG: 
204 @G_TYPE_PARAM_ULONG: 
205 @G_TYPE_PARAM_INT64: 
206 @G_TYPE_PARAM_UINT64: 
207 @G_TYPE_PARAM_UNICHAR: 
208 @G_TYPE_PARAM_ENUM: 
209 @G_TYPE_PARAM_FLAGS: 
210 @G_TYPE_PARAM_FLOAT: 
211 @G_TYPE_PARAM_DOUBLE: 
212 @G_TYPE_PARAM_STRING: 
213 @G_TYPE_PARAM_PARAM: 
214 @G_TYPE_PARAM_BOXED: 
215 @G_TYPE_PARAM_POINTER: 
216 @G_TYPE_PARAM_VALUE_ARRAY: 
217 @G_TYPE_PARAM_CLOSURE: 
218 @G_TYPE_PARAM_OBJECT: 
219
220 <!-- ##### STRUCT GTypeInterface ##### -->
221 <para>
222 An opaque structure used as the base of all interface types.
223 </para>
224
225
226 <!-- ##### STRUCT GTypeInstance ##### -->
227 <para>
228 An opaque structure used as the base of all type instances.
229 </para>
230
231
232 <!-- ##### STRUCT GTypeInfo ##### -->
233 <para>
234 This structure is used to provide the type system with the information
235 required to initialize and destruct (finalize) a type's class and
236 instances thereof.
237 The initialized structure is passed to the g_type_register_static() function
238 (or is copied into the provided #GTypeInfo structure in the
239 g_type_plugin_complete_type_info()). The type system will perform a deep
240 copy of this structure, so it's memory does not need to be persistent
241 across invocation of g_type_register_static().
242 </para>
243
244 @class_size:     Size of the class structure (required for interface, classed and instantiatable types).
245 @base_init:      Location of the base initialization function (optional).
246 @base_finalize:  Location of the base finalization function (optional).
247 @class_init:     Location of the class initialization function (optional, for classed and instantiatable types only).
248 @class_finalize: Location of the class finalization function (optional).
249 @class_data:     User-supplied data passed to the class init/finalize functions.
250 @instance_size:  Size of the instance (object) structure (required for instantiatable types only).
251 @n_preallocs:    Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
252 @instance_init:  Location of the instance initialization function (optional, for instantiatable types only).
253 @value_table:    A #GTypeValueTable function table for generic handling of GValues of this type (usualy only
254                  useful for fundamental types).
255
256 <!-- ##### STRUCT GTypeFundamentalInfo ##### -->
257 <para>
258 A structure that provides information to the type system which is
259 used specifically for managing fundamental types.  
260 </para>
261
262 @type_flags: 
263
264 <!-- ##### STRUCT GInterfaceInfo ##### -->
265 <para>
266 A structure that provides information to the type system which is
267 used specifically for managing interface types.
268 </para>
269
270 @interface_init:        Location of the function that initializes the interface.
271 @interface_finalize:    Location of the function that finalizes the interface.
272 @interface_data:        Location of user data passed to the @interface_init and
273                         @interface_finalize functions (optional).
274
275 <!-- ##### STRUCT GTypeValueTable ##### -->
276 <para>
277 The #GTypeValueTable provides the functions required by the #GValue implementation,
278 to serve as a container for values of a type.
279 </para>
280
281 @value_init:            Default initialize @values contents by poking values
282                         directly into the value-&gt;data array. The data array of
283                         the #GValue passed into this function was zero-filled
284                         with memset, so no care has to be taken to free any
285                         old contents. E.g. for the implementation of a string
286                         value that may never be NULL, the implementation might
287                         look like:
288 <msgtext><programlisting>
289 {
290   value-&gt;data[0].v_pointer = g_strdup ("");
291 }
292 </programlisting></msgtext>
293 @value_free:            Free any old contents that might be left in the
294                         data array of the passed in @value. No resources may
295                         remain allocated through the #GValue contents after
296                         this function returns. E.g. for our above string type:
297 <msgtext><programlisting>
298 {
299   /* only free strings without a specific flag for static storage */
300   if (!(value-&gt;data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
301     g_free (value-&gt;data[0].v_pointer);
302 }
303 </programlisting></msgtext>
304 @value_copy:            @dest_value is a #GValue with zero-filled data section
305                         and @src_value is a properly setup #GValue of same or
306                         derived type.
307                         The purpose of this function is to copy the contents of
308                         @src_value into @dest_value in a way, that even after
309                         @src_value has been freed, the contents of @dest_value
310                         remain valid. String type example:
311 <msgtext><programlisting>
312 {
313   dest_value-&gt;data[0].v_pointer = g_strdup (src_value-&gt;data[0].v_pointer);
314 }
315 </programlisting></msgtext>
316 @value_peek_pointer:    If the value contents fit into a pointer, such as objects
317                         or strings, return this pointer, so the caller can peek at
318                         the current contents. To extend on our above string example:
319 <msgtext><programlisting>
320 {
321   return value-&gt;data[0].v_pointer;
322 }
323 </programlisting></msgtext>
324 @collect_format:        A string format describing how to collect the contents of
325                         this value, bit-by-bit. Each character in the format represents
326                         an argument to be collected, the characters themselves indicate
327                         the type of the argument. Currently supported arguments are:
328 <msgtext><variablelist>
329   <varlistentry><term></term><listitem><para>
330         'i' - Integers. passed as collect_values[].v_int.
331   </para></listitem></varlistentry>
332   <varlistentry><term></term><listitem><para>
333         'l' - Longs. passed as collect_values[].v_long.
334   </para></listitem></varlistentry>
335   <varlistentry><term></term><listitem><para>
336         'd' - Doubles. passed as collect_values[].v_double.
337   </para></listitem></varlistentry>
338   <varlistentry><term></term><listitem><para>
339         'p' - Pointers. passed as collect_values[].v_pointer.
340   </para></listitem></varlistentry>
341 </variablelist></msgtext>
342                         It should be noted, that for variable argument list construction,
343                         ANSI C promotes every type smaller than an integer to an int, and
344                         floats to doubles. So for collection of short int or char, 'i'
345                         needs to be used, and for collection of floats 'd'.
346 @collect_value:         The collect_value() function is responsible for converting the
347                         values collected from a variable argument list into contents
348                         suitable for storage in a GValue. This function should setup
349                         @value similar to value_init(), e.g. for a string value that
350                         does not allow NULL pointers, it needs to either spew an error,
351                         or do an implicit conversion by storing an empty string.
352                         The @value passed in to this function has a zero-filled data
353                         array, so just like for @value_init it is guaranteed to not
354                         contain any old contents that might need freeing.
355                         @n_collect_values is exactly the string length of @collect_format,
356                         and @collect_values is an array of unions #GTypeCValue with
357                         length @n_collect_values, containing the collected values
358                         according to @collect_format.
359                         @collect_flags is an argument provided as a hint by the caller,
360                         which may contain the flag #G_VALUE_NOCOPY_CONTENTS indicating,
361                         that the collected value contents may be considered "static"
362                         for the duration of the #@value lifetime.
363                         Thus an extra copy of the contents stored in @collect_values is
364                         not required for assignment to @value.
365                         For our above string example, we continue with:
366 <msgtext><programlisting>
367 {
368   if (!collect_values[0].v_pointer)
369     value->data[0].v_pointer = g_strdup ("");
370   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
371     {
372       value-&gt;data[0].v_pointer = collect_values[0].v_pointer;
373       /* keep a flag for the value_free() implementation to not free this string */
374       value-&gt;data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
375     }
376   else
377     value-&gt;data[0].v_pointer = g_strdup (collect_values[0].v_pointer);
378
379   return NULL;
380 }
381 </programlisting></msgtext>
382                         It should be noted, that it is generally a bad idea to follow the
383                         #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to
384                         reentrancy requirements and reference count assertions performed
385                         by the GSignal code, reference counts should always be incremented
386                         for reference counted contents stored in the value-&gt;data array.
387                         To deviate from our string example for a moment, and taking a look
388                         at an exemplary implementation for collect_value() of #GObject:
389 <msgtext><programlisting>
390 {
391   if (collect_values[0].v_pointer)
392     {
393       GObject *object = G_OBJECT (collect_values[0].v_pointer);
394
395       /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
396       value-&gt;data[0].v_pointer = g_object_ref (object);
397       return NULL;
398     }
399   else
400     return g_strdup_printf ("Object passed as invalid NULL pointer");
401 }
402 </programlisting></msgtext>
403                         The reference count for valid objects is always incremented,
404                         regardless of @collect_flags. For invalid objects, the example
405                         returns a newly allocated string without altering @value.
406                         Upon success, collect_value() needs to return NULL, if however
407                         a malicious condition occurred, collect_value() may spew an
408                         error by returning a newly allocated non-NULL string, giving
409                         a suitable description of the error condition.
410                         The calling code makes no assumptions about the @value
411                         contents being valid upon error returns, @value
412                         is simply thrown away without further freeing. As such, it is
413                         a good idea to not allocate #GValue contents, prior to returning
414                         an error, however, collect_values() is not obliged to return
415                         a correctly setup @value for error returns, simply because
416                         any non-NULL return is considered a fatal condition so further
417                         program behaviour is undefined.
418 @lcopy_format:          Format description of the arguments to collect for @lcopy_value,
419                         analogous to @collect_format. Usually, @lcopy_format string consists
420                         only of 'p's to provide lcopy_value() with pointers to storage locations.
421 @lcopy_value:           This function is responsible for storing the @value contents into
422                         arguments passed through a variable argument list which got
423                         collected into @collect_values according to @lcopy_format.
424                         @n_collect_values equals the string length of @lcopy_format,
425                         and @collect_flags may contain #G_VALUE_NOCOPY_CONTENTS.
426                         In contrast to collect_value(), lcopy_value() is obliged to
427                         always properly support #G_VALUE_NOCOPY_CONTENTS.
428                         Similar to collect_value() the function may prematurely abort
429                         by returning a newly allocated string describing an error condition.
430                         To complete the string example:
431 <msgtext><programlisting>
432 {
433   gchar **string_p = collect_values[0].v_pointer;
434
435   if (!string_p)
436     return g_strdup_printf ("string location passed as NULL");
437
438   if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
439     *string_p = value-&gt;data[0].v_pointer;
440   else
441     *string_p = g_strdup (value-&gt;data[0].v_pointer);
442
443 }
444 </programlisting></msgtext>
445                         And an exemplary version of lcopy_value() for
446                         reference-counted types:
447 <msgtext><programlisting>
448 {
449   GObject **object_p = collect_values[0].v_pointer;
450
451   if (!object_p)
452     return g_strdup_printf ("object location passed as NULL");
453   if (!value-&gt;data[0].v_pointer)
454     *object_p = NULL;
455   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) /* always honour */
456     *object_p = value-&gt;data[0].v_pointer;
457   else
458     *object_p = g_object_ref (value-&gt;data[0].v_pointer);
459   return NULL;
460 }
461 </programlisting></msgtext>
462
463 <!-- ##### MACRO G_TYPE_FROM_INSTANCE ##### -->
464 <para>
465 Returns the type identifier from a given @instance structure.
466 </para>
467
468 @instance: Location of a valid #GTypeInstance structure.
469
470
471 <!-- ##### MACRO G_TYPE_FROM_CLASS ##### -->
472 <para>
473 Returns the type identifier from a given @class structure.
474 </para>
475
476 @g_class: Location of a valid #GTypeClass structure.
477
478
479 <!-- ##### MACRO G_TYPE_FROM_INTERFACE ##### -->
480 <para>
481 Returns the type identifier from a given @interface structure.
482 </para>
483
484 @g_iface: Location of a valid #GTypeInterface structure.
485
486
487 <!-- ##### MACRO G_TYPE_INSTANCE_GET_CLASS ##### -->
488 <para>
489 Returns the class structure of a given @instance, casted
490 to a specified anchestor type @g_type of the instance.
491 </para>
492
493 @instance:      Location of the #GTypeInstance structure.
494 @g_type:        The anchestor type of the class to be returned.
495 @c_type:        The corresponding C type of @g_Type.
496
497
498 <!-- ##### MACRO G_TYPE_INSTANCE_GET_INTERFACE ##### -->
499 <para>
500
501 </para>
502
503 @instance: 
504 @g_type: 
505 @c_type: 
506
507
508 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE ##### -->
509 <para>
510
511 </para>
512
513 @instance: 
514
515
516 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE_CAST ##### -->
517 <para>
518
519 </para>
520
521 @instance: 
522 @g_type: 
523 @c_type: 
524
525
526 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE_TYPE ##### -->
527 <para>
528
529 </para>
530
531 @instance: 
532 @g_type: 
533
534
535 <!-- ##### MACRO G_TYPE_CHECK_CLASS_CAST ##### -->
536 <para>
537
538 </para>
539
540 @g_class: 
541 @g_type: 
542 @c_type: 
543
544
545 <!-- ##### MACRO G_TYPE_CHECK_CLASS_TYPE ##### -->
546 <para>
547
548 </para>
549
550 @g_class: 
551 @g_type: 
552
553
554 <!-- ##### MACRO G_TYPE_CHECK_VALUE ##### -->
555 <para>
556
557 </para>
558
559 @value: 
560
561
562 <!-- ##### MACRO G_TYPE_CHECK_VALUE_TYPE ##### -->
563 <para>
564
565 </para>
566
567 @value: 
568 @g_type: 
569
570
571 <!-- ##### MACRO G_TYPE_FLAG_RESERVED_ID_BIT ##### -->
572 <para>
573
574 </para>
575
576
577
578 <!-- ##### FUNCTION g_type_init ##### -->
579 <para>
580 Prior to any use of the type system, g_type_init() has to be called to initialize
581 the type system and assorted other code portions (such as the various fundamental
582 type implementations or the signal system).
583 </para>
584
585 <!-- # Unused Parameters # -->
586 @debug_flags: Bitwise combination of #GTypeDebugFlags values for debugging purposes.
587
588
589 <!-- ##### ENUM GTypeDebugFlags ##### -->
590 <para>
591
592 </para>
593
594 @G_TYPE_DEBUG_NONE: 
595 @G_TYPE_DEBUG_OBJECTS: 
596 @G_TYPE_DEBUG_SIGNALS: 
597 @G_TYPE_DEBUG_MASK: 
598
599 <!-- ##### FUNCTION g_type_init_with_debug_flags ##### -->
600 <para>
601
602 </para>
603
604 @debug_flags: 
605
606
607 <!-- ##### FUNCTION g_type_name ##### -->
608 <para>
609 Return the unique name that is assigned to a type ID (this is the preferred method
610 to find out whether a specific type has been registered for the passed in ID yet).
611 </para>
612
613 @type:          Type to return name for.
614 @Returns:       Static type name or NULL.
615
616
617 <!-- ##### FUNCTION g_type_qname ##### -->
618 <para>
619 Return the corresponding quark of the type IDs name.
620 </para>
621
622 @type:    Type to return quark of type name for.
623 @Returns: The type names quark or 0.
624
625
626 <!-- ##### FUNCTION g_type_from_name ##### -->
627 <para>
628 Lookup the type ID from a given type name, returns 0 if no type has been registered under this name
629 (this is the preferred method to find out by name whether a specific type has been registered yet).
630 </para>
631
632 @name:    Type name to lookup.
633 @Returns: Corresponding type ID or 0.
634
635
636 <!-- ##### FUNCTION g_type_parent ##### -->
637 <para>
638 Return the direct parent type of the passed in type.
639 If the passed in type has no parent, i.e. is a fundamental type, 0 is returned.
640 </para>
641
642 @type:    The derived type.
643 @Returns: The parent type.
644
645
646 <!-- ##### FUNCTION g_type_depth ##### -->
647 <para>
648
649 </para>
650
651 @type: 
652 @Returns: 
653
654
655 <!-- ##### FUNCTION g_type_next_base ##### -->
656 <para>
657 Given a @leaf_type and a @root_type which is contained in its anchestry, return
658 the type that @root_type is the immediate parent of.
659 In other words, this function determines the type that is derived directly from
660 @root_type which is also a base class of @leaf_type.  Given a root type and a
661 leaf type, this function can be used to determine the types and order in which
662 the leaf type is descended from the root type.
663 </para>
664
665 @leaf_type:     Descendant of @root_type and the type to be returned.
666 @root_type:     Immediate parent of the returned type.
667 @Returns:       Immediate child of @root_type and anchestor of @leaf_type.
668
669
670 <!-- ##### FUNCTION g_type_is_a ##### -->
671 <para>
672 Check whether @type is a descendant of @is_a_type.
673 </para>
674
675 @type:      Type to check anchestry for.
676 @is_a_type: Possible anchestor of @type.
677 @Returns:   %TRUE if @type is_a @is_a_type holds true.
678
679
680 <!-- ##### FUNCTION g_type_class_ref ##### -->
681 <para>
682 Increments the reference count of the class structure belonging to
683 @type. This function will demand-create the class if it doesn't
684 exist already.
685 </para>
686
687 @type:    Type ID of a classed type.
688 @Returns: The #GTypeClass structure for the given type ID.
689
690
691 <!-- ##### FUNCTION g_type_class_peek ##### -->
692 <para>
693 This function is essentially the same as g_type_class_ref(), except that
694 the classes reference count isn't incremented. Therefore, this function
695 may return NULL if the class of the type passed in does not currently
696 exist (hasn't been referenced before).
697 </para>
698
699 @type:          Type ID of a classed type.
700 @Returns:       The #GTypeClass structure for the given type ID or NULL
701                 if the class does not currently exist.
702
703
704 <!-- ##### FUNCTION g_type_class_unref ##### -->
705 <para>
706 Decrements the reference count of the class structure being passed in.
707 Once the last reference count of a class has been released, classes
708 may be finalized by the type system, so further dereferencing of a
709 class pointer after g_type_class_unref() are invalid.
710 </para>
711
712 @g_class:       The #GTypeClass structure to unreference.
713
714
715 <!-- ##### FUNCTION g_type_class_peek_parent ##### -->
716 <para>
717 This is a convenience function, often needed in class intializers.
718 It essentially takes the immediate parent type of the class passed in,
719 and returns the class structure thereof. Since derived classes hold
720 a reference count on their parent classes as long as they are instantiated,
721 the returned class will always exist. This function is essentially
722 equivalent to:
723
724 <msgtext><programlisting>
725 g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)));
726 </programlisting></msgtext>
727
728 </para>
729
730 @g_class: The #GTypeClass structure to retrieve the parent class for.
731 @Returns: The parent class of @g_class.
732
733
734 <!-- ##### FUNCTION g_type_interface_peek ##### -->
735 <para>
736
737 </para>
738
739 @instance_class: 
740 @iface_type: 
741 @Returns: 
742
743
744 <!-- ##### FUNCTION g_type_interface_peek_parent ##### -->
745 <para>
746
747 </para>
748
749 @g_iface: 
750 @Returns: 
751
752
753 <!-- ##### FUNCTION g_type_children ##### -->
754 <para>
755 Return a newly allocated and 0 terminated array of type IDs, listing the
756 child types of @type. The return value has to be g_free()ed after use.
757 </para>
758
759 @type:       The parent type.
760 @n_children: Optional #guint pointer to contain the number of child types.
761 @Returns:    Newly allocated and 0 terminated array of child types.
762
763
764 <!-- ##### FUNCTION g_type_interfaces ##### -->
765 <para>
766 Return a newly allocated and 0 terminated array of type IDs, listing the
767 interface types that @type conforms to. The return value has to be
768 g_free()ed after use.
769 </para>
770
771 @type:         The type to list interface types for.
772 @n_interfaces: Optional #guint pointer to contain the number of interface types.
773 @Returns:      Newly allocated and 0 terminated array of interface types.
774
775
776 <!-- ##### FUNCTION g_type_set_qdata ##### -->
777 <para>
778
779 </para>
780
781 @type: 
782 @quark: 
783 @data: 
784
785
786 <!-- ##### FUNCTION g_type_get_qdata ##### -->
787 <para>
788
789 </para>
790
791 @type: 
792 @quark: 
793 @Returns: 
794
795
796 <!-- ##### FUNCTION g_type_query ##### -->
797 <para>
798
799 </para>
800
801 @type: 
802 @query: 
803
804
805 <!-- ##### STRUCT GTypeQuery ##### -->
806 <para>
807
808 </para>
809
810 @type: 
811 @type_name: 
812 @class_size: 
813 @instance_size: 
814
815 <!-- ##### USER_FUNCTION GBaseInitFunc ##### -->
816 <para>
817 A callback function used by the type system to do base initialization
818 of the class structures of derived types. It is called as part of the
819 initialization process of all derived classes and should reallocate
820 or reset all dynamic class members copied over from the parent class.
821 Therefore class members, e.g. strings, that are not sufficiently
822 handled by a plain memory copy of the parent class into the derived class
823 have to be altered. See GClassInitFunc() for a discussion of the class
824 intialization process.
825 </para>
826
827 @g_class: The #GTypeClass structure to initialize.
828
829
830 <!-- ##### USER_FUNCTION GBaseFinalizeFunc ##### -->
831 <para>
832 A callback function used by the type system to finalize those portions
833 of a derived types class structure that were setup from the corresponding
834 GBaseInitFunc() function. Class finalization basically works the inverse
835 way in which class intialization is performed.
836 See GClassInitFunc() for a discussion of the class intialization process.
837 </para>
838
839 @g_class: The #GTypeClass structure to finalize.
840
841
842 <!-- ##### USER_FUNCTION GClassInitFunc ##### -->
843 <para>
844 A callback function used by the type system to initialize the class
845 of a specific type. This function should initialize all static class
846 members.
847 The initialization process of a class involves:
848 <variablelist>
849   <varlistentry><term></term><listitem><para>
850         1 - Copying common members from the parent class over to the
851         derived class structure.
852   </para></listitem></varlistentry>
853   <varlistentry><term></term><listitem><para>
854         2 -  Zero initialization of the remaining members not copied
855         over from the parent class.
856   </para></listitem></varlistentry>
857   <varlistentry><term></term><listitem><para>
858         3 - Invocation of the GBaseInitFunc initializers of all parent
859         types and the class' type.
860   </para></listitem></varlistentry>
861   <varlistentry><term></term><listitem><para>
862         4 - Invocation of the class' GClassInitFunc initializer.
863   </para></listitem></varlistentry>
864 </variablelist>
865 Since derived classes are partially initialized through a memory copy
866 of the parent class, the general rule is that GBaseInitFunc() and
867 GBaseFinalizeFunc() should take care of necessary reinitialization
868 and release of those class members that were introduced by the type
869 that specified these GBaseInitFunc()/GBaseFinalizeFunc().
870 GClassInitFunc() should only care about intializing static
871 class members, while dynamic class members (such as allocated strings
872 or reference counted resources) are better handled by a GBaseInitFunc()
873 for this type, so proper initialization of the dynamic class members
874 are performed for class intialization of derived types as well.
875 An example may help to correspond the intend of the different class
876 initializers:
877
878 <msgtext><programlisting>
879 typedef struct {
880   GObjectClass parent_class;
881   gint         static_integer;
882   gchar       *dynamic_string;
883 } TypeAClass;
884 static void
885 type_a_base_class_init (TypeAClass *class)
886 {
887   class->dynamic_string = g_strdup ("some string");
888 }
889 static void
890 type_a_base_class_finalize (TypeAClass *class)
891 {
892   g_free (class->dynamic_string);
893 }
894 static void
895 type_a_class_init (TypeAClass *class)
896 {
897   class->static_integer = 42;
898 }
899
900 typedef struct {
901   TypeAClass   parent_class;
902   gfloat       static_float;
903   GString     *dynamic_gstring;
904 } TypeBClass;
905 static void
906 type_b_base_class_init (TypeBClass *class)
907 {
908   class->dynamic_gstring = g_string_new ("some other string);
909 }
910 static void
911 type_b_base_class_finalize (TypeBClass *class)
912 {
913   g_string_free (class->dynamic_gstring);
914 }
915 static void
916 type_b_class_init (TypeBClass *class)
917 {
918   class->static_float = 3.14159265358979323846;
919 }
920 </programlisting></msgtext>
921 Initialization of TypeBClass will first cause initialization of
922 TypeAClass (derived classes reference their parent classes, see
923 g_type_class_ref() on this).
924 Initialization of TypeAClass roughly involves zero-initializing its fields,
925 then calling its GBaseInitFunc() type_a_base_class_init() that allocates
926 its dynamic members (dynamic_string) and finally calling its GClassInitFunc()
927 type_a_class_init() to initialize its static members (static_integer).
928 The first step in the initialization process of TypeBClass is then
929 a plain memory copy of the contents of TypeAClass into TypeBClass and 
930 zero-initialization of the remaining fields in TypeBClass.
931 The dynamic members of TypeAClass within TypeBClass now need
932 reinitialization which is performed by calling type_a_base_class_init()
933 with an argument of TypeBClass.
934 After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init()
935 is called to allocate the dynamic members of TypeBClass (dynamic_gstring),
936 and finally the GClassInitFunc() of TypeBClass, type_b_class_init(),
937 is called to complete the initialization process with the static members
938 (static_float).
939 Corresponding finalization counter parts to the GBaseInitFunc() functions
940 have to be provided to release allocated resources at class finalization
941 time.
942 </para>
943
944 @g_class:       The #GTypeClass structure to initialize.
945 @class_data:    The @class_data member supplied via the #GTypeInfo structure.
946
947
948 <!-- ##### USER_FUNCTION GClassFinalizeFunc ##### -->
949 <para>
950 A callback function used by the type system to finalize a class.
951 This function is rarely needed, as dynamically allocated class resources
952 should be handled by GBaseInitFunc() and GBaseFinalizeFunc().
953 Also, specification of a GClassFinalizeFunc in the #GTypeInfo
954 structure of a static type is invalid, because classes of static types
955 will never be finalized (they are artificially kept alive when their
956 reference count drops to zero).
957 </para>
958
959 @g_class:       The #GTypeClass structure to finalize.
960 @class_data:    The @class_data member supplied via the #GTypeInfo structure.
961
962
963 <!-- ##### USER_FUNCTION GInstanceInitFunc ##### -->
964 <para>
965 A callback function used by the type system to initialize a new
966 instance of a type. This function initializes all instance members and
967 allocates any resources required by it.
968 Initialization of a derived instance involves calling all its parent
969 types instance initializers, therefore the class member of the instance
970 is altered during its initialization to always point to the class that
971 belongs to the type the current initializer was introduced for.
972 </para>
973
974 @instance:      The instance to initialize.
975 @g_class:       The class of the type the instance is created for.
976
977
978 <!-- ##### USER_FUNCTION GInterfaceInitFunc ##### -->
979 <para>
980 A callback function used by the type system to initialize a new
981 interface.  This function should initialize all internal data and
982 allocate any resources required by the interface.
983 </para>
984
985 @g_iface:       The interface structure to initialize.
986 @iface_data:    The @class_data supplied via the #GTypeInfo structure.
987
988
989 <!-- ##### USER_FUNCTION GInterfaceFinalizeFunc ##### -->
990 <para>
991 A callback function used by the type system to finalize an interface.
992 This function should destroy any internal data and release any resources
993 allocated by the corresponding GInterfaceInitFunc() function.
994 </para>
995
996 @g_iface:       The interface structure to finalize.
997 @iface_data:    The @class_data supplied via the #GTypeInfo structure.
998
999
1000 <!-- ##### USER_FUNCTION GTypeClassCacheFunc ##### -->
1001 <para>
1002
1003 </para>
1004
1005 @cache_data: 
1006 @g_class: 
1007 @Returns: 
1008
1009
1010 <!-- ##### ENUM GTypeFlags ##### -->
1011 <para>
1012 Bit masks used to check or determine characteristics of a type.
1013 </para>
1014
1015 @G_TYPE_FLAG_ABSTRACT:  Indicates an abstract type. No instances can be
1016                         created for an abstract type.
1017 @G_TYPE_FLAG_VALUE_ABSTRACT: 
1018
1019 <!-- ##### ENUM GTypeFundamentalFlags ##### -->
1020 <para>
1021 Bit masks used to check or determine specific characteristics of a
1022 fundamental type.
1023 </para>
1024
1025 @G_TYPE_FLAG_CLASSED:           Indicates a classed type.
1026 @G_TYPE_FLAG_INSTANTIATABLE:    Indicates an instantiable type (implies classed).
1027 @G_TYPE_FLAG_DERIVABLE:                 Indicates a flat derivable type.
1028 @G_TYPE_FLAG_DEEP_DERIVABLE:    Indicates a deep derivable type (implies derivable).
1029
1030 <!-- ##### FUNCTION g_type_register_static ##### -->
1031 <para>
1032 Registers @type_name as the name of a new static type derived from
1033 @parent_type.  The type system uses the information contained in the
1034 #GTypeInfo structure pointed to by @info to manage the type and its
1035 instances (if not abstract).  The value of @flags determines the nature
1036 (e.g. abstract or not) of the type.
1037 </para>
1038
1039 @parent_type:   Type which this type will be derived from.
1040 @type_name:     Null-terminated string used as the name of the new type.
1041 @info:          The #GTypeInfo structure for this type.
1042 @flags:                 Bitwise combination of #GTypeFlags values.
1043 @Returns:       The new type identifier.
1044
1045
1046 <!-- ##### FUNCTION g_type_register_dynamic ##### -->
1047 <para>
1048 Registers @type_name as the name of a new dynamic type derived from
1049 @parent_type.  The type system uses the information contained in the
1050 #GTypePlugin structure pointed to by @plugin to manage the type and its
1051 instances (if not abstract).  The value of @flags determines the nature
1052 (e.g. abstract or not) of the type.
1053 </para>
1054
1055 @parent_type:   Type which this type will be derived from.
1056 @type_name:     Null-terminated string used as the name of the new type.
1057 @plugin:        The #GTypePlugin structure to retrive the #GTypeInfo from.
1058 @flags:                 Bitwise combination of #GTypeFlags values.
1059 @Returns:       The new type identifier.
1060 <!-- # Unused Parameters # -->
1061 @Returns: #G_TYPE_INVALID if registration failed or the new type identifier.
1062
1063
1064 <!-- ##### FUNCTION g_type_register_fundamental ##### -->
1065 <para>
1066 Registers @type_id as the predefined identifier and @type_name as the
1067 name of a fundamental type.  The type system uses the information
1068 contained in the #GTypeInfo structure pointed to by @info and the 
1069 #GTypeFundamentalInfo structure pointed to by @finfo to manage the
1070 type and its instances.  The value of @flags determines additional
1071 characteristics of the fundamental type.
1072 </para>
1073
1074 @type_id:       A predefined #GTypeFundamentals value.
1075 @type_name:     Null-terminated string used as the name of the new type.
1076 @info:          The #GTypeInfo structure for this type.
1077 @finfo:                 The #GTypeFundamentalInfo structure for this type.
1078 @flags:                 Bitwise combination of #GTypeFlags values.
1079 @Returns:       The predefined type identifier.
1080
1081
1082 <!-- ##### FUNCTION g_type_add_interface_static ##### -->
1083 <para>
1084 Adds the static @interface_type to @instantiable_type.  The information
1085 contained in the #GTypeInterfaceInfo structure pointed to by @info
1086 is used to manage the relationship.
1087 </para>
1088
1089 @instance_type:          #GType value of an instantiable type.
1090 @interface_type: #GType value of an interface type.
1091 @info:           The #GInterfaceInfo structure for this
1092                  (@instance_type, @interface_type) combination.
1093
1094
1095 <!-- ##### FUNCTION g_type_add_interface_dynamic ##### -->
1096 <para>
1097 </para>
1098
1099 @instance_type: 
1100 @interface_type: 
1101 @plugin: 
1102
1103
1104 <!-- ##### FUNCTION g_type_interface_add_prerequisite ##### -->
1105 <para>
1106
1107 </para>
1108
1109 @interface_type: 
1110 @prerequisite_type: 
1111
1112
1113 <!-- ##### FUNCTION g_type_get_plugin ##### -->
1114 <para>
1115 Returns the the #GTypePlugin structure for @type or
1116 #NULL if @type does not have a #GTypePlugin structure.
1117 </para>
1118
1119 @type:          The #GType to retrive the plugin for.
1120 @Returns:       The corresponding plugin if @type is a dynamic type,
1121                 NULL otherwise.
1122
1123
1124 <!-- ##### FUNCTION g_type_interface_get_plugin ##### -->
1125 <para>
1126 </para>
1127
1128 @instance_type: 
1129 @implementation_type: 
1130 @Returns: 
1131
1132
1133 <!-- ##### FUNCTION g_type_fundamental_next ##### -->
1134 <para>
1135 Returns the next free fundamental type id which can be used to
1136 register a new fundamental type with g_type_register_fundamental().
1137 The returned type ID represents the highest currently registered
1138 fundamental type identifier.
1139
1140 </para>
1141
1142 @Returns: The nextmost fundamental type ID to be registered,
1143           or 0 if the type system ran out of fundamental type IDs.
1144
1145
1146 <!-- ##### FUNCTION g_type_fundamental ##### -->
1147 <para>
1148 Internal function, used to extract the fundamental type ID portion.
1149 use G_TYPE_FUNDAMENTAL() instead.
1150 </para>
1151
1152 @type_id: valid type ID
1153 @Returns: fundamental type ID
1154
1155
1156 <!-- ##### FUNCTION g_type_create_instance ##### -->
1157 <para>
1158 Creates and initializes an instance of @type if @type is valid and can
1159 be instantiated. The type system only performs basic allocation and
1160 structure setups for instances, actual instance creation should happen
1161 through functions supplied by the type's fundamental type implementation.
1162 So use of g_type_create_instance() is reserved for implementators of
1163 fundamental types only. E.g. instances of the #GObject hierarchy
1164 should be created via g_object_new() and <emphasis>never</emphasis>
1165 directly through g_type_create_instance() which doesn't handle
1166 things like singleton objects or object construction.
1167 Note: Do <emphasis>not</emphasis> use this function, unless you're
1168 implementing a fundamental type. Also language bindings should <emphasis>not</emphasis>
1169 use this function but g_object_new() instead.
1170 </para>
1171
1172 @type:    An instantiabtable type to create an instance for.
1173 @Returns: An allocated and initialized instance, subject to further
1174           treatment by the fundamental type implementation.
1175
1176
1177 <!-- ##### FUNCTION g_type_free_instance ##### -->
1178 <para>
1179 </para>
1180
1181 @instance: 
1182
1183
1184 <!-- ##### FUNCTION g_type_add_class_cache_func ##### -->
1185 <para>
1186
1187 </para>
1188
1189 @cache_data: 
1190 @cache_func: 
1191
1192
1193 <!-- ##### FUNCTION g_type_remove_class_cache_func ##### -->
1194 <para>
1195
1196 </para>
1197
1198 @cache_data: 
1199 @cache_func: 
1200
1201
1202 <!-- ##### FUNCTION g_type_class_unref_uncached ##### -->
1203 <para>
1204
1205 </para>
1206
1207 @g_class: 
1208
1209
1210 <!-- ##### FUNCTION g_type_value_table_peek ##### -->
1211 <para>
1212 Returns the location of the #GTypeValueTable associated with @type.
1213 <emphasis>Note, this function should only be used from source code
1214 that implements or has internal knowledge of the implementation of
1215 @type.</emphasis>
1216 </para>
1217
1218 @type:    A #GType value.
1219 @Returns: Location of the #GTypeValueTable associated with @type or
1220           #NULL if there is no #GTypeValueTable associated with @type.
1221
1222