Synopsis#include <glib-object.h> typedef GType; #define G_TYPE_FUNDAMENTAL (type) #define G_TYPE_FUNDAMENTAL_MAX #define G_TYPE_MAKE_FUNDAMENTAL (x) #define G_TYPE_IS_ABSTRACT (type) #define G_TYPE_IS_DERIVED (type) #define G_TYPE_IS_FUNDAMENTAL (type) #define G_TYPE_IS_VALUE_TYPE (type) #define G_TYPE_HAS_VALUE_TABLE (type) #define G_TYPE_IS_CLASSED (type) #define G_TYPE_IS_INSTANTIATABLE (type) #define G_TYPE_IS_DERIVABLE (type) #define G_TYPE_IS_DEEP_DERIVABLE (type) #define G_TYPE_IS_INTERFACE (type) GTypeInterface; GTypeInstance; GTypeClass; GTypeInfo; GTypeFundamentalInfo; GInterfaceInfo; GTypeValueTable; #define G_TYPE_FROM_INSTANCE (instance) #define G_TYPE_FROM_CLASS (g_class) #define G_TYPE_FROM_INTERFACE (g_iface) #define G_TYPE_INSTANCE_GET_CLASS (instance, g_type, c_type) #define G_TYPE_INSTANCE_GET_INTERFACE (instance, g_type, c_type) #define G_TYPE_INSTANCE_GET_PRIVATE (instance, g_type, c_type) #define G_TYPE_CHECK_INSTANCE (instance) #define G_TYPE_CHECK_INSTANCE_CAST (instance, g_type, c_type) #define G_TYPE_CHECK_INSTANCE_TYPE (instance, g_type) #define G_TYPE_CHECK_CLASS_CAST (g_class, g_type, c_type) #define G_TYPE_CHECK_CLASS_TYPE (g_class, g_type) #define G_TYPE_CHECK_VALUE (value) #define G_TYPE_CHECK_VALUE_TYPE (value, g_type) #define G_TYPE_FLAG_RESERVED_ID_BIT void g_type_init (void); enum GTypeDebugFlags; void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags); const gchar* g_type_name (GType type); GQuark g_type_qname (GType type); GType g_type_from_name (const gchar *name); GType g_type_parent (GType type); guint g_type_depth (GType type); GType g_type_next_base (GType leaf_type, GType root_type); gboolean g_type_is_a (GType type, GType is_a_type); gpointer g_type_class_ref (GType type); gpointer g_type_class_peek (GType type); gpointer g_type_class_peek_static (GType type); void g_type_class_unref (gpointer g_class); gpointer g_type_class_peek_parent (gpointer g_class); void g_type_class_add_private (gpointer g_class, gsize private_size); gpointer g_type_interface_peek (gpointer instance_class, GType iface_type); gpointer g_type_interface_peek_parent (gpointer g_iface); gpointer g_type_default_interface_ref (GType g_type); gpointer g_type_default_interface_peek (GType g_type); void g_type_default_interface_unref (gpointer g_iface); GType* g_type_children (GType type, guint *n_children); GType* g_type_interfaces (GType type, guint *n_interfaces); GType* g_type_interface_prerequisites (GType interface_type, guint *n_prerequisites); void g_type_set_qdata (GType type, GQuark quark, gpointer data); gpointer g_type_get_qdata (GType type, GQuark quark); void g_type_query (GType type, GTypeQuery *query); GTypeQuery; void (*GBaseInitFunc) (gpointer g_class); void (*GBaseFinalizeFunc) (gpointer g_class); void (*GClassInitFunc) (gpointer g_class, gpointer class_data); void (*GClassFinalizeFunc) (gpointer g_class, gpointer class_data); void (*GInstanceInitFunc) (GTypeInstance *instance, gpointer g_class); void (*GInterfaceInitFunc) (gpointer g_iface, gpointer iface_data); void (*GInterfaceFinalizeFunc) (gpointer g_iface, gpointer iface_data); gboolean (*GTypeClassCacheFunc) (gpointer cache_data, GTypeClass *g_class); enum GTypeFlags; enum GTypeFundamentalFlags; GType g_type_register_static (GType parent_type, const gchar *type_name, const GTypeInfo *info, GTypeFlags flags); GType g_type_register_static_simple (GType parent_type, const gchar *type_name, guint class_size, GClassInitFunc class_init, guint instance_size, GInstanceInitFunc instance_init, GTypeFlags flags); GType g_type_register_dynamic (GType parent_type, const gchar *type_name, GTypePlugin *plugin, GTypeFlags flags); GType g_type_register_fundamental (GType type_id, const gchar *type_name, const GTypeInfo *info, const GTypeFundamentalInfo *finfo, GTypeFlags flags); void g_type_add_interface_static (GType instance_type, GType interface_type, const GInterfaceInfo *info); void g_type_add_interface_dynamic (GType instance_type, GType interface_type, GTypePlugin *plugin); void g_type_interface_add_prerequisite (GType interface_type, GType prerequisite_type); GTypePlugin* g_type_get_plugin (GType type); GTypePlugin* g_type_interface_get_plugin (GType instance_type, GType interface_type); GType g_type_fundamental_next (void); GType g_type_fundamental (GType type_id); GTypeInstance* g_type_create_instance (GType type); void g_type_free_instance (GTypeInstance *instance); void g_type_add_class_cache_func (gpointer cache_data, GTypeClassCacheFunc cache_func); void g_type_remove_class_cache_func (gpointer cache_data, GTypeClassCacheFunc cache_func); void g_type_class_unref_uncached (gpointer g_class); void g_type_add_interface_check (gpointer check_data, GTypeInterfaceCheckFunc check_func); void g_type_remove_interface_check (gpointer check_data, GTypeInterfaceCheckFunc check_func); void (*GTypeInterfaceCheckFunc) (gpointer check_data, gpointer g_iface); GTypeValueTable* g_type_value_table_peek (GType type); #define G_DEFINE_TYPE (TN, t_n, T_P) #define G_DEFINE_TYPE_WITH_CODE (TN, t_n, T_P, _C_) #define G_DEFINE_ABSTRACT_TYPE (TN, t_n, T_P) #define G_DEFINE_ABSTRACT_TYPE_WITH_CODE (TN, t_n, T_P, _C_) #define G_IMPLEMENT_INTERFACE (TYPE_IFACE, iface_init) #define G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, _f_, _C_) #define G_TYPE_INVALID #define G_TYPE_NONE #define G_TYPE_INTERFACE #define G_TYPE_CHAR #define G_TYPE_UCHAR #define G_TYPE_BOOLEAN #define G_TYPE_INT #define G_TYPE_UINT #define G_TYPE_LONG #define G_TYPE_ULONG #define G_TYPE_INT64 #define G_TYPE_UINT64 #define G_TYPE_ENUM #define G_TYPE_FLAGS #define G_TYPE_FLOAT #define G_TYPE_DOUBLE #define G_TYPE_STRING #define G_TYPE_POINTER #define G_TYPE_BOXED #define G_TYPE_PARAM #define G_TYPE_OBJECT #define G_TYPE_GTYPE #define G_TYPE_RESERVED_GLIB_FIRST #define G_TYPE_RESERVED_GLIB_LAST #define G_TYPE_RESERVED_BSE_FIRST #define G_TYPE_RESERVED_BSE_LAST #define G_TYPE_RESERVED_USER_FIRST Description
The GType API is the foundation of the GObject system. It provides the
facilities for registering and managing all fundamental data types,
user-defined object and interface types. Before using any GType
or GObject functions,
For type creation and registration purposes, all types fall into one of
two categories: static or dynamic. Static types are never loaded or
unloaded at run-time as dynamic types may be. Static types are created
with A final word about type names. Such an identifier needs to be at least three characters long. There is no upper length limit. The first character needs to be a letter (a-z or A-Z) or an underscore '_'. Subsequent characters can be letters, numbers or any of '-_+'.
DetailsG_TYPE_FUNDAMENTAL()#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type))
The fundamental type which is the ancestor of
G_TYPE_FUNDAMENTAL_MAX#define G_TYPE_FUNDAMENTAL_MAX (255 << G_TYPE_FUNDAMENTAL_SHIFT) An integer constant that represents the number of identifiers reserved for types that are assigned at compile-time.
G_TYPE_MAKE_FUNDAMENTAL()#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
Get the type ID for the fundamental type number
G_TYPE_IS_ABSTRACT()#define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))
Checks if
G_TYPE_IS_DERIVED()#define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX)
Checks if
G_TYPE_IS_FUNDAMENTAL()#define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX)
Checks if
G_TYPE_IS_VALUE_TYPE()#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type))
Checks if
G_TYPE_HAS_VALUE_TABLE()#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL)
Checks if
G_TYPE_IS_CLASSED()#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))
Checks if
G_TYPE_IS_INSTANTIATABLE()#define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))
Checks if
G_TYPE_IS_DERIVABLE()#define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE))
Checks if
G_TYPE_IS_DEEP_DERIVABLE()#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))
Checks if
G_TYPE_IS_INTERFACE()#define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE)
Checks if
GTypeInterfacetypedef struct { } GTypeInterface; An opaque structure used as the base of all interface types.
GTypeInstancetypedef struct { } GTypeInstance; An opaque structure used as the base of all type instances.
GTypeInfotypedef struct { /* interface types, classed types, instantiated types */ guint16 class_size; GBaseInitFunc base_init; GBaseFinalizeFunc base_finalize; /* interface types, classed types, instantiated types */ GClassInitFunc class_init; GClassFinalizeFunc class_finalize; gconstpointer class_data; /* instantiated types */ guint16 instance_size; guint16 n_preallocs; GInstanceInitFunc instance_init; /* value handling */ const GTypeValueTable *value_table; } GTypeInfo;
This structure is used to provide the type system with the information
required to initialize and destruct (finalize) a type's class and
its instances.
The initialized structure is passed to the
GTypeFundamentalInfotypedef struct { GTypeFundamentalFlags type_flags; } GTypeFundamentalInfo; A structure that provides information to the type system which is used specifically for managing fundamental types.
GInterfaceInfotypedef struct { GInterfaceInitFunc interface_init; GInterfaceFinalizeFunc interface_finalize; gpointer interface_data; } GInterfaceInfo; A structure that provides information to the type system which is used specifically for managing interface types.
GTypeValueTabletypedef struct { void (*value_init) (GValue *value); void (*value_free) (GValue *value); void (*value_copy) (const GValue *src_value, GValue *dest_value); /* varargs functionality (optional) */ gpointer (*value_peek_pointer) (const GValue *value); gchar *collect_format; gchar* (*collect_value) (GValue *value, guint n_collect_values, GTypeCValue *collect_values, guint collect_flags); gchar *lcopy_format; gchar* (*lcopy_value) (const GValue *value, guint n_collect_values, GTypeCValue *collect_values, guint collect_flags); } GTypeValueTable; The GTypeValueTable provides the functions required by the GValue implementation, to serve as a container for values of a type.
G_TYPE_FROM_INSTANCE()#define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class))
Get the type identifier from a given This macro should only be used in type implementations.
G_TYPE_FROM_CLASS()#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type)
Get the type identifier from a given This macro should only be used in type implementations.
G_TYPE_FROM_INTERFACE()#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type)
Get the type identifier from a given This macro should only be used in type implementations.
G_TYPE_INSTANCE_GET_CLASS()#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type))
Get the class structure of a given
Note that while calling a This macro should only be used in type implementations.
G_TYPE_INSTANCE_GET_INTERFACE()#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type))
Get the interface structure for interface This macro should only be used in type implementations.
G_TYPE_INSTANCE_GET_PRIVATE()#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type)))
Gets the private structure for a particular type.
The private structure must have been registered in the
class_init function with This macro should only be used in type implementations.
Since 2.4 G_TYPE_CHECK_INSTANCE()#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance)))
Checks if This macro should only be used in type implementations.
G_TYPE_CHECK_INSTANCE_CAST()#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
Checks that This macro should only be used in type implementations.
G_TYPE_CHECK_INSTANCE_TYPE()#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type)))
Checks if This macro should only be used in type implementations.
G_TYPE_CHECK_CLASS_CAST()#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type))
Checks that This macro should only be used in type implementations.
G_TYPE_CHECK_CLASS_TYPE()#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type)))
Checks if This macro should only be used in type implementations.
G_TYPE_CHECK_VALUE()#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value)))
Checks if This macro should only be used in type implementations.
G_TYPE_CHECK_VALUE_TYPE()#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type)))
Checks if This macro should only be used in type implementations.
G_TYPE_FLAG_RESERVED_ID_BIT#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0)) A bit in the type number that's supposed to be left untouched.
g_type_init ()void g_type_init (void);
Prior to any use of the type system,
enum GTypeDebugFlagstypedef enum /*< skip >*/ { G_TYPE_DEBUG_NONE = 0, G_TYPE_DEBUG_OBJECTS = 1 << 0, G_TYPE_DEBUG_SIGNALS = 1 << 1, G_TYPE_DEBUG_MASK = 0x03 } GTypeDebugFlags;
The GTypeDebugFlags enumeration values can be passed to
g_type_init_with_debug_flags ()void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags);
Similar to
g_type_name ()const gchar* g_type_name (GType type);
Get the unique name that is assigned to a type ID. Note that this
function (like all other GType API) cannot cope with invalid type
IDs.
g_type_qname ()GQuark g_type_qname (GType type); Get the corresponding quark of the type IDs name.
g_type_from_name ()GType g_type_from_name (const gchar *name); Lookup the type ID from a given type name, returning 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).
g_type_parent ()GType g_type_parent (GType type); 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.
g_type_depth ()guint g_type_depth (GType type); 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.
g_type_next_base ()GType g_type_next_base (GType leaf_type, GType root_type);
Given a
g_type_is_a ()gboolean g_type_is_a (GType type, GType is_a_type);
If
g_type_class_ref ()gpointer g_type_class_ref (GType type);
Increments the reference count of the class structure belonging to
g_type_class_peek ()gpointer g_type_class_peek (GType type);
This function is essentially the same as
g_type_class_peek_static ()gpointer g_type_class_peek_static (GType type);
A more efficient version of
Since 2.4 g_type_class_unref ()void g_type_class_unref (gpointer g_class);
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_peek_parent ()gpointer g_type_class_peek_parent (gpointer g_class); This is a convenience function often needed in class initializers. It returns the class structure of the immediate parent type of the class passed in. 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:
g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)));
g_type_class_add_private ()void g_type_class_add_private (gpointer g_class, gsize private_size);
Registers a private structure for an instantiatable type;
when an object is allocated, the private structures for
the type 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
typedef struct _MyObjectPrivate MyObjectPrivate; struct _MyObjectPrivate { int some_field; }; #define MY_OBJECT_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), MY_TYPE_OBJECT, MyObjectPrivate)) static void my_object_class_init (MyObjectClass *klass) { g_type_class_add_private (klass, sizeof (MyObjectPrivate)); } static int my_object_get_some_field (MyObject *my_object) { MyObjectPrivate *priv = MY_OBJECT_GET_PRIVATE (my_object); return priv->some_field; }
Since 2.4 g_type_interface_peek ()gpointer g_type_interface_peek (gpointer instance_class, GType iface_type); Returns the GTypeInterface structure of an interface to which the passed in class conforms.
g_type_interface_peek_parent ()gpointer g_type_interface_peek_parent (gpointer g_iface);
Returns the corresponding GTypeInterface structure of the parent type
of the instance type to which
g_type_default_interface_ref ()gpointer g_type_default_interface_ref (GType g_type);
Increments the reference count for the interface type
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 @
Since 2.4 g_type_default_interface_peek ()gpointer g_type_default_interface_peek (GType g_type);
If the interface type
Since 2.4 g_type_default_interface_unref ()void g_type_default_interface_unref (gpointer g_iface);
Decrements the reference count for the type corresponding to the
interface default vtable
Since 2.4 g_type_children ()GType* g_type_children (GType type, guint *n_children);
Return a newly allocated and 0-terminated array of type IDs, listing the
child types of
g_type_interfaces ()GType* g_type_interfaces (GType type, guint *n_interfaces);
Return a newly allocated and 0-terminated array of type IDs, listing the
interface types that
g_type_interface_prerequisites ()GType* g_type_interface_prerequisites (GType interface_type, guint *n_prerequisites); Returns the prerequisites of an interfaces type.
Since 2.2 g_type_set_qdata ()void g_type_set_qdata (GType type, GQuark quark, gpointer data); Attaches arbitrary data to a type.
g_type_get_qdata ()gpointer g_type_get_qdata (GType type, GQuark quark);
Obtains data which has previously been attached to
g_type_query ()void g_type_query (GType type, GTypeQuery *query);
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
GTypeQuerytypedef struct { GType type; const gchar *type_name; guint class_size; guint instance_size; } GTypeQuery;
A structure holding information for a specific type. It is
filled in by the
GBaseInitFunc ()void (*GBaseInitFunc) (gpointer g_class);
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.
For example, class members (such as strings) that are not sufficiently
handled by a plain memory copy of the parent class into the derived class
have to be altered. See
GBaseFinalizeFunc ()void (*GBaseFinalizeFunc) (gpointer g_class);
A callback function used by the type system to finalize those portions
of a derived types class structure that were setup from the corresponding
GClassInitFunc ()void (*GClassInitFunc) (gpointer g_class, gpointer class_data); 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:
Since derived classes are partially initialized through a memory copy
of the parent class, the general rule is that
typedef struct { GObjectClass parent_class; gint static_integer; gchar *dynamic_string; } TypeAClass; static void type_a_base_class_init (TypeAClass *class) { class->dynamic_string = g_strdup ("some string"); } static void type_a_base_class_finalize (TypeAClass *class) { g_free (class->dynamic_string); } static void type_a_class_init (TypeAClass *class) { class->static_integer = 42; } typedef struct { TypeAClass parent_class; gfloat static_float; GString *dynamic_gstring; } TypeBClass; static void type_b_base_class_init (TypeBClass *class) { class->dynamic_gstring = g_string_new ("some other string"); } static void type_b_base_class_finalize (TypeBClass *class) { g_string_free (class->dynamic_gstring); } static void type_b_class_init (TypeBClass *class) { class->static_float = 3.14159265358979323846; }
Initialization of TypeBClass will first cause initialization of
TypeAClass (derived classes reference their parent classes, see
GClassFinalizeFunc ()void (*GClassFinalizeFunc) (gpointer g_class, gpointer class_data);
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
GInstanceInitFunc ()void (*GInstanceInitFunc) (GTypeInstance *instance, gpointer g_class); 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, so 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.
GInterfaceInitFunc ()void (*GInterfaceInitFunc) (gpointer g_iface, gpointer iface_data); 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.
GInterfaceFinalizeFunc ()void (*GInterfaceFinalizeFunc) (gpointer g_iface, gpointer iface_data);
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
GTypeClassCacheFunc ()gboolean (*GTypeClassCacheFunc) (gpointer cache_data, GTypeClass *g_class);
A callback function which is called when the reference count of a class
drops to zero. It may use 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.
enum GTypeFlagstypedef enum /*< skip >*/ { G_TYPE_FLAG_ABSTRACT = (1 << 4), G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5) } GTypeFlags; Bit masks used to check or determine characteristics of a type.
enum GTypeFundamentalFlagstypedef enum /*< skip >*/ { G_TYPE_FLAG_CLASSED = (1 << 0), G_TYPE_FLAG_INSTANTIATABLE = (1 << 1), G_TYPE_FLAG_DERIVABLE = (1 << 2), G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3) } GTypeFundamentalFlags; Bit masks used to check or determine specific characteristics of a fundamental type.
g_type_register_static ()GType g_type_register_static (GType parent_type, const gchar *type_name, const GTypeInfo *info, GTypeFlags flags);
Registers
g_type_register_static_simple ()GType g_type_register_static_simple (GType parent_type, const gchar *type_name, guint class_size, GClassInitFunc class_init, guint instance_size, GInstanceInitFunc instance_init, GTypeFlags flags);
Registers
Since 2.12 g_type_register_dynamic ()GType g_type_register_dynamic (GType parent_type, const gchar *type_name, GTypePlugin *plugin, GTypeFlags flags);
Registers
g_type_register_fundamental ()GType g_type_register_fundamental (GType type_id, const gchar *type_name, const GTypeInfo *info, const GTypeFundamentalInfo *finfo, GTypeFlags flags);
Registers
g_type_add_interface_static ()void g_type_add_interface_static (GType instance_type, GType interface_type, const GInterfaceInfo *info);
Adds the static
g_type_add_interface_dynamic ()void g_type_add_interface_dynamic (GType instance_type, GType interface_type, GTypePlugin *plugin);
Adds the dynamic
g_type_interface_add_prerequisite ()void g_type_interface_add_prerequisite (GType interface_type, GType prerequisite_type);
Adds
g_type_get_plugin ()GTypePlugin* g_type_get_plugin (GType type);
Returns the GTypePlugin structure for
g_type_interface_get_plugin ()GTypePlugin* g_type_interface_get_plugin (GType instance_type, GType interface_type);
Returns the GTypePlugin structure for the dynamic interface
g_type_fundamental_next ()GType g_type_fundamental_next (void);
Returns the next free fundamental type id which can be used to
register a new fundamental type with
g_type_fundamental ()GType g_type_fundamental (GType type_id);
Internal function, used to extract the fundamental type ID portion.
use
g_type_create_instance ()GTypeInstance* g_type_create_instance (GType type);
Creates and initializes an instance of
g_type_free_instance ()void g_type_free_instance (GTypeInstance *instance); Frees an instance of a type, returning it to the instance pool for the type, if there is one.
Like
g_type_add_class_cache_func ()void g_type_add_class_cache_func (gpointer cache_data, GTypeClassCacheFunc cache_func);
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
g_type_remove_class_cache_func ()void g_type_remove_class_cache_func (gpointer cache_data, GTypeClassCacheFunc cache_func);
Removes a previously installed GTypeClassCacheFunc. The cache
maintained by
g_type_class_unref_uncached ()void g_type_class_unref_uncached (gpointer g_class);
A variant of
g_type_add_interface_check ()void g_type_add_interface_check (gpointer check_data, GTypeInterfaceCheckFunc check_func);
Adds a function to be called after an interface vtable is
initialized for any class (i.e. after the 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.
Since 2.4 g_type_remove_interface_check ()void g_type_remove_interface_check (gpointer check_data, GTypeInterfaceCheckFunc check_func);
Removes an interface check function added with
Since 2.4 GTypeInterfaceCheckFunc ()void (*GTypeInterfaceCheckFunc) (gpointer check_data, gpointer g_iface);
A callback called after an interface vtable is initialized.
See
Since 2.4 g_type_value_table_peek ()GTypeValueTable* g_type_value_table_peek (GType type);
Returns the location of the GTypeValueTable associated with
G_DEFINE_TYPE()#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
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
Since 2.4 G_DEFINE_TYPE_WITH_CODE()#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
A convenience macro for type implementations.
Similar to
Since 2.4 G_DEFINE_ABSTRACT_TYPE()#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
A convenience macro for type implementations.
Similar to
Since 2.4 G_DEFINE_ABSTRACT_TYPE_WITH_CODE()#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
A convenience macro for type implementations.
Similar to
Since 2.4 G_IMPLEMENT_INTERFACE()#define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)
A convenience macro to ease interface addition in the Note that this macro can only be used together with the G_DEFINE_TYPE_* macros, since it depends on variable names from those macros.
Since 2.4 G_DEFINE_TYPE_EXTENDED()#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
The most general convenience macro for type implementations, on which
G_DEFINE_TYPE_EXTENDED (GtkGadget, gtk_gadget, GTK_TYPE_WIDGET, 0, G_IMPLEMENT_INTERFACE (TYPE_GIZMO, gtk_gadget_gizmo_init)); expands to static void gtk_gadget_init (GtkGadget *self); static void gtk_gadget_class_init (GtkGadgetClass *klass); static gpointer gtk_gadget_parent_class = NULL; static void gtk_gadget_class_intern_init (gpointer klass) { gtk_gadget_parent_class = g_type_class_peek_parent (klass); gtk_gadget_class_init ((GtkGadgetClass*) klass); } GType gtk_gadget_get_type (void) { static GType g_define_type_id = 0; if (G_UNLIKELY (g_define_type_id == 0)) { static const GTypeInfo g_define_type_info = { sizeof (GtkGadgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gtk_gadget_class_intern_init, (GClassFinalizeFunc) NULL, NULL, // class_data sizeof (GtkGadget), 0, // n_preallocs (GInstanceInitFunc) gtk_gadget_init, }; g_define_type_id = g_type_register_static (GTK_TYPE_WIDGET, "GtkGadget", &g_define_type_info, 0); { static const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc) gtk_gadget_gizmo_init }; g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); } } return g_define_type_id; } 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.
Since 2.4 G_TYPE_INVALID#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0) An invalid GType used as error return value in some functions which return a GType.
G_TYPE_NONE#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
A fundamental type which is used as a replacement for the C
G_TYPE_INTERFACE#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2) The fundamental type from which all interfaces are derived.
G_TYPE_CHAR#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) The fundamental type corresponding to gchar. The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. This may or may not be the same type a the C type "gchar".
G_TYPE_UCHAR#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4) The fundamental type corresponding to guchar.
G_TYPE_BOOLEAN#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5) The fundamental type corresponding to gboolean.
G_TYPE_INT#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6) The fundamental type corresponding to gint.
G_TYPE_UINT#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7) The fundamental type corresponding to guint.
G_TYPE_LONG#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8) The fundamental type corresponding to glong.
G_TYPE_ULONG#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9) The fundamental type corresponding to gulong.
G_TYPE_INT64#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10) The fundamental type corresponding to gint64.
G_TYPE_UINT64#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11) The fundamental type corresponding to guint64.
G_TYPE_ENUM#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12) The fundamental type from which all enumeration types are derived.
G_TYPE_FLAGS#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13) The fundamental type from which all flags types are derived.
G_TYPE_FLOAT#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14) The fundamental type corresponding to gfloat.
G_TYPE_DOUBLE#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15) The fundamental type corresponding to gdouble.
G_TYPE_STRING#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16) The fundamental type corresponding to nul-terminated C strings.
G_TYPE_POINTER#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17) The fundamental type corresponding to gpointer.
G_TYPE_BOXED#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18) The fundamental type from which all boxed types are derived.
G_TYPE_PARAM#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19) The fundamental type from which all GParamSpec types are derived.
G_TYPE_RESERVED_GLIB_FIRST#define G_TYPE_RESERVED_GLIB_FIRST (21)
First fundamental type number to create a new fundamental type id with
G_TYPE_RESERVED_GLIB_LAST#define G_TYPE_RESERVED_GLIB_LAST (31) Last fundamental type number reserved for GLib.
G_TYPE_RESERVED_BSE_FIRST#define G_TYPE_RESERVED_BSE_FIRST (32)
First fundamental type number to create a new fundamental type id with
G_TYPE_RESERVED_BSE_LAST#define G_TYPE_RESERVED_BSE_LAST (48) Last fundamental type number reserved for BSE.
G_TYPE_RESERVED_USER_FIRST#define G_TYPE_RESERVED_USER_FIRST (49)
First available fundamental type number to create new fundamental
type id with
|