Next: , Previous: Introduction, Up: Top


2 GType designator

GObject is an object system based on GType type system. Types in it are identified by an integer value of type GType. In cl-gtk2-gobject, types are identified by GType designators. GType designator is an integer (equal to corresponding GType identifier) or a string (equal to the name of corresponding type). The important difference between GType and GType designator is that GType values may change between program runs (all GTypes except fundamental GTypes will change values), but string GType designators do not change (because names of types do not change). As such, if ever GType must be saved in a code, string GType designator should be preferred.

An example of GType designator is a string "GObject" and the numeric value 80 that corresponds to it.

Some of the types are fundamental and have constant integer values. They are identified by constants (strings in parentheses are corresponding type names):

Functions g-type-string and g-type-numeric return the numeric and string representations of GType designators (given any of them). Functions g-type= and g-type/= check types for equality.

Invalid type (the GType that does not exist) is identified as a 0 or NIL.

     (g-type-numeric "GObject") => 80
     (g-type-numeric 80) => 80
     (g-type-string "GObject") => "GObject"
     (g-type-string 80) => "GObject"
     (g-type-numeric "GtkWidget") => 6905648 ;;Will be different on each run