1 (defpackage :gobject.type-info
2 (:use :cl :iter :cffi :glib :gobject.ffi)
3 (:export #:+g-type-invalid+
35 #:g-type-interface-prerequisites
39 "This package contains functions for querying the basic type information from GObject type system. For an overview of GObject type system, see @a[http://library.gnome.org/devel/gobject/stable/index.html]{GObject documentation}
41 Types are identified by GType designators that are specified in @class{g-type-designator}. Functions of this package provide means to query basic information about type.
44 @item{@fun{g-type-name} and @fun{g-type-from-name} convert between numeric and string representation of GType.}
45 @item{@fun{g-type-parent}, @fun{g-type-children} and @fun{g-type-interfaces} traverse across the type hierarchy.}
46 @item{@fun{g-type-depth}, @fun{g-type-fundamental}, @fun{g-type-is-a}, @fun{g-type-next-base} are convenience functions that provide useful information from type hierarchy}
49 This is a list of variables and functions that correspond to basic types:
51 @item{@fun{g-closure-get-type}}
52 @item{@fun{g-strv-get-type}}
53 @item{@variable{+g-type-invalid+}}
54 @item{@variable{+g-type-void+}}
55 @item{@variable{+g-type-interface+}}
56 @item{@variable{+g-type-char+}}
57 @item{@variable{+g-type-uchar+}}
58 @item{@variable{+g-type-boolean+}}
59 @item{@variable{+g-type-int+}}
60 @item{@variable{+g-type-uint+}}
61 @item{@variable{+g-type-long+}}
62 @item{@variable{+g-type-ulong+}}
63 @item{@variable{+g-type-int64+}}
64 @item{@variable{+g-type-uint64+}}
65 @item{@variable{+g-type-enum+}}
66 @item{@variable{+g-type-flags+}}
67 @item{@variable{+g-type-float+}}
68 @item{@variable{+g-type-double+}}
69 @item{@variable{+g-type-string+}}
70 @item{@variable{+g-type-pointer+}}
71 @item{@variable{+g-type-boxed+}}
72 @item{@variable{+g-type-param+}}
73 @item{@variable{+g-type-object+}}
77 (in-package :gobject.type-info)
79 (defctype g-type gsize)
81 (eval-when (:load-toplevel :compile-toplevel)
82 (defun gtype-make-fundamental-type (x)
85 (defconstant +g-type-invalid+ (gtype-make-fundamental-type 0) "An invalid GType used as error return value in some functions which return a GType.")
86 (defconstant +g-type-void+ (gtype-make-fundamental-type 1) "A fundamental type which is used as a replacement for the C @code{void} return type.")
87 (defconstant +g-type-interface+ (gtype-make-fundamental-type 2) "The fundamental type from which all interfaces are derived.")
88 (defconstant +g-type-char+ (gtype-make-fundamental-type 3) "The fundamental type corresponding to gchar. The type designated by @variable{+g-type-char+} is unconditionally an 8-bit signed integer. This may or may not be the same type a the C type @code{gchar}.")
89 (defconstant +g-type-uchar+ (gtype-make-fundamental-type 4) "The fundamental type corresponding to @code{guchar}.")
90 (defconstant +g-type-boolean+ (gtype-make-fundamental-type 5) "The fundamental type corresponding to @code{gboolean}.")
91 (defconstant +g-type-int+ (gtype-make-fundamental-type 6) "The fundamental type corresponding to @code{gint}.")
92 (defconstant +g-type-uint+ (gtype-make-fundamental-type 7) "The fundamental type corresponding to @code{guint}.")
93 (defconstant +g-type-long+ (gtype-make-fundamental-type 8) "The fundamental type corresponding to @code{glong}.")
94 (defconstant +g-type-ulong+ (gtype-make-fundamental-type 9) "The fundamental type corresponding to @code{gulong}.")
95 (defconstant +g-type-int64+ (gtype-make-fundamental-type 10) "The fundamental type corresponding to @code{gint64}.")
96 (defconstant +g-type-uint64+ (gtype-make-fundamental-type 11) "The fundamental type corresponding to @code{guint64}.")
97 (defconstant +g-type-enum+ (gtype-make-fundamental-type 12) "The fundamental type from which all enumeration types are derived.")
98 (defconstant +g-type-flags+ (gtype-make-fundamental-type 13) "The fundamental type from which all flags types are derived.")
99 (defconstant +g-type-float+ (gtype-make-fundamental-type 14) "The fundamental type corresponding to @code{gfloat}.")
100 (defconstant +g-type-double+ (gtype-make-fundamental-type 15) "The fundamental type corresponding to @code{gdouble}.")
101 (defconstant +g-type-string+ (gtype-make-fundamental-type 16) "The fundamental type corresponding to null-terminated C strings.")
102 (defconstant +g-type-pointer+ (gtype-make-fundamental-type 17) "The fundamental type corresponding to @code{gpointer}.")
103 (defconstant +g-type-boxed+ (gtype-make-fundamental-type 18) "The fundamental type from which all boxed types are derived.")
104 (defconstant +g-type-param+ (gtype-make-fundamental-type 19) "The fundamental type from which all GParamSpec types are derived.")
105 (defconstant +g-type-object+ (gtype-make-fundamental-type 20) "The fundamental type for GObject.")
107 (defun g-type-children (g-type)
108 "Returns the list of types inherited from @code{g-type}.@see{g-type-parent}
112 \(g-type-children \"GtkObject\")
113 => (\"GtkWidget\" \"GtkAdjustment\" \"GtkTreeViewColumn\" \"GtkCellRenderer\"
114 \"GtkFileFilter\" \"GtkRecentFilter\" \"GtkTooltips\")
116 @arg[g-type]{GType designator (see @class{g-type-designator})}
117 @return{list of GType designators}"
118 (with-foreign-object (n-children :uint)
119 (let ((g-types-ptr (%g-type-children g-type n-children)))
122 for i from 0 below (mem-ref n-children :uint)
123 collect (mem-aref g-types-ptr 'g-type-designator i))
124 (g-free g-types-ptr)))))
126 (defun g-type-interfaces (g-type)
127 "Returns the list of interfaces the @code{g-type} conforms to.
131 \(g-type-interfaces \"GtkButton\")
132 => (\"AtkImplementorIface\" \"GtkBuildable\" \"GtkActivatable\")
134 @arg[g-type]{GType designator (see @class{g-type-designator})}
135 @return{list of GType designators}"
136 (with-foreign-object (n-interfaces :uint)
137 (let ((g-types-ptr (%g-type-interfaces g-type n-interfaces)))
140 for i from 0 below (mem-ref n-interfaces :uint)
141 collect (mem-aref g-types-ptr 'g-type-designator i))
142 (g-free g-types-ptr)))))
144 (defun g-type-interface-prerequisites (g-type)
145 "Returns the prerequisites of an interface type. Prerequisite is a type that must be a superclass of an implementing class or an interface that the object must also implement.
149 \(g-type-interface-prerequisites \"GtkTreeModel\")
152 @arg[g-type]{GType designator (see @class{g-type-designator})}
153 @return{list of GType designators}"
154 (with-foreign-object (n-interface-prerequisites :uint)
155 (let ((g-types-ptr (%g-type-interface-prerequisites g-type n-interface-prerequisites)))
158 for i from 0 below (mem-ref n-interface-prerequisites :uint)
159 collect (mem-aref g-types-ptr 'g-type-designator i))
160 (g-free g-types-ptr)))))