1 (defpackage :gobject.type-info
2 (:use :cl :iter :cffi :glib :gobject.ffi)
3 (:export #:+g-type-invalid+
35 #:g-type-interface-prerequisites
38 #:g-class-property-definition
39 #:g-class-property-definition-name
40 #:g-class-property-definition-type
41 #:g-class-property-definition-readable
42 #:g-class-property-definition-writable
43 #:g-class-property-definition-constructor
44 #:g-class-property-definition-constructor-only
45 #:g-class-property-definition-owner-type
48 #:interface-properties
62 #:signal-info-owner-type
64 #:signal-info-return-type
65 #:signal-info-param-types
70 #:class-property-info)
72 "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}
74 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.
77 @item{@fun{g-type-name} and @fun{g-type-from-name} convert between numeric and string representation of GType.}
78 @item{@fun{g-type-parent}, @fun{g-type-children} and @fun{g-type-interfaces} traverse across the type hierarchy.}
79 @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}
82 This is a list of variables and functions that correspond to basic types:
84 @item{@fun{g-closure-get-type}}
85 @item{@fun{g-strv-get-type}}
86 @item{@variable{+g-type-invalid+}}
87 @item{@variable{+g-type-void+}}
88 @item{@variable{+g-type-interface+}}
89 @item{@variable{+g-type-char+}}
90 @item{@variable{+g-type-uchar+}}
91 @item{@variable{+g-type-boolean+}}
92 @item{@variable{+g-type-int+}}
93 @item{@variable{+g-type-uint+}}
94 @item{@variable{+g-type-long+}}
95 @item{@variable{+g-type-ulong+}}
96 @item{@variable{+g-type-int64+}}
97 @item{@variable{+g-type-uint64+}}
98 @item{@variable{+g-type-enum+}}
99 @item{@variable{+g-type-flags+}}
100 @item{@variable{+g-type-float+}}
101 @item{@variable{+g-type-double+}}
102 @item{@variable{+g-type-string+}}
103 @item{@variable{+g-type-pointer+}}
104 @item{@variable{+g-type-boxed+}}
105 @item{@variable{+g-type-param+}}
106 @item{@variable{+g-type-object+}}
110 (in-package :gobject.type-info)
112 (defctype g-type gsize)
114 (eval-when (:load-toplevel :compile-toplevel)
115 (defun gtype-make-fundamental-type (x)
118 (defconstant +g-type-invalid+ (gtype-make-fundamental-type 0) "An invalid GType used as error return value in some functions which return a GType.")
119 (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.")
120 (defconstant +g-type-interface+ (gtype-make-fundamental-type 2) "The fundamental type from which all interfaces are derived.")
121 (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}.")
122 (defconstant +g-type-uchar+ (gtype-make-fundamental-type 4) "The fundamental type corresponding to @code{guchar}.")
123 (defconstant +g-type-boolean+ (gtype-make-fundamental-type 5) "The fundamental type corresponding to @code{gboolean}.")
124 (defconstant +g-type-int+ (gtype-make-fundamental-type 6) "The fundamental type corresponding to @code{gint}.")
125 (defconstant +g-type-uint+ (gtype-make-fundamental-type 7) "The fundamental type corresponding to @code{guint}.")
126 (defconstant +g-type-long+ (gtype-make-fundamental-type 8) "The fundamental type corresponding to @code{glong}.")
127 (defconstant +g-type-ulong+ (gtype-make-fundamental-type 9) "The fundamental type corresponding to @code{gulong}.")
128 (defconstant +g-type-int64+ (gtype-make-fundamental-type 10) "The fundamental type corresponding to @code{gint64}.")
129 (defconstant +g-type-uint64+ (gtype-make-fundamental-type 11) "The fundamental type corresponding to @code{guint64}.")
130 (defconstant +g-type-enum+ (gtype-make-fundamental-type 12) "The fundamental type from which all enumeration types are derived.")
131 (defconstant +g-type-flags+ (gtype-make-fundamental-type 13) "The fundamental type from which all flags types are derived.")
132 (defconstant +g-type-float+ (gtype-make-fundamental-type 14) "The fundamental type corresponding to @code{gfloat}.")
133 (defconstant +g-type-double+ (gtype-make-fundamental-type 15) "The fundamental type corresponding to @code{gdouble}.")
134 (defconstant +g-type-string+ (gtype-make-fundamental-type 16) "The fundamental type corresponding to null-terminated C strings.")
135 (defconstant +g-type-pointer+ (gtype-make-fundamental-type 17) "The fundamental type corresponding to @code{gpointer}.")
136 (defconstant +g-type-boxed+ (gtype-make-fundamental-type 18) "The fundamental type from which all boxed types are derived.")
137 (defconstant +g-type-param+ (gtype-make-fundamental-type 19) "The fundamental type from which all GParamSpec types are derived.")
138 (defconstant +g-type-object+ (gtype-make-fundamental-type 20) "The fundamental type for GObject.")
140 (defun g-type-children (g-type)
141 "Returns the list of types inherited from @code{g-type}.@see{g-type-parent}
145 \(g-type-children \"GtkObject\")
146 => (\"GtkWidget\" \"GtkAdjustment\" \"GtkTreeViewColumn\" \"GtkCellRenderer\"
147 \"GtkFileFilter\" \"GtkRecentFilter\" \"GtkTooltips\")
149 @arg[g-type]{GType designator (see @class{g-type-designator})}
150 @return{list of GType designators}"
151 (with-foreign-object (n-children :uint)
152 (let ((g-types-ptr (%g-type-children g-type n-children)))
155 for i from 0 below (mem-ref n-children :uint)
156 collect (mem-aref g-types-ptr 'g-type-designator i))
157 (g-free g-types-ptr)))))
159 (defun g-type-interfaces (g-type)
160 "Returns the list of interfaces the @code{g-type} conforms to.
164 \(g-type-interfaces \"GtkButton\")
165 => (\"AtkImplementorIface\" \"GtkBuildable\" \"GtkActivatable\")
167 @arg[g-type]{GType designator (see @class{g-type-designator})}
168 @return{list of GType designators}"
169 (with-foreign-object (n-interfaces :uint)
170 (let ((g-types-ptr (%g-type-interfaces g-type n-interfaces)))
173 for i from 0 below (mem-ref n-interfaces :uint)
174 collect (mem-aref g-types-ptr 'g-type-designator i))
175 (g-free g-types-ptr)))))
177 (defun g-type-interface-prerequisites (g-type)
178 "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.
182 \(g-type-interface-prerequisites \"GtkTreeModel\")
185 @arg[g-type]{GType designator (see @class{g-type-designator})}
186 @return{list of GType designators}"
187 (with-foreign-object (n-interface-prerequisites :uint)
188 (let ((g-types-ptr (%g-type-interface-prerequisites g-type n-interface-prerequisites)))
191 for i from 0 below (mem-ref n-interface-prerequisites :uint)
192 collect (mem-aref g-types-ptr 'g-type-designator i))
193 (g-free g-types-ptr)))))