Type Information

G-Golf GObject Type Information low level API.
Type Information — The GLib Runtime type identification and management system

Procedures

g-type->symbol
symbol->g-type
g-type-from-class
g-type-name
g-type-from-name
g-type-parent
g-type-is-a
g-type-class-ref
g-type-class-peek
g-type-class-unref
g-type-class-peek-parent
g-type-interface-peek
g-type-interfaces
g-type-query
g-type-register-static-simple
g-type-add-interface-static
g-type-fundamental
g-type-ensure

Types and Values

%g-type-fundamental-flags
%g-type-fundamental-types

Object Hierarchy

gpointer
  +— GType

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.

Please read the Type Information section from the GObject reference manual for a complete description.

Procedures

Procedure: g-type->symbol g-type

Returns a symbol.

Get the symbol that correspond to the type ID g-type. Note that this function (like all other GType API) cannot cope with invalid type IDs. It accepts validly registered type ID, but randomized type IDs should not be passed in and will most likely lead to a crash.

Procedure: symbol->g-type symbol

Returns a type ID.

Get the type ID for symbol. Note that this function (like all other GType API) cannot cope with invalid type ID symbols. It accepts validly registered type ID symbol, but randomized type IDs should not be passed in and will most likely lead to a crash.

Procedure: g-type-from-class g-class

Returns a GType.

Obtains and returns the GType for g-class (a pointer to a valid GTypeClass structure).

Procedure: g-type-name g-type

Returns a string.

Get the unique name that is assigned to g-type, a type ID. Note that this function (like all other GType API) cannot cope with invalid type IDs. It accepts validly registered type ID, but randomized type IDs should not be passed in and will most likely lead to a crash.

Procedure: g-type-from-name name

Returns a type ID or #f.

Obtains and returns the type ID for the given type name, or #f 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).

Procedure: g-type-parent g-type

Returns a GType.

Returns the direct parent type for g-type. If g-type has no parent, i.e. is a fundamental type, 0 is returned.

Procedure: g-type-is-a g-type is-a-g-type

Returns #t if g-type is a is-a-g-type.

If is-a-g-type is a derivable type, check whether g-type is a descendant of is-a-g-type. If is-a-g-type is an interface, check whether g-type conforms to it.

Procedure: g-type-class-ref g-type

Returns a pointer.

Obtains and returns a pointer to the GTypeClass structure for g-type (a GObject class GType). The reference count of the class is incremented, and the class is ‘created’ (instanciated) if/when it doesn’t exist already.

Procedure: g-type-class-peek g-type

Returns a pointer.

Obtains and returns a pointer to the GTypeClass structure for g-type (a GObject class GType). The reference count of the class isn’t incremented. As a consequence, this function may return #f - if the class of the type passed in does not currently exist (hasn’t been referenced before).

Procedure: g-type-class-unref g-class

Returns nothing.

Decrements the reference count for g-class (a pointer to a GTypeClass structure). Once the last reference count of a class has been released, it may be finalized by the type system. Attempting to further dereference a finalized class is invalid.

Procedure: g-type-class-peek-parent g-class

Returns a pointer or #f.

Obtains and returns a pointer to the class structure of the immediate parent type for g-class (a pointer to a GTypeClass structure). If no immediate parent type exists, it returns #f.

Procedure: g-type-interface-peek g-class iface-type

Returns a pointer of #f.

Obtains and returns the (a pointer to) GTypeInterface structure for iface-type if implemented by g-class, Otherwise. it returs #f.

Procedure: g-type-interfaces g-type

Returns a (possibily empty) list.

Obtains and returns the (possibily empty) list of the interface IDs (g-type) that g-type conforms to.

Procedure: g-type-query g-type

Returns a list.

Obtains and returns the (g-type type-name class-size instance-size) list for g-type.

Procedure: g-type-register-static-simple parent-type type-name class-size class-init-func instance-size instance-init-func flags

Returns a new type ID.

Registers type-name as the name of a new static type derived from parent-type. The value of flags determines the nature (e.g. abstract or not) of the type. It works by filling a GTypeInfo struct and calling g_type_register_static.

Procedure: g-type-add-interface-static g-type iface-type iface-info

Returns nothing.

Adds iface-type to the static g-type. The information contained in the GInterfaceInfo structure pointed to by iface-info is used to manage the relationship.

If iface-info is #f, a new GInterfaceInfo structure is made, with iface-init-func and iface-finalize-func set to no-op procedures, and iface-data set to the %null-pointer (this is only meant to be used for testing and debugging purposes).

Procedure: g-type-fundamental g-type

Returns a type ID.

Extracts the fundamental type ID portion for g-type.

Procedure: g-type-ensure g-type

Returns nothing.

Ensures that the indicated g-type has been registered with the type system, and that its _class_init method has been run.

Types and Values

Instance Variable of <gi-enum>: %g-type-fundamental-flags

Bit masks used to check or determine specific characteristics of a fundamental type.

An instance of <gi-enum>, who’s members are the scheme representation of the GTypeFundamentalFlags:

g-name: GTypeFundamentalFlags
name: g-type-fundamental-flags
enum-set:

classed

Indicates a classed type

instantiable

Indicates an instantiable type (implies classed)

derivable

Indicates a flat derivable type

deep-derivable

Indicates a deep derivable type (implies derivable)

Instance Variable of <gi-enum>: %g-type-fundamental-types

An instance of <gi-enum>, who’s members are the scheme representation of the GType obtained from the fundamentl types defined using G_TYPE_MAKE_FUNDAMENTAL, which starts with G_TYPE_INVALID and ends with G_TYPE_OBJECT.

g-name: #f28

name: g-type-fundamental-types
enum-set:

invalid

An invalid GType used as error return value in some functions which return a GType.

none

A fundamental type which is used as a replacement for the C void return type.

interface

The fundamental type from which all interfaces are derived.

char

The fundamental type corresponding to gchar. It is unconditionally an 8-bit signed integer. This may or may not be the same type a the C type "gchar".

uchar

The fundamental type corresponding to guchar.

boolean

The fundamental type corresponding to gboolean.

int

The fundamental type corresponding to gint.

uint

The fundamental type corresponding to guint.

long

The fundamental type corresponding to glong.

ulong

The fundamental type corresponding to gulong.

int64

The fundamental type corresponding to gint64.

uint64

The fundamental type corresponding to guint64.

enum

The fundamental type from which all enumeration types are derived.

flags

The fundamental type from which all flags types are derived.

float

The fundamental type corresponding to gfloat.

double

The fundamental type corresponding to gdouble.

string

The fundamental type corresponding to nul-terminated C strings.

pointer

The fundamental type corresponding to gpointer.

boxed

The fundamental type from which all boxed types are derived.

param

The fundamental type from which all GParamSpec types are derived.

object

The fundamental type for GObject.


Footnotes

(28)

There is no corresponding enum in GOject. These fundamental types (in GObject) are defined using a macro, G_TYPE_MAKE_FUNDAMENTAL, that applies bitwise arithmetic shift given by G_TYPE_FUNDAMENTAL_SHIFT (which we also have to apply, to get to the type ID for the fundamental number x).