Details
GType
A numerical value which represents the unique identifier of a registered
type.
G_TYPE_FUNDAMENTAL()
#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type))
|
Returns TRUE if type is a fundamental data type such as G_TYPE_INT or
G_TYPE_POINTER. Fundamental types are types that serve as fundaments for
the derived types, thus they are the roots of distinct inheritance hierarchies.
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))
|
Returns the type ID for the fundamental type number x.
Use g_type_fundamental_next() instead of this macro to create new fundamental
types.
G_TYPE_IS_ABSTRACT()
#define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))
|
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.
G_TYPE_IS_DERIVED()
#define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX)
|
Returns TRUE if type is derived (or in object-oriented terminology:
inherited) from another type (this holds true for all non-fundamental
types).
G_TYPE_IS_FUNDAMENTAL()
#define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX)
|
Returns TRUE if type is a fundamental type.
G_TYPE_IS_VALUE_TYPE()
#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type))
|
G_TYPE_HAS_VALUE_TABLE()
#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL)
|
Returns TRUE if type has a GTypeValueTable.
G_TYPE_IS_CLASSED()
#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))
|
Returns TRUE if type is a classed type.
G_TYPE_IS_INSTANTIATABLE()
#define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))
|
Returns TRUE if type can be instantiated. Instantiation is the
process of creating an instance (object) of this type.
G_TYPE_IS_DERIVABLE()
#define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE))
|
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.
G_TYPE_IS_DEEP_DERIVABLE()
#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))
|
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.
G_TYPE_IS_INTERFACE()
#define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE)
|
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).
struct GTypeInterface
struct GTypeInterface
{
/*< private >*/
GType g_type; /* iface type */
GType g_instance_type;
};
|
An opaque structure used as the base of all interface types.
struct GTypeInstance
struct GTypeInstance
{
/*< private >*/
GTypeClass *g_class;
};
|
An opaque structure used as the base of all type instances.
struct GTypeInfo
struct GTypeInfo
{
/* interface types, classed types, instantiated types */
guint16 class_size;
GBaseInitFunc base_init;
GBaseFinalizeFunc base_finalize;
/* 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;
};
|
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().
struct GTypeFundamentalInfo
struct GTypeFundamentalInfo
{
GTypeFundamentalFlags type_flags;
};
|
A structure that provides information to the type system which is
used specifically for managing fundamental types.
struct GInterfaceInfo
struct GInterfaceInfo
{
GInterfaceInitFunc interface_init;
GInterfaceFinalizeFunc interface_finalize;
gpointer interface_data;
};
|
A structure that provides information to the type system which is
used specifically for managing interface types.
struct GTypeValueTable
struct GTypeValueTable
{
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);
};
|
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))
|
Returns the type identifier from a given instance structure.
G_TYPE_FROM_CLASS()
#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type)
|
Returns the type identifier from a given class structure.
G_TYPE_FROM_INTERFACE()
#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type)
|
Returns the type identifier from a given interface structure.
G_TYPE_INSTANCE_GET_CLASS()
#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type))
|
Returns the class structure of a given instance, casted
to a specified anchestor type g_type of the instance.
G_TYPE_INSTANCE_GET_INTERFACE()
#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type))
|
G_TYPE_CHECK_INSTANCE()
#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance)))
|
G_TYPE_CHECK_INSTANCE_CAST()
#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
|
G_TYPE_CHECK_INSTANCE_TYPE()
#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type)))
|
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))
|
G_TYPE_CHECK_CLASS_TYPE()
#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type)))
|
G_TYPE_CHECK_VALUE()
#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value)))
|
G_TYPE_CHECK_VALUE_TYPE()
#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type)))
|
G_TYPE_FLAG_RESERVED_ID_BIT
#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0))
|
g_type_init ()
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).
enum GTypeDebugFlags
typedef 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() 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".
g_type_init_with_debug_flags ()
Similar to g_type_init(), but additionally sets debug flags.
g_type_name ()
Return 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).
g_type_qname ()
Return the corresponding quark of the type IDs name.
g_type_from_name ()
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).
g_type_parent ()
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 ()
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 ()
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.
g_type_is_a ()
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.
g_type_class_ref ()
Increments the reference count of the class structure belonging to
type. This function will demand-create the class if it doesn't
exist already.
g_type_class_peek ()
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).
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_unref() are invalid.
g_type_class_peek_parent ()
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:
g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)));
|
g_type_interface_peek ()
Returns the GTypeInterface structure of an interface to which the passed in
class conforms.
g_type_interface_peek_parent ()
g_type_children ()
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.
g_type_interfaces ()
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.
struct GTypeQuery
struct GTypeQuery
{
GType type;
const gchar *type_name;
guint class_size;
guint instance_size;
};
|
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.
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.
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
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.
GClassInitFunc ()
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:
1 - Copying common members from the parent class over to the
derived class structure.
2 - Zero initialization of the remaining members not copied
over from the parent class.
3 - Invocation of the GBaseInitFunc() initializers of all parent
types and the class' type.
4 - Invocation of the class' GClassInitFunc() initializer.
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:
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
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.
GClassFinalizeFunc ()
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).
GInstanceInitFunc ()
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.
GInterfaceInitFunc ()
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 ()
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.
enum GTypeFlags
typedef 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 GTypeFundamentalFlags
typedef 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 ()
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.
g_type_register_dynamic ()
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.
g_type_register_fundamental ()
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.
g_type_add_interface_static ()
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.
g_type_add_interface_dynamic ()
g_type_interface_add_prerequisite ()
void g_type_interface_add_prerequisite
(GType interface_type,
GType prerequisite_type); |
g_type_get_plugin ()
Returns the GTypePlugin structure for type or
NULL if type does not have a GTypePlugin structure.
g_type_interface_get_plugin ()
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_register_fundamental().
The returned type ID represents the highest currently registered
fundamental type identifier.
g_type_fundamental ()
Internal function, used to extract the fundamental type ID portion.
use G_TYPE_FUNDAMENTAL() instead.
g_type_create_instance ()
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.
g_type_add_class_cache_func ()
g_type_remove_class_cache_func ()
g_type_class_unref_uncached ()
void g_type_class_unref_uncached (gpointer g_class); |
g_type_value_table_peek ()
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.
G_TYPE_INVALID
#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0)
|
G_TYPE_NONE
#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
|
G_TYPE_INTERFACE
#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2)
|
G_TYPE_CHAR
#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3)
|
G_TYPE_UCHAR
#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4)
|
G_TYPE_BOOLEAN
#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5)
|
G_TYPE_INT
#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)
|
G_TYPE_UINT
#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7)
|
G_TYPE_LONG
#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8)
|
G_TYPE_ULONG
#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9)
|
G_TYPE_INT64
#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10)
|
G_TYPE_UINT64
#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11)
|
G_TYPE_ENUM
#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12)
|
G_TYPE_FLAGS
#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13)
|
G_TYPE_FLOAT
#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14)
|
G_TYPE_DOUBLE
#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15)
|
G_TYPE_STRING
#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16)
|
G_TYPE_POINTER
#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17)
|
G_TYPE_BOXED
#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18)
|
G_TYPE_PARAM
#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19)
|
G_TYPE_OBJECT
#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
|
G_TYPE_RESERVED_GLIB_FIRST
#define G_TYPE_RESERVED_GLIB_FIRST (21)
|
G_TYPE_RESERVED_GLIB_LAST
#define G_TYPE_RESERVED_GLIB_LAST (31)
|
G_TYPE_RESERVED_BSE_FIRST
#define G_TYPE_RESERVED_BSE_FIRST (32)
|
G_TYPE_RESERVED_BSE_LAST
#define G_TYPE_RESERVED_BSE_LAST (48)
|
G_TYPE_RESERVED_USER_FIRST
#define G_TYPE_RESERVED_USER_FIRST (49)
|