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
60 "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}
62 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.
65 @item{@fun{g-type-name} and @fun{g-type-from-name} convert between numeric and string representation of GType.}
66 @item{@fun{g-type-parent}, @fun{g-type-children} and @fun{g-type-interfaces} traverse across the type hierarchy.}
67 @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}
70 This is a list of variables and functions that correspond to basic types:
72 @item{@fun{g-closure-get-type}}
73 @item{@fun{g-strv-get-type}}
74 @item{@variable{+g-type-invalid+}}
75 @item{@variable{+g-type-void+}}
76 @item{@variable{+g-type-interface+}}
77 @item{@variable{+g-type-char+}}
78 @item{@variable{+g-type-uchar+}}
79 @item{@variable{+g-type-boolean+}}
80 @item{@variable{+g-type-int+}}
81 @item{@variable{+g-type-uint+}}
82 @item{@variable{+g-type-long+}}
83 @item{@variable{+g-type-ulong+}}
84 @item{@variable{+g-type-int64+}}
85 @item{@variable{+g-type-uint64+}}
86 @item{@variable{+g-type-enum+}}
87 @item{@variable{+g-type-flags+}}
88 @item{@variable{+g-type-float+}}
89 @item{@variable{+g-type-double+}}
90 @item{@variable{+g-type-string+}}
91 @item{@variable{+g-type-pointer+}}
92 @item{@variable{+g-type-boxed+}}
93 @item{@variable{+g-type-param+}}
94 @item{@variable{+g-type-object+}}
98 (in-package :gobject.type-info)
100 (defctype g-type gsize)
102 (eval-when (:load-toplevel :compile-toplevel)
103 (defun gtype-make-fundamental-type (x)
106 (defconstant +g-type-invalid+ (gtype-make-fundamental-type 0) "An invalid GType used as error return value in some functions which return a GType.")
107 (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.")
108 (defconstant +g-type-interface+ (gtype-make-fundamental-type 2) "The fundamental type from which all interfaces are derived.")
109 (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}.")
110 (defconstant +g-type-uchar+ (gtype-make-fundamental-type 4) "The fundamental type corresponding to @code{guchar}.")
111 (defconstant +g-type-boolean+ (gtype-make-fundamental-type 5) "The fundamental type corresponding to @code{gboolean}.")
112 (defconstant +g-type-int+ (gtype-make-fundamental-type 6) "The fundamental type corresponding to @code{gint}.")
113 (defconstant +g-type-uint+ (gtype-make-fundamental-type 7) "The fundamental type corresponding to @code{guint}.")
114 (defconstant +g-type-long+ (gtype-make-fundamental-type 8) "The fundamental type corresponding to @code{glong}.")
115 (defconstant +g-type-ulong+ (gtype-make-fundamental-type 9) "The fundamental type corresponding to @code{gulong}.")
116 (defconstant +g-type-int64+ (gtype-make-fundamental-type 10) "The fundamental type corresponding to @code{gint64}.")
117 (defconstant +g-type-uint64+ (gtype-make-fundamental-type 11) "The fundamental type corresponding to @code{guint64}.")
118 (defconstant +g-type-enum+ (gtype-make-fundamental-type 12) "The fundamental type from which all enumeration types are derived.")
119 (defconstant +g-type-flags+ (gtype-make-fundamental-type 13) "The fundamental type from which all flags types are derived.")
120 (defconstant +g-type-float+ (gtype-make-fundamental-type 14) "The fundamental type corresponding to @code{gfloat}.")
121 (defconstant +g-type-double+ (gtype-make-fundamental-type 15) "The fundamental type corresponding to @code{gdouble}.")
122 (defconstant +g-type-string+ (gtype-make-fundamental-type 16) "The fundamental type corresponding to null-terminated C strings.")
123 (defconstant +g-type-pointer+ (gtype-make-fundamental-type 17) "The fundamental type corresponding to @code{gpointer}.")
124 (defconstant +g-type-boxed+ (gtype-make-fundamental-type 18) "The fundamental type from which all boxed types are derived.")
125 (defconstant +g-type-param+ (gtype-make-fundamental-type 19) "The fundamental type from which all GParamSpec types are derived.")
126 (defconstant +g-type-object+ (gtype-make-fundamental-type 20) "The fundamental type for GObject.")
128 (defun g-type-children (g-type)
129 "Returns the list of types inherited from @code{g-type}.@see{g-type-parent}
133 \(g-type-children \"GtkObject\")
134 => (\"GtkWidget\" \"GtkAdjustment\" \"GtkTreeViewColumn\" \"GtkCellRenderer\"
135 \"GtkFileFilter\" \"GtkRecentFilter\" \"GtkTooltips\")
137 @arg[g-type]{GType designator (see @class{g-type-designator})}
138 @return{list of GType designators}"
139 (with-foreign-object (n-children :uint)
140 (let ((g-types-ptr (%g-type-children g-type n-children)))
143 for i from 0 below (mem-ref n-children :uint)
144 collect (mem-aref g-types-ptr 'g-type-designator i))
145 (g-free g-types-ptr)))))
147 (defun g-type-interfaces (g-type)
148 "Returns the list of interfaces the @code{g-type} conforms to.
152 \(g-type-interfaces \"GtkButton\")
153 => (\"AtkImplementorIface\" \"GtkBuildable\" \"GtkActivatable\")
155 @arg[g-type]{GType designator (see @class{g-type-designator})}
156 @return{list of GType designators}"
157 (with-foreign-object (n-interfaces :uint)
158 (let ((g-types-ptr (%g-type-interfaces g-type n-interfaces)))
161 for i from 0 below (mem-ref n-interfaces :uint)
162 collect (mem-aref g-types-ptr 'g-type-designator i))
163 (g-free g-types-ptr)))))
165 (defun g-type-interface-prerequisites (g-type)
166 "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.
170 \(g-type-interface-prerequisites \"GtkTreeModel\")
173 @arg[g-type]{GType designator (see @class{g-type-designator})}
174 @return{list of GType designators}"
175 (with-foreign-object (n-interface-prerequisites :uint)
176 (let ((g-types-ptr (%g-type-interface-prerequisites g-type n-interface-prerequisites)))
179 for i from 0 below (mem-ref n-interface-prerequisites :uint)
180 collect (mem-aref g-types-ptr 'g-type-designator i))
181 (g-free g-types-ptr)))))