PageRenderTime 86ms CodeModel.GetById 45ms RepoModel.GetById 0ms app.codeStats 0ms

/src/wrappers/gobject/library/g_type.e

http://github.com/tybor/Liberty
Specman e | 1237 lines | 13 code | 325 blank | 899 comment | 0 complexity | 95b31e373631511d0eb81f86914430af MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0
  1. indexing
  2. description: "GType - the GLib Runtime type identification and management system."
  3. copyright: "(C) 2006 Paolo Redaelli "
  4. license: "LGPL v2 or later"
  5. date: "$Date:$"
  6. revision: "$Revision:$"
  7. -- Description
  8. -- The GType API is the foundation of the GObject system. It
  9. -- provides the facilities for registering and managing all
  10. -- fundamental data types, user-defined object and interface
  11. -- types. Before using any GType or GObject functions,
  12. -- g_type_init() must be called to initialize the type
  13. -- system.
  14. -- For type creation and registration purposes, all types
  15. -- fall into one of two categories: static or dynamic. Static
  16. -- types are never loaded or unloaded at run-time as dynamic
  17. -- types may be. Static types are created with
  18. -- g_type_register_static() that gets type specific
  19. -- information passed in via a GTypeInfo structure. Dynamic
  20. -- types are created with g_type_register_dynamic() which
  21. -- takes a GTypePlugin structure instead. The remaining type
  22. -- information (the GTypeInfo structure) is retrieved during
  23. -- runtime through GTypePlugin and the g_type_plugin_*()
  24. -- API. These registration functions are usually called only
  25. -- once from a function whose only purpose is to return the
  26. -- type identifier for a specific class. Once the type (or
  27. -- class or interface) is registered, it may be instantiated,
  28. -- inherited, or implemented depending on exactly what sort
  29. -- of type it is. There is also a third registration function
  30. -- for registering fundamental types called
  31. -- g_type_register_fundamental() which requires both a
  32. -- GTypeInfo structure and a GTypeFundamentalInfo structure
  33. -- but it is seldom used since most fundamental types are
  34. -- predefined rather than user-defined.
  35. -- A final word about type names. Such an identifier needs to
  36. -- be at least three characters long. There is no upper
  37. -- length limit. The first character needs to be a letter
  38. -- (a-z or A-Z) or an underscore '_'. Subsequent characters
  39. -- can be letters, numbers or any of '-_+'.
  40. deferred class G_TYPE
  41. insert G_TYPE_EXTERNALS
  42. feature
  43. -- Note: in libglib 2.9.1 "typedef gulong GType;" (Paolo
  44. -- 2006-01-07)
  45. is_g_type (a_type_number: INTEGER): BOOLEAN is
  46. -- Is `a_type_number' a valid value for a g_type? (i.e. a
  47. -- type number that can be used for g_value_init()?
  48. do
  49. Result := (g_type_is_value_type (a_type_number)).to_boolean
  50. end
  51. -- #define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type))
  52. -- Returns the fundamental type which is the ancestor of type. Fundamental types are types that serve as fundaments for the derived types, thus they are the roots of distinct inheritance hierarchies.
  53. -- type : A GType value.
  54. -- G_TYPE_MAKE_FUNDAMENTAL()
  55. -- #define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
  56. -- Returns the type ID for the fundamental type number x. Use g_type_fundamental_next() instead of this macro to create new fundamental types.
  57. -- x : the fundamental type number.
  58. -- G_TYPE_IS_ABSTRACT()
  59. -- #define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))
  60. -- Returns TRUE if type is an abstract type. An abstract type can not be instantiated and is normally used as an abstract base class for derived classes.
  61. -- type : A GType value.
  62. -- G_TYPE_IS_DERIVED()
  63. -- #define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX)
  64. -- Returns TRUE if type is derived (or in object-oriented terminology: inherited) from another type (this holds true for all non-fundamental types).
  65. -- type : A GType value.
  66. -- G_TYPE_IS_FUNDAMENTAL()
  67. -- #define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX)
  68. -- Returns TRUE if type is a fundamental type.
  69. -- type : A GType value.
  70. -- G_TYPE_IS_VALUE_TYPE()
  71. -- #define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type))
  72. -- Returns TRUE if type is a value type which can be used for g_value_init().
  73. -- type : A GType value.
  74. -- G_TYPE_HAS_VALUE_TABLE()
  75. -- #define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL)
  76. -- Returns TRUE if type has a GTypeValueTable.
  77. -- type : A GType value.
  78. -- G_TYPE_IS_CLASSED()
  79. -- #define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))
  80. -- Returns TRUE if type is a classed type.
  81. -- type : A GType value.
  82. -- G_TYPE_IS_INSTANTIATABLE()
  83. -- #define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))
  84. -- Returns TRUE if type can be instantiated. Instantiation is the process of creating an instance (object) of this type.
  85. -- type : A GType value.
  86. -- G_TYPE_IS_DERIVABLE()
  87. -- #define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE))
  88. -- Returns TRUE if type is a derivable type. A derivable type can be used as the base class of a flat (single-level) class hierarchy.
  89. -- type : A GType value.
  90. -- G_TYPE_IS_DEEP_DERIVABLE()
  91. -- #define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))
  92. -- Returns TRUE if type is a deep derivable type. A deep derivable type can be used as the base class of a deep (multi-level) class hierarchy.
  93. -- type : A GType value.
  94. -- G_TYPE_IS_INTERFACE()
  95. -- #define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE)
  96. -- Returns TRUE if type is an interface type. Interface types are types that provide pure APIs, the implementation of which is provided by another type (which is then said to conform to the interface). GLib interfaces are somewhat analogous to Java interfaces and C++ classes containing only pure virtual functions, with the difference that GType interfaces are not derivable (but see g_type_interface_add_prerequisite() for an alternative).
  97. -- type : A GType value.
  98. -- GTypeInterface
  99. -- typedef struct {
  100. -- } GTypeInterface;
  101. -- An opaque structure used as the base of all interface types.
  102. -- GTypeInstance
  103. -- typedef struct {
  104. -- } GTypeInstance;
  105. -- An opaque structure used as the base of all type instances.
  106. -- GTypeClass
  107. -- typedef struct {
  108. -- } GTypeClass;
  109. -- An opaque structure used as the base of all classes.
  110. -- GTypeInfo
  111. -- typedef struct {
  112. -- /* interface types, classed types, instantiated types */
  113. -- guint16 class_size;
  114. -- GBaseInitFunc base_init;
  115. -- GBaseFinalizeFunc base_finalize;
  116. -- /* interface types, classed types, instantiated types */
  117. -- GClassInitFunc class_init;
  118. -- GClassFinalizeFunc class_finalize;
  119. -- gconstpointer class_data;
  120. -- /* instantiated types */
  121. -- guint16 instance_size;
  122. -- guint16 n_preallocs;
  123. -- GInstanceInitFunc instance_init;
  124. -- /* value handling */
  125. -- const GTypeValueTable *value_table;
  126. -- } GTypeInfo;
  127. -- This structure is used to provide the type system with the information required to initialize and destruct (finalize) a type's class and instances thereof. The initialized structure is passed to the g_type_register_static() function (or is copied into the provided GTypeInfo structure in the g_type_plugin_complete_type_info()). The type system will perform a deep copy of this structure, so it's memory does not need to be persistent across invocation of g_type_register_static().
  128. -- guint16 class_size; Size of the class structure (required for interface, classed and instantiatable types).
  129. -- GBaseInitFunc base_init; Location of the base initialization function (optional).
  130. -- GBaseFinalizeFunc base_finalize; Location of the base finalization function (optional).
  131. -- GClassInitFunc class_init; Location of the class initialization function for classed and types. Location of the default vtable inititalization function for interface types. (optional) This function is used both to fill in virtual functions in the class or default vtable, and to do type-specific setup such as registering signals and object properties.
  132. -- GClassFinalizeFunc class_finalize; Location of the class finalization function for classed and types. Location fo the default vtable finalization function for interface types. (optional)
  133. -- gconstpointer class_data; User-supplied data passed to the class init/finalize functions.
  134. -- guint16 instance_size; Size of the instance (object) structure (required for instantiatable types only).
  135. -- guint16 n_preallocs; Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the slice allocator now.
  136. -- GInstanceInitFunc instance_init; Location of the instance initialization function (optional, for instantiatable types only).
  137. -- const GTypeValueTable *value_table; A GTypeValueTable function table for generic handling of GValues of this type (usually only useful for fundamental types).
  138. -- GTypeFundamentalInfo
  139. -- typedef struct {
  140. -- GTypeFundamentalFlags type_flags;
  141. -- } GTypeFundamentalInfo;
  142. -- A structure that provides information to the type system which is used specifically for managing fundamental types.
  143. -- GTypeFundamentalFlags type_flags; GTypeFundamentalFlags describing the characteristics of the fundamental type
  144. -- GInterfaceInfo
  145. -- typedef struct {
  146. -- GInterfaceInitFunc interface_init;
  147. -- GInterfaceFinalizeFunc interface_finalize;
  148. -- gpointer interface_data;
  149. -- } GInterfaceInfo;
  150. -- A structure that provides information to the type system which is used specifically for managing interface types.
  151. -- GTypeValueTable
  152. -- typedef struct {
  153. -- void (*value_init) (GValue *value);
  154. -- void (*value_free) (GValue *value);
  155. -- void (*value_copy) (const GValue *src_value,
  156. -- GValue *dest_value);
  157. -- /* varargs functionality (optional) */
  158. -- gpointer (*value_peek_pointer) (const GValue *value);
  159. -- gchar *collect_format;
  160. -- gchar* (*collect_value) (GValue *value,
  161. -- guint n_collect_values,
  162. -- GTypeCValue *collect_values,
  163. -- guint collect_flags);
  164. -- gchar *lcopy_format;
  165. -- gchar* (*lcopy_value) (const GValue *value,
  166. -- guint n_collect_values,
  167. -- GTypeCValue *collect_values,
  168. -- guint collect_flags);
  169. -- } GTypeValueTable;
  170. -- The GTypeValueTable provides the functions required by the GValue implementation, to serve as a container for values of a type.
  171. -- value_init () Default initialize values contents by poking values directly into the value->data array. The data array of the GValue passed into this function was zero-filled with memset(), so no care has to be taken to free any old contents. E.g. for the implementation of a string value that may never be NULL, the implementation might look like:
  172. -- {
  173. -- value->data[0].v_pointer = g_strdup ("");
  174. -- }
  175. -- value_free () Free any old contents that might be left in the data array of the passed in value. No resources may remain allocated through the GValue contents after this function returns. E.g. for our above string type:
  176. -- {
  177. -- /* only free strings without a specific flag for static storage */
  178. -- if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
  179. -- g_free (value->data[0].v_pointer);
  180. -- }
  181. -- value_copy () dest_value is a GValue with zero-filled data section and src_value is a properly setup GValue of same or derived type. The purpose of this function is to copy the contents of src_value into dest_value in a way, that even after src_value has been freed, the contents of dest_value remain valid. String type example:
  182. -- {
  183. -- dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
  184. -- }
  185. -- value_peek_pointer () If the value contents fit into a pointer, such as objects or strings, return this pointer, so the caller can peek at the current contents. To extend on our above string example:
  186. -- {
  187. -- return value->data[0].v_pointer;
  188. -- }
  189. -- gchar *collect_format; A string format describing how to collect the contents of this value, bit-by-bit. Each character in the format represents an argument to be collected, the characters themselves indicate the type of the argument. Currently supported arguments are:
  190. -- 'i' - Integers. passed as collect_values[].v_int.
  191. -- 'l' - Longs. passed as collect_values[].v_long.
  192. -- 'd' - Doubles. passed as collect_values[].v_double.
  193. -- 'p' - Pointers. passed as collect_values[].v_pointer.
  194. -- It should be noted, that for variable argument list construction, ANSI C promotes every type smaller than an integer to an int, and floats to doubles. So for collection of short int or char, 'i' needs to be used, and for collection of floats 'd'.
  195. -- collect_value () The collect_value() function is responsible for converting the values collected from a variable argument list into contents suitable for storage in a GValue. This function should setup value similar to value_init(), e.g. for a string value that does not allow NULL pointers, it needs to either spew an error, or do an implicit conversion by storing an empty string. The value passed in to this function has a zero-filled data array, so just like for value_init() it is guaranteed to not contain any old contents that might need freeing. n_collect_values is exactly the string length of collect_format, and collect_values is an array of unions GTypeCValue with length n_collect_values, containing the collected values according to collect_format. collect_flags is an argument provided as a hint by the caller, which may contain the flag G_VALUE_NOCOPY_CONTENTS indicating, that the collected value contents may be considered "static" for the duration of the value lifetime. Thus an extra copy of the contents stored in collect_values is not required for assignment to value. For our above string example, we continue with:
  196. -- {
  197. -- if (!collect_values[0].v_pointer)
  198. -- value->data[0].v_pointer = g_strdup ("");
  199. -- else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
  200. -- {
  201. -- value->data[0].v_pointer = collect_values[0].v_pointer;
  202. -- /* keep a flag for the value_free() implementation to not free this string */
  203. -- value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
  204. -- }
  205. -- else
  206. -- value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer);
  207. -- return NULL;
  208. -- }
  209. -- It should be noted, that it is generally a bad idea to follow the G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to reentrancy requirements and reference count assertions performed by the GSignal code, reference counts should always be incremented for reference counted contents stored in the value->data array. To deviate from our string example for a moment, and taking a look at an exemplary implementation for collect_value() of GObject:
  210. -- {
  211. -- if (collect_values[0].v_pointer)
  212. -- {
  213. -- GObject *object = G_OBJECT (collect_values[0].v_pointer);
  214. -- /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
  215. -- value->data[0].v_pointer = g_object_ref (object);
  216. -- return NULL;
  217. -- }
  218. -- else
  219. -- return g_strdup_printf ("Object passed as invalid NULL pointer");
  220. -- }
  221. -- The reference count for valid objects is always incremented, regardless of collect_flags. For invalid objects, the example returns a newly allocated string without altering value. Upon success, collect_value() needs to return NULL, if however a malicious condition occurred, collect_value() may spew an error by returning a newly allocated non-NULL string, giving a suitable description of the error condition. The calling code makes no assumptions about the value contents being valid upon error returns, value is simply thrown away without further freeing. As such, it is a good idea to not allocate GValue contents, prior to returning an error, however, collect_values() is not obliged to return a correctly setup value for error returns, simply because any non-NULL return is considered a fatal condition so further program behaviour is undefined.
  222. -- gchar *lcopy_format; Format description of the arguments to collect for lcopy_value, analogous to collect_format. Usually, lcopy_format string consists only of 'p's to provide lcopy_value() with pointers to storage locations.
  223. -- lcopy_value () This function is responsible for storing the value contents into arguments passed through a variable argument list which got collected into collect_values according to lcopy_format. n_collect_values equals the string length of lcopy_format, and collect_flags may contain G_VALUE_NOCOPY_CONTENTS. In contrast to collect_value(), lcopy_value() is obliged to always properly support G_VALUE_NOCOPY_CONTENTS. Similar to collect_value() the function may prematurely abort by returning a newly allocated string describing an error condition. To complete the string example:
  224. -- {
  225. -- gchar **string_p = collect_values[0].v_pointer;
  226. -- if (!string_p)
  227. -- return g_strdup_printf ("string location passed as NULL");
  228. -- if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
  229. -- *string_p = value->data[0].v_pointer;
  230. -- else
  231. -- *string_p = g_strdup (value->data[0].v_pointer);
  232. -- }
  233. -- And an exemplary version of lcopy_value() for reference-counted types:
  234. -- {
  235. -- GObject **object_p = collect_values[0].v_pointer;
  236. -- if (!object_p)
  237. -- return g_strdup_printf ("object location passed as NULL");
  238. -- if (!value->data[0].v_pointer)
  239. -- *object_p = NULL;
  240. -- else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) /* always honour */
  241. -- *object_p = value->data[0].v_pointer;
  242. -- else
  243. -- *object_p = g_object_ref (value->data[0].v_pointer);
  244. -- return NULL;
  245. -- }
  246. -- G_TYPE_FROM_INSTANCE()
  247. -- #define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class))
  248. -- Returns the type identifier from a given instance structure.
  249. -- This macro should only be used in type implementations.
  250. -- instance : Location of a valid GTypeInstance structure.
  251. -- G_TYPE_FROM_CLASS()
  252. -- #define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type)
  253. -- Returns the type identifier from a given class structure.
  254. -- This macro should only be used in type implementations.
  255. -- g_class : Location of a valid GTypeClass structure.
  256. -- G_TYPE_FROM_INTERFACE()
  257. -- #define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type)
  258. -- Returns the type identifier from a given interface structure.
  259. -- This macro should only be used in type implementations.
  260. -- g_iface : Location of a valid GTypeInterface structure.
  261. -- G_TYPE_INSTANCE_GET_CLASS()
  262. -- #define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type))
  263. -- Returns the class structure of a given instance, casted to a specified ancestor type g_type of the instance.
  264. -- Warning
  265. -- Note that while calling a GInstanceInitFunc(), the class pointer gets modified, so it might not always return the expected pointer.
  266. -- This macro should only be used in type implementations.
  267. -- instance : Location of the GTypeInstance structure.
  268. -- g_type : The anchestor type of the class to be returned.
  269. -- c_type : The corresponding C type of g_type.
  270. -- G_TYPE_INSTANCE_GET_INTERFACE()
  271. -- #define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type))
  272. -- Returns the interface structure for interface g_type of a given instance.
  273. -- This macro should only be used in type implementations.
  274. -- instance : Location of the GTypeInstance structure.
  275. -- g_type : The interface type to be returned.
  276. -- c_type : The corresponding C type of g_type.
  277. -- G_TYPE_INSTANCE_GET_PRIVATE()
  278. -- #define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type)))
  279. -- Gets the private structure for a particular type. The private structure must have been registered in the class_init function with g_type_class_add_private().
  280. -- This macro should only be used in type implementations.
  281. -- instance : the instance of a type deriving from private_type.
  282. -- g_type : the type identifying which private data to retrieve.
  283. -- c_type : The C type for the private structure.
  284. -- Since 2.4
  285. -- G_TYPE_CHECK_INSTANCE()
  286. -- #define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance)))
  287. -- Returns TRUE if instance is a valid GTypeInstance structure, otherwise emits a warning and returns FALSE.
  288. -- This macro should only be used in type implementations.
  289. -- instance : Location of a GTypeInstance structure.
  290. -- G_TYPE_CHECK_INSTANCE_CAST()
  291. -- #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
  292. -- Checks that instance is an instance of the type identified by g_type and emits a warning if this is not the case. Returns instance casted to a pointer to c_type.
  293. -- This macro should only be used in type implementations.
  294. -- instance : Location of a GTypeInstance structure.
  295. -- g_type : The type to be returned.
  296. -- c_type : The corresponding C type of g_type.
  297. -- G_TYPE_CHECK_INSTANCE_TYPE()
  298. -- #define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type)))
  299. -- Returns TRUE if instance is an instance of the type identified by g_type. Otherwise emits a warning and returns FALSE.
  300. -- This macro should only be used in type implementations.
  301. -- instance : Location of a GTypeInstance structure.
  302. -- g_type : The type to be checked
  303. -- G_TYPE_CHECK_CLASS_CAST()
  304. -- #define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type))
  305. -- Checks that g_class is a class structure of the type identified by g_type and emits a warning if this is not the case. Returns g_class casted to a pointer to c_type.
  306. -- This macro should only be used in type implementations.
  307. -- g_class : Location of a GTypeClass structure.
  308. -- g_type : The type to be returned.
  309. -- c_type : The corresponding C type of class structure of g_type.
  310. -- G_TYPE_CHECK_CLASS_TYPE()
  311. -- #define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type)))
  312. -- Returns TRUE if g_class is a class structure of the type identified by g_type. Otherwise emits a warning and returns FALSE.
  313. -- This macro should only be used in type implementations.
  314. -- g_class : Location of a GTypeClass structure.
  315. -- g_type : The type to be checked.
  316. -- G_TYPE_CHECK_VALUE()
  317. -- #define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value)))
  318. -- Returns TRUE if value has been initialized to hold values of a value type.
  319. -- This macro should only be used in type implementations.
  320. -- value : a GValue
  321. -- G_TYPE_CHECK_VALUE_TYPE()
  322. -- #define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type)))
  323. -- Returns TRUE if value has been initialized to hold values of type g_type.
  324. -- This macro should only be used in type implementations.
  325. -- value : a GValue
  326. -- g_type : The type to be checked.
  327. -- G_TYPE_FLAG_RESERVED_ID_BIT
  328. -- #define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0))
  329. -- A bit in the type number that's supposed to be left untouched.
  330. -- g_type_init ()
  331. -- void g_type_init (void);
  332. -- Prior to any use of the type system, g_type_init() has to be called to initialize the type system and assorted other code portions (such as the various fundamental type implementations or the signal system).
  333. -- enum GTypeDebugFlags
  334. -- typedef enum /*< skip >*/
  335. -- {
  336. -- G_TYPE_DEBUG_NONE = 0,
  337. -- G_TYPE_DEBUG_OBJECTS = 1 << 0,
  338. -- G_TYPE_DEBUG_SIGNALS = 1 << 1,
  339. -- G_TYPE_DEBUG_MASK = 0x03
  340. -- } GTypeDebugFlags;
  341. -- The GTypeDebugFlags enumeration values can be passed to g_type_init_with_debug_flags() to trigger debugging messages during runtime. Note that the messages can also be triggered by setting the GOBJECT_DEBUG environment variable to a ':'-separated list of "objects" and "signals".
  342. -- G_TYPE_DEBUG_NONE Print no messages.
  343. -- G_TYPE_DEBUG_OBJECTS Print messages about object bookkeeping.
  344. -- G_TYPE_DEBUG_SIGNALS Print messages about signal emissions.
  345. -- G_TYPE_DEBUG_MASK Mask covering all debug flags.
  346. -- g_type_init_with_debug_flags ()
  347. -- void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags);
  348. -- Similar to g_type_init(), but additionally sets debug flags.
  349. -- debug_flags : Bitwise combination of GTypeDebugFlags values for debugging purposes.
  350. -- g_type_name ()
  351. -- const gchar* g_type_name (GType type);
  352. -- Returns the unique name that is assigned to a type ID (this is the preferred method to find out whether a specific type has been registered for the passed in ID yet).
  353. -- type : Type to return name for.
  354. -- Returns : Static type name or NULL.
  355. -- g_type_qname ()
  356. -- GQuark g_type_qname (GType type);
  357. -- Return the corresponding quark of the type IDs name.
  358. -- type : Type to return quark of type name for.
  359. -- Returns : The type names quark or 0.
  360. -- g_type_from_name ()
  361. -- GType g_type_from_name (const gchar *name);
  362. -- Lookup the type ID from a given type name, returns 0 if no type has been registered under this name (this is the preferred method to find out by name whether a specific type has been registered yet).
  363. -- name : Type name to lookup.
  364. -- Returns : Corresponding type ID or 0.
  365. -- g_type_parent ()
  366. -- GType g_type_parent (GType type);
  367. -- Return the direct parent type of the passed in type. If the passed in type has no parent, i.e. is a fundamental type, 0 is returned.
  368. -- type : The derived type.
  369. -- Returns : The parent type.
  370. -- g_type_depth ()
  371. -- guint g_type_depth (GType type);
  372. -- Returns the length of the ancestry of the passed in type. This includes the type itself, so that e.g. a fundamental type has depth 1.
  373. -- type : A GType value.
  374. -- Returns : The depth of type.
  375. -- g_type_next_base ()
  376. -- GType g_type_next_base (GType leaf_type,
  377. -- GType root_type);
  378. -- Given a leaf_type and a root_type which is contained in its anchestry, return the type that root_type is the immediate parent of. In other words, this function determines the type that is derived directly from root_type which is also a base class of leaf_type. Given a root type and a leaf type, this function can be used to determine the types and order in which the leaf type is descended from the root type.
  379. -- leaf_type : Descendant of root_type and the type to be returned.
  380. -- root_type : Immediate parent of the returned type.
  381. -- Returns : Immediate child of root_type and anchestor of leaf_type.
  382. -- g_type_is_a ()
  383. -- gboolean g_type_is_a (GType type,
  384. -- GType is_a_type);
  385. -- If is_a_type is a derivable type, check whether type is a descendant of is_a_type. If is_a_type is an interface, check whether type conforms to it.
  386. -- type : Type to check anchestry for.
  387. -- is_a_type : Possible anchestor of type or interface type could conform to.
  388. -- Returns : TRUE if type is_a is_a_type holds true.
  389. -- g_type_class_ref ()
  390. -- gpointer g_type_class_ref (GType type);
  391. -- Increments the reference count of the class structure belonging to type. This function will demand-create the class if it doesn't exist already.
  392. -- type : Type ID of a classed type.
  393. -- Returns : The GTypeClass structure for the given type ID.
  394. -- g_type_class_peek ()
  395. -- gpointer g_type_class_peek (GType type);
  396. -- This function is essentially the same as g_type_class_ref(), except that the classes reference count isn't incremented. Therefore, this function may return NULL if the class of the type passed in does not currently exist (hasn't been referenced before).
  397. -- type : Type ID of a classed type.
  398. -- Returns : The GTypeClass structure for the given type ID or NULL if the class does not currently exist.
  399. -- g_type_class_peek_static ()
  400. -- gpointer g_type_class_peek_static (GType type);
  401. -- A more efficient version of g_type_class_peek() which works only for static types.
  402. -- type : Type ID of a classed type.
  403. -- Returns : The GTypeClass structure for the given type ID or NULL if the class does not currently exist or is dynamically loaded.
  404. -- Since 2.4
  405. -- g_type_class_unref ()
  406. -- void g_type_class_unref (gpointer g_class);
  407. -- Decrements the reference count of the class structure being passed in. Once the last reference count of a class has been released, classes may be finalized by the type system, so further dereferencing of a class pointer after g_type_class_unref() are invalid.
  408. -- g_class : The GTypeClass structure to unreference.
  409. -- g_type_class_peek_parent ()
  410. -- gpointer g_type_class_peek_parent (gpointer g_class);
  411. -- This is a convenience function, often needed in class initializers. It essentially takes the immediate parent type of the class passed in, and returns the class structure thereof. Since derived classes hold a reference count on their parent classes as long as they are instantiated, the returned class will always exist. This function is essentially equivalent to:
  412. -- g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)));
  413. -- g_class : The GTypeClass structure to retrieve the parent class for.
  414. -- Returns : The parent class of g_class.
  415. -- g_type_class_add_private ()
  416. -- void g_type_class_add_private (gpointer g_class,
  417. -- gsize private_size);
  418. -- Registers a private structure for a instantiatable type; when an object is allocated, the private structures for the type and and all of its parent types are allocated sequentially in the same memory block as the public structures. This function should be called in the type's class_init() function. The private structure can be retrieved using the G_TYPE_INSTANCE_GET_PRIVATE() macro. The following example shows attaching a private structure MyObjectPrivate to an object MyObject defined in the standard GObject fashion.
  419. -- typedef struct _MyObjectPrivate MyObjectPrivate;
  420. -- struct _MyObjectPrivate {
  421. -- int some_field;
  422. -- };
  423. -- #define MY_OBJECT_GET_PRIVATE(o) \
  424. -- (G_TYPE_INSTANCE_GET_PRIVATE ((o), MY_TYPE_OBJECT, MyObjectPrivate))
  425. -- static void
  426. -- my_object_class_init (MyObjectClass *klass)
  427. -- {
  428. -- g_type_class_add_private (klass, sizeof (MyObjectPrivate));
  429. -- }
  430. -- static int
  431. -- my_object_get_some_field (MyObject *my_object)
  432. -- {
  433. -- MyObjectPrivate *priv = MY_OBJECT_GET_PRIVATE (my_object);
  434. -- return priv->some_field;
  435. -- }
  436. -- g_class : class structure for an instantiatable type
  437. -- private_size : size of private structure.
  438. -- Since 2.4
  439. -- g_type_interface_peek ()
  440. -- gpointer g_type_interface_peek (gpointer instance_class,
  441. -- GType iface_type);
  442. -- Returns the GTypeInterface structure of an interface to which the passed in class conforms.
  443. -- instance_class : A GTypeClass structure.
  444. -- iface_type : An interface ID which this class conforms to.
  445. -- Returns : The GTypeInterface structure of iface_type, or NULL if the class is not instantiated.
  446. -- g_type_interface_peek_parent ()
  447. -- gpointer g_type_interface_peek_parent (gpointer g_iface);
  448. -- Returns the corresponding GTypeInterface structure of the parent type of the instance type to which g_iface belongs. This is useful when deriving the implementation of an interface from the parent type and then possibly overriding some methods.
  449. -- g_iface : A GTypeInterface structure.
  450. -- Returns : The corresponding GTypeInterface structure of the parent type of the instance type to which g_iface belongs, or NULL if the parent type doesn't conform to the interface.
  451. -- g_type_default_interface_ref ()
  452. -- gpointer g_type_default_interface_ref (GType g_type);
  453. -- Increments the reference count for the interface type g_type, and returns the default interface vtable for the type.
  454. -- If the type is not currently in use, then the default vtable for the type will be created and initalized by calling the base interface init and default vtable init functions for the type (the @base_init and class_init members of GTypeInfo). Calling g_type_default_interface_ref() is useful when you want to make sure that signals and properties for an interface have been installed.
  455. -- g_type : an interface type
  456. -- Returns : the default vtable for the interface; call g_type_default_interface_unref() when you are done using the interface.
  457. -- Since 2.4
  458. -- g_type_default_interface_peek ()
  459. -- gpointer g_type_default_interface_peek (GType g_type);
  460. -- If the interface type g_type is currently in use, returns its default interface vtable.
  461. -- g_type : an interface type
  462. -- Returns : the default vtable for the interface; or NULL if the type is not currently in use.
  463. -- Since 2.4
  464. -- g_type_default_interface_unref ()
  465. -- void g_type_default_interface_unref (gpointer g_iface);
  466. -- Decrements the reference count for the type corresponding to the interface default vtable g_iface. If the type is dynamic, then when no one is using the interface and all references have been released, the finalize function for the interface's default vtable (the class_finalize member of GTypeInfo) will be called.
  467. -- g_iface : the default vtable structure for a interface, as returned by g_type_default_interface_ref()
  468. -- Since 2.4
  469. -- g_type_children ()
  470. -- GType* g_type_children (GType type,
  471. -- guint *n_children);
  472. -- Return a newly allocated and 0-terminated array of type IDs, listing the child types of type. The return value has to be g_free()ed after use.
  473. -- type : The parent type.
  474. -- n_children : Optional guint pointer to contain the number of child types.
  475. -- Returns : Newly allocated and 0-terminated array of child types.
  476. -- g_type_interfaces ()
  477. -- GType* g_type_interfaces (GType type,
  478. -- guint *n_interfaces);
  479. -- Return a newly allocated and 0-terminated array of type IDs, listing the interface types that type conforms to. The return value has to be g_free()ed after use.
  480. -- type : The type to list interface types for.
  481. -- n_interfaces : Optional guint pointer to contain the number of interface types.
  482. -- Returns : Newly allocated and 0-terminated array of interface types.
  483. -- g_type_interface_prerequisites ()
  484. -- GType* g_type_interface_prerequisites (GType interface_type,
  485. -- guint *n_prerequisites);
  486. -- Returns the prerequisites of an interfaces type.
  487. -- interface_type : an interface type
  488. -- n_prerequisites : location to return the number of prerequisites, or NULL
  489. -- Returns : a newly-allocated zero-terminated array of GType containing the prerequisites of interface_type
  490. -- Since 2.2
  491. -- g_type_set_qdata ()
  492. -- void g_type_set_qdata (GType type,
  493. -- GQuark quark,
  494. -- gpointer data);
  495. -- Attaches arbitrary data to a type.
  496. -- type : a GType
  497. -- quark : a GQuark id to identify the data
  498. -- data : the data
  499. -- g_type_get_qdata ()
  500. -- gpointer g_type_get_qdata (GType type,
  501. -- GQuark quark);
  502. -- Obtains data which has previously been attached to type with g_type_set_qdata().
  503. -- type : a GType
  504. -- quark : a GQuark id to identify the data
  505. -- Returns : the data, or NULL if no data was found
  506. -- g_type_query ()
  507. -- void g_type_query (GType type,
  508. -- GTypeQuery *query);
  509. -- Queries the type system for information about a specific type. This function will fill in a user-provided structure to hold type-specific information. If an invalid GType is passed in, the type member of the GTypeQuery is 0. All members filled into the GTypeQuery structure should be considered constant and have to be left untouched.
  510. -- type : the GType value of a static, classed type.
  511. -- query : A user provided structure that is filled in with constant values upon success.
  512. -- GTypeQuery
  513. -- typedef struct {
  514. -- GType type;
  515. -- const gchar *type_name;
  516. -- guint class_size;
  517. -- guint instance_size;
  518. -- } GTypeQuery;
  519. -- A structure holding information for a specific type. It is filled in by the g_type_query() function.
  520. -- GType type; the GType value of the type.
  521. -- const gchar *type_name; the name of the type.
  522. -- guint class_size; the size of the class structure.
  523. -- guint instance_size; the size of the instance structure.
  524. -- GBaseInitFunc ()
  525. -- void (*GBaseInitFunc) (gpointer g_class);
  526. -- A callback function used by the type system to do base initialization of the class structures of derived types. It is called as part of the initialization process of all derived classes and should reallocate or reset all dynamic class members copied over from the parent class. Therefore class members, e.g. strings, that are not sufficiently handled by a plain memory copy of the parent class into the derived class have to be altered. See GClassInitFunc() for a discussion of the class intialization process.
  527. -- g_class : The GTypeClass structure to initialize.
  528. -- GBaseFinalizeFunc ()
  529. -- void (*GBaseFinalizeFunc) (gpointer g_class);
  530. -- A callback function used by the type system to finalize those portions of a derived types class structure that were setup from the corresponding GBaseInitFunc() function. Class finalization basically works the inverse way in which class intialization is performed. See GClassInitFunc() for a discussion of the class intialization process.
  531. -- g_class : The GTypeClass structure to finalize.
  532. -- GClassInitFunc ()
  533. -- void (*GClassInitFunc) (gpointer g_class,
  534. -- gpointer class_data);
  535. -- A callback function used by the type system to initialize the class of a specific type. This function should initialize all static class members. The initialization process of a class involves:
  536. -- 1 - Copying common members from the parent class over to the derived class structure.
  537. -- 2 - Zero initialization of the remaining members not copied over from the parent class.
  538. -- 3 - Invocation of the GBaseInitFunc() initializers of all parent types and the class' type.
  539. -- 4 - Invocation of the class' GClassInitFunc() initializer.
  540. -- Since derived classes are partially initialized through a memory copy of the parent class, the general rule is that GBaseInitFunc() and GBaseFinalizeFunc() should take care of necessary reinitialization and release of those class members that were introduced by the type that specified these GBaseInitFunc()/GBaseFinalizeFunc(). GClassInitFunc() should only care about initializing static class members, while dynamic class members (such as allocated strings or reference counted resources) are better handled by a GBaseInitFunc() for this type, so proper initialization of the dynamic class members is performed for class initialization of derived types as well. An example may help to correspond the intend of the different class initializers:
  541. -- typedef struct {
  542. -- GObjectClass parent_class;
  543. -- gint static_integer;
  544. -- gchar *dynamic_string;
  545. -- } TypeAClass;
  546. -- static void
  547. -- type_a_base_class_init (TypeAClass *class)
  548. -- {
  549. -- class->dynamic_string = g_strdup ("some string");
  550. -- }
  551. -- static void
  552. -- type_a_base_class_finalize (TypeAClass *class)
  553. -- {
  554. -- g_free (class->dynamic_string);
  555. -- }
  556. -- static void
  557. -- type_a_class_init (TypeAClass *class)
  558. -- {
  559. -- class->static_integer = 42;
  560. -- }
  561. -- typedef struct {
  562. -- TypeAClass parent_class;
  563. -- gfloat static_float;
  564. -- GString *dynamic_gstring;
  565. -- } TypeBClass;
  566. -- static void
  567. -- type_b_base_class_init (TypeBClass *class)
  568. -- {
  569. -- class->dynamic_gstring = g_string_new ("some other string");
  570. -- }
  571. -- static void
  572. -- type_b_base_class_finalize (TypeBClass *class)
  573. -- {
  574. -- g_string_free (class->dynamic_gstring);
  575. -- }
  576. -- static void
  577. -- type_b_class_init (TypeBClass *class)
  578. -- {
  579. -- class->static_float = 3.14159265358979323846;
  580. -- }
  581. -- Initialization of TypeBClass will first cause initialization of TypeAClass (derived classes reference their parent classes, see g_type_class_ref() on this). Initialization of TypeAClass roughly involves zero-initializing its fields, then calling its GBaseInitFunc() type_a_base_class_init() that allocates its dynamic members (dynamic_string) and finally calling its GClassInitFunc() type_a_class_init() to initialize its static members (static_integer). The first step in the initialization process of TypeBClass is then a plain memory copy of the contents of TypeAClass into TypeBClass and zero-initialization of the remaining fields in TypeBClass. The dynamic members of TypeAClass within TypeBClass now need reinitialization which is performed by calling type_a_base_class_init() with an argument of TypeBClass. After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init() is called to allocate the dynamic members of TypeBClass (dynamic_gstring), and finally the GClassInitFunc() of TypeBClass, type_b_class_init(), is called to complete the initialization process with the static members (static_float). Corresponding finalization counter parts to the GBaseInitFunc() functions have to be provided to release allocated resources at class finalization time.
  582. -- g_class : The GTypeClass structure to initialize.
  583. -- class_data : The class_data member supplied via the GTypeInfo structure.
  584. -- GClassFinalizeFunc ()
  585. -- void (*GClassFinalizeFunc) (gpointer g_class,
  586. -- gpointer class_data);
  587. -- A callback function used by the type system to finalize a class. This function is rarely needed, as dynamically allocated class resources should be handled by GBaseInitFunc() and GBaseFinalizeFunc(). Also, specification of a GClassFinalizeFunc() in the GTypeInfo structure of a static type is invalid, because classes of static types will never be finalized (they are artificially kept alive when their reference count drops to zero).
  588. -- g_class : The GTypeClass structure to finalize.
  589. -- class_data : The class_data member supplied via the GTypeInfo structure.
  590. -- GInstanceInitFunc ()
  591. -- void (*GInstanceInitFunc) (GTypeInstance *instance,
  592. -- gpointer g_class);
  593. -- A callback function used by the type system to initialize a new instance of a type. This function initializes all instance members and allocates any resources required by it. Initialization of a derived instance involves calling all its parent types instance initializers, therefore the class member of the instance is altered during its initialization to always point to the class that belongs to the type the current initializer was introduced for.
  594. -- instance : The instance to initialize.
  595. -- g_class : The class of the type the instance is created for.
  596. -- GInterfaceInitFunc ()
  597. -- void (*GInterfaceInitFunc) (gpointer g_iface,
  598. -- gpointer iface_data);
  599. -- A callback function used by the type system to initialize a new interface. This function should initialize all internal data and allocate any resources required by the interface.
  600. -- g_iface : The interface structure to initialize.
  601. -- iface_data : The class_data supplied via the GTypeInfo structure.
  602. -- GInterfaceFinalizeFunc ()
  603. -- void (*GInterfaceFinalizeFunc) (gpointer g_iface,
  604. -- gpointer iface_data);
  605. -- A callback function used by the type system to finalize an interface. This function should destroy any internal data and release any resources allocated by the corresponding GInterfaceInitFunc() function.
  606. -- g_iface : The interface structure to finalize.
  607. -- iface_data : The class_data supplied via the GTypeInfo structure.
  608. -- GTypeClassCacheFunc ()
  609. -- gboolean (*GTypeClassCacheFunc) (gpointer cache_data,
  610. -- GTypeClass *g_class);
  611. -- A callback function which is called when the reference count of a class drops to zero. It may use g_type_class_ref() to prevent the class from being freed. You should not call g_type_class_unref() from a GTypeClassCacheFunc function to prevent infinite recursion, use g_type_class_unref_uncached() instead.
  612. -- The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same GTypeClassCacheFunc chain.
  613. -- cache_data : data that was given to the g_type_add_class_cache_func() call
  614. -- g_class : The GTypeClass structure which is unreferenced
  615. -- Returns : TRUE to stop further GTypeClassCacheFuncs from being called, FALSE to continue.
  616. -- enum GTypeFlags
  617. -- typedef enum /*< skip >*/
  618. -- {
  619. -- G_TYPE_FLAG_ABSTRACT = (1 << 4),
  620. -- G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5)
  621. -- } GTypeFlags;
  622. -- Bit masks used to check or determine characteristics of a type.
  623. -- G_TYPE_FLAG_ABSTRACT Indicates an abstract type. No instances can be created for an abstract type.
  624. -- G_TYPE_FLAG_VALUE_ABSTRACT Indicates an abstract value type, i.e. a type that introduces a value table, but can't be used for g_value_init().
  625. -- enum GTypeFundamentalFlags
  626. -- typedef enum /*< skip >*/
  627. -- {
  628. -- G_TYPE_FLAG_CLASSED = (1 << 0),
  629. -- G_TYPE_FLAG_INSTANTIATABLE = (1 << 1),
  630. -- G_TYPE_FLAG_DERIVABLE = (1 << 2),
  631. -- G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3)
  632. -- } GTypeFundamentalFlags;
  633. -- Bit masks used to check or determine specific characteristics of a fundamental type.
  634. -- G_TYPE_FLAG_CLASSED Indicates a classed type.
  635. -- G_TYPE_FLAG_INSTANTIATABLE Indicates an instantiable type (implies classed).
  636. -- G_TYPE_FLAG_DERIVABLE Indicates a flat derivable type.
  637. -- G_TYPE_FLAG_DEEP_DERIVABLE Indicates a deep derivable type (implies derivable).
  638. -- g_type_register_static ()
  639. -- GType g_type_register_static (GType parent_type,
  640. -- const gchar *type_name,
  641. -- const GTypeInfo *info,
  642. -- GTypeFlags flags);
  643. -- Registers type_name as the name of a new static type derived from parent_type. The type system uses the information contained in the GTypeInfo structure pointed to by info to manage the type and its instances (if not abstract). The value of flags determines the nature (e.g. abstract or not) of the type.
  644. -- parent_type : Type which this type will be derived from.
  645. -- type_name : 0-terminated string used as the name of the new type.
  646. -- info : The GTypeInfo structure for this type.
  647. -- flags : Bitwise combination of GTypeFlags values.
  648. -- Returns : The new type identifier.
  649. -- g_type_register_dynamic ()
  650. -- GType g_type_register_dynamic (GType parent_type,
  651. -- const gchar *type_name,
  652. -- GTypePlugin *plugin,
  653. -- GTypeFlags flags);
  654. -- Registers type_name as the name of a new dynamic type derived from parent_type. The type system uses the information contained in the GTypePlugin structure pointed to by plugin to manage the type and its instances (if not abstract). The value of flags determines the nature (e.g. abstract or not) of the type.
  655. -- parent_type : Type which this type will be derived from.
  656. -- type_name : 0-terminated string used as the name of the new type.
  657. -- plugin : The GTypePlugin structure to retrieve the GTypeInfo from.
  658. -- flags : Bitwise combination of GTypeFlags values.
  659. -- Returns : The new type identifier or G_TYPE_INVALID if registration failed.
  660. -- g_type_register_fundamental ()
  661. -- GType g_type_register_fundamental (GType type_id,
  662. -- const gchar *type_name,
  663. -- const GTypeInfo *info,
  664. -- const GTypeFundamentalInfo *finfo,
  665. -- GTypeFlags flags);
  666. -- Registers type_id as the predefined identifier and type_name as the name of a fundamental type. The type system uses the information contained in the GTypeInfo structure pointed to by info and the GTypeFundamentalInfo structure pointed to by finfo to manage the type and its instances. The value of flags determines additional characteristics of the fundamental type.
  667. -- type_id : A predefined GTypeFundamentals value.
  668. -- type_name : 0-terminated string used as the name of the new type.
  669. -- info : The GTypeInfo structure for this type.
  670. -- finfo : The GTypeFundamentalInfo structure for this type.
  671. -- flags : Bitwise combination of GTypeFlags values.
  672. -- Returns : The predefined type identifier.
  673. -- g_type_add_interface_static ()
  674. -- void g_type_add_interface_static (GType instance_type,
  675. -- GType interface_type,
  676. -- const GInterfaceInfo *info);
  677. -- Adds the static interface_type to instantiable_type. The information contained in the GTypeInterfaceInfo structure pointed to by info is used to manage the relationship.
  678. -- instance_type : GType value of an instantiable type.
  679. -- interface_type : GType value of an interface type.
  680. -- info : The GInterfaceInfo structure for this (instance_type, interface_type) combination.
  681. -- g_type_add_interface_dynamic ()
  682. -- void g_type_add_interface_dynamic (GType instance_type,
  683. -- GType interface_type,
  684. -- GTypePlugin *plugin);
  685. -- Adds the dynamic interface_type to instantiable_type. The information contained in the GTypePlugin structure pointed to by plugin is used to manage the relationship.
  686. -- instance_type : the GType value of an instantiable type.
  687. -- interface_type : the GType value of an interface type.
  688. -- plugin : the GTypePlugin structure to retrieve the GInterfaceInfo from.
  689. -- g_type_interface_add_prerequisite ()
  690. -- void g_type_interface_add_prerequisite
  691. -- (GType interface_type,
  692. -- GType prerequisite_type);
  693. -- Adds prerequisite_type to the list of prerequisites of interface_type. This means that any type implementing interface_type must also implement prerequisite_type. Prerequisites can be thought of as an alternative to interface derivation (which GType doesn't support). An interface can have at most one instantiatable prerequisite type.
  694. -- interface_type : GType value of an interface type.
  695. -- prerequisite_type : GType value of an interface or instantiatable type.
  696. -- g_type_get_plugin ()
  697. -- GTypePlugin* g_type_get_plugin (GType type);
  698. -- Returns the GTypePlugin structure for type or NULL if type does not have a GTypePlugin structure.
  699. -- type : The GType to retrieve the plugin for.
  700. -- Returns : The corresponding plugin if type is a dynamic type, NULL otherwise.
  701. -- g_type_interface_get_plugin ()
  702. -- GTypePlugin* g_type_interface_get_plugin (GType instance_type,
  703. -- GType interface_type);
  704. -- Returns the GTypePlugin structure for the dynamic interface interface_type which has been added to instance_type, or NULL if interface_type has not been added to instance_type or does not have a GTypePlugin structure. See g_type_add_interface_dynamic().
  705. -- instance_type : the GType value of an instantiatable type.
  706. -- interface_type : the GType value of an interface type.
  707. -- Returns : the GTypePlugin for the dynamic interface interface_type of instance_type.
  708. -- g_type_fundamental_next ()
  709. -- GType g_type_fundamental_next (void);
  710. -- Returns the next free fundamental type id which can be used to register a new fundamental type with g_type_register_fundamental(). The returned type ID represents the highest currently registered fundamental type identifier.
  711. -- Returns : The nextmost fundamental type ID to be registered, or 0 if the type system ran out of fundamental type IDs.
  712. -- g_type_fundamental ()
  713. -- GType g_type_fundamental (GType type_id);
  714. -- Internal function, used to extract the fundamental type ID portion. use G_TYPE_FUNDAMENTAL() instead.
  715. -- type_id : valid type ID
  716. -- Returns : fundamental type ID
  717. -- g_type_create_instance ()
  718. -- GTypeInstance* g_type_create_instance (GType type);
  719. -- Creates and initializes an instance of type if type is valid and can be instantiated. The type system only performs basic allocation and structure setups for instances, actual instance creation should happen through functions supplied by the type's fundamental type implementation. So use of g_type_create_instance() is reserved for implementators of fundamental types only. E.g. instances of the GObject hierarchy should be created via g_object_new() and never directly through g_type_create_instance() which doesn't handle things like singleton objects or object construction. Note: Do not use this function, unless you're implementing a fundamental type. Also language bindings should not use this function but g_object_new() instead.
  720. -- type : An instantiatable type to create an instance for.
  721. -- Returns : An allocated and initialized instance, subject to further treatment by the fundamental type implementation.
  722. -- g_type_free_instance ()
  723. -- void g_type_free_instance (GTypeInstance *instance);
  724. -- Frees an instance of a type, returning it to the instance pool for the type, if there is one.
  725. -- Like g_type_create_instance(), this function is reserved for implementors of fundamental types.
  726. -- instance : an instance of a type.
  727. -- g_type_add_class_cache_func ()
  728. -- void g_type_add_class_cache_func (gpointer cache_data,
  729. -- GTypeClassCacheFunc cache_func);
  730. -- Adds a GTypeClassCacheFunc to be called before the reference count of a class goes from one to zero. This can be used to prevent premature class destruction. All installed GTypeClassCacheFunc functions will be chained until one of them returns TRUE. The functions have to check the class id passed in to figure whether they actually want to cache the class of this type, since all classes are routed through the same GTypeClassCacheFunc chain.
  731. -- cache_data : data to be passed to cache_func
  732. -- cache_func : a GTypeClassCacheFunc
  733. -- g_type_remove_class_cache_func ()
  734. -- void g_type_remove_class_cache_func (gpointer cache_data,
  735. -- GTypeClassCacheFunc cache_func);
  736. -- Removes a previously installed GTypeClassCacheFunc. The cache maintained by cache_func has to be empty when calling g_type_remove_class_cache_func() to avoid leaks.
  737. -- cache_data : data that was given when adding cache_func
  738. -- cache_func : a GTypeClassCacheFunc
  739. -- g_type_class_unref_uncached ()
  740. -- void g_type_class_unref_uncached (gpointer g_class);
  741. -- A variant of g_type_class_unref() for use in GTypeClassCacheFunc implementations. It unreferences a class without consulting the chain of GTypeClassCacheFuncs, avoiding the recursion which would occur otherwise.
  742. -- g_class : The GTypeClass structure to unreference.
  743. -- g_type_add_interface_check ()
  744. -- void g_type_add_interface_check (gpointer check_data,
  745. -- GTypeInterfaceCheckFunc check_func);
  746. -- Adds a function to be called after an interface vtable is initialized for any class. That is, after the interface_init member of GInterfaceInfo has been called.
  747. -- This function is useful when you want to check an invariant that depends on the interfaces of a class. For instance, the implementation of GObject uses this facility to check that an object implements all of the properties that are defined on its interfaces.
  748. -- check_data : data to pass to check_func
  749. -- check_func : function to be called after each interface is initialized.
  750. -- Since 2.4
  751. -- g_type_remove_interface_check ()
  752. -- void g_type_remove_interface_check (gpointer check_data,
  753. -- GTypeInterfaceCheckFunc check_func);
  754. -- Removes an interface check function added with g_type_add_interface_check().
  755. -- check_data : callback data passed to g_type_add_interface_check()
  756. -- check_func : callback function passed to g_type_add_interface_check()
  757. -- Since 2.4
  758. -- GTypeInterfaceCheckFunc ()
  759. -- void (*GTypeInterfaceCheckFunc) (gpointer check_data,
  760. -- gpointer g_iface);
  761. -- A callback called after an interface vtable is initialized. See g_type_add_interface_check().
  762. -- check_data : data passed to g_type_add_interface_check().
  763. -- g_iface : the interface that has been initialized
  764. -- Since 2.4
  765. -- g_type_value_table_peek ()
  766. -- GTypeValueTable* g_type_value_table_peek (GType type);
  767. -- Returns the location of the GTypeValueTable associated with type. Note, this function should only be used from source code that implements or has internal knowledge of the implementation of type.
  768. -- type : A GType value.
  769. -- Returns : Location of the GTypeValueTable associated with type or NULL if there is no GTypeValueTable associated with type.
  770. -- G_DEFINE_TYPE()
  771. -- #define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
  772. -- A convenience macro for type implementations, which declares a class initialization function, an instance initialization function (see GTypeInfo for information about these) and a static variable named t_n_parent_class pointing to the parent class. Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() for an example.
  773. -- TN : The name of the new type, in Camel case.
  774. -- t_n : The name of the new type, in lowercase, with words separated by '_'.
  775. -- T_P : The GType of the parent type.
  776. -- Since 2.4
  777. -- G_DEFINE_TYPE_WITH_CODE()
  778. -- #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, _C_)
  779. -- A convenience macro for type implementations. Similar to G_DEFINE_TYPE(), but allows to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). See G_DEFINE_TYPE_EXTENDED() for an example.
  780. -- TN : The name of the new type, in Camel case.
  781. -- t_n : The name of the new type in lowercase, with words separated by '_'.
  782. -- T_P : The GType of the parent type.
  783. -- _C_ : Custom code that gets inserted in the *_get_type() function.
  784. -- Since 2.4
  785. -- G_DEFINE_ABSTRACT_TYPE()
  786. -- #define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
  787. -- A convenience macro for type implementations. Similar to G_DEFINE_TYPE(), but defines an abstract type. See G_DEFINE_TYPE_EXTENDED() for an example.
  788. -- TN : The name of the new type, in Camel case.
  789. -- t_n : The name of the new type, in lowercase, with words separated by '_'.
  790. -- T_P : The GType of the parent type.
  791. -- Since 2.4
  792. -- G_DEFINE_ABSTRACT_TYPE_WITH_CODE()
  793. -- #define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, _C_)
  794. -- A convenience macro for type implementations. Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and allows to insert custom code into the *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). See G_DEFINE_TYPE_EXTENDED() for an example.
  795. -- TN : The name of the new type, in Camel case.
  796. -- t_n : The name of the new type, in lowercase, with words separated by '_'.
  797. -- T_P : The GType of the parent type.
  798. -- _C_ : Custom code that gets inserted in the @type_name_get_type() function.
  799. -- Since 2.4
  800. -- G_IMPLEMENT_INTERFACE()
  801. -- #define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)
  802. -- A convenience macro to ease interface addition in the _C_ section of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). See G_DEFINE_TYPE_EXTENDED() for an example.
  803. -- Note that this macro can only be used together with the G_DEFINE_TYPE_* macros, since it depends on variable names from those macros.
  804. -- TYPE_IFACE : The GType of the interface to add
  805. -- iface_init : The interface init function
  806. -- Since 2.4
  807. -- G_DEFINE_TYPE_EXTENDED()
  808. -- #define G_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE)
  809. -- The most general convenience macro for type implementations, on which G_DEFINE_TYPE(), etc are based.
  810. -- G_DEFINE_TYPE_EXTENDED (GtkGadget,
  811. -- gtk_gadget,
  812. -- GTK_TYPE_WIDGET,
  813. -- 0,
  814. -- G_IMPLEMENT_INTERFACE (TYPE_GIZMO,
  815. -- gtk_gadget_gizmo_init));
  816. -- expands to
  817. -- static void gtk_gadget_init (GtkGadget *self);
  818. -- static void gtk_gadget_class_init (GtkGadgetClass *klass);
  819. -- static gpointer gtk_gadget_parent_class = NULL;
  820. -- static void gtk_gadget_class_intern_init (gpointer klass)
  821. -- {
  822. -- gtk_gadget_parent_class = g_type_class_peek_parent (klass);
  823. -- gtk_gadget_class_init ((GtkGadgetClass*) klass);
  824. -- }
  825. -- GType
  826. -- gtk_gadget_get_type (void)
  827. -- {
  828. -- static GType g_define_type_id = 0;
  829. -- if (G_UNLIKELY (g_define_type_id == 0))
  830. -- {
  831. -- static const GTypeInfo g_define_type_info = {
  832. -- sizeof (GtkGadgetClass),
  833. -- (GBaseInitFunc) NULL,
  834. -- (GBaseFinalizeFunc) NULL,
  835. -- (GClassInitFunc) gtk_gadget_class_intern_init,
  836. -- (GClassFinalizeFunc) NULL,
  837. -- NULL, /* class_data */
  838. -- sizeof (GtkGadget),
  839. -- 0, /* n_preallocs */
  840. -- (GInstanceInitFunc) gtk_gadget_init,
  841. -- };
  842. -- g_define_type_id = g_type_register_static (GTK_TYPE_WIDGET, "GtkGadget", &g_define_type_info, 0);
  843. -- {
  844. -- static const GInterfaceInfo g_implement_interface_info = {
  845. -- (GInterfaceInitFunc) gtk_gadget_gizmo_init
  846. -- };
  847. -- g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info);
  848. -- }
  849. -- }
  850. -- return g_define_type_id;
  851. -- }
  852. -- The only pieces which have to be manually provided are the definitions of the instance and class structure and the definitions of the instance and class init functions.
  853. -- TypeName : The name of the new type, in Camel case.
  854. -- type_name : The name of the new type, in lowercase, with words separated by '_'.
  855. -- TYPE_PARENT : The GType of the parent type.
  856. -- flags : GTypeFlags to pass to g_type_register_static()
  857. -- CODE : Custom code that gets inserted in the *_get_type() function.
  858. -- Since 2.4
  859. -- G_TYPE_INVALID
  860. -- #define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0)
  861. -- An invalid GType, used as error return value in some functions which return a GType.
  862. -- G_TYPE_NONE
  863. -- #define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
  864. -- A fundamental type which is used as a replacement for the C void return type.
  865. -- G_TYPE_INTERFACE
  866. -- #define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2)
  867. -- The fundamental type from which all interfaces are derived.
  868. -- G_TYPE_CHAR
  869. -- #define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3)
  870. -- The fundamental type corresponding to gchar.
  871. -- G_TYPE_UCHAR
  872. -- #define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4)
  873. -- The fundamental type corresponding to guchar.
  874. -- G_TYPE_BOOLEAN
  875. -- #define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5)
  876. -- The fundamental type corresponding to gboolean.
  877. -- G_TYPE_INT
  878. -- #define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)
  879. -- The fundamental type corresponding to gint.
  880. -- G_TYPE_UINT
  881. -- #define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7)
  882. -- The fundamental type corresponding to guint.
  883. -- G_TYPE_LONG
  884. -- #define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8)
  885. -- The fundamental type corresponding to glong.
  886. -- G_TYPE_ULONG
  887. -- #define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9)
  888. -- The fundamental type corresponding to gulong.
  889. -- G_TYPE_INT64
  890. -- #define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10)
  891. -- The fundamental type corresponding to gint64.
  892. -- G_TYPE_UINT64
  893. -- #define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11)
  894. -- The fundamental type corresponding to guint64.
  895. -- G_TYPE_ENUM
  896. -- #define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12)
  897. -- The fundamental type from which all enumeration types are derived.
  898. -- G_TYPE_FLAGS
  899. -- #define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13)
  900. -- The fundamental type from which all flags types are derived.
  901. -- G_TYPE_FLOAT
  902. -- #define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14)
  903. -- The fundamental type corresponding to gfloat.
  904. -- G_TYPE_DOUBLE
  905. -- #define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15)
  906. -- The fundamental type corresponding to gdouble.
  907. -- G_TYPE_STRING
  908. -- #define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16)
  909. -- The fundamental type corresponding to nul-terminated C strings.
  910. -- G_TYPE_POINTER
  911. -- #define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17)
  912. -- The fundamental ty