3 (define-foreign-type g-type-designator ()
5 (:documentation "Values of this type identify the GType. GType is designated by a its name (a string) or a numeric identifier. Functions accept GType designators as a string or integer and return them as a string. Functions @fun{g-type-name} and @fun{g-type-from-name} are used to convert between name and numeric identifier.")
7 (:simple-parser g-type-designator))
9 (defmethod translate-from-foreign (value (type g-type-designator))
12 (defmethod translate-to-foreign (value (type g-type-designator))
14 (string (g-type-from-name value))
16 (null +g-type-invalid+)))
18 (defcfun (g-type-fundamental "g_type_fundamental") g-type-designator
19 "Returns the fundamental type which is the ancestor of @code{type}.
20 @arg[type]{GType designator (see @class{g-type-fundamental})}
21 @return{GType designator}"
22 (type g-type-designator))
24 (defcfun (%g-type-init "g_type_init") :void)
26 (at-init () (%g-type-init))
28 (defcfun (g-type-name "g_type_name") :string
29 "Returns the name of a GType.
31 @arg[type]{GType designator (see @class{g-type-designator})}
33 (type g-type-designator))
35 (defcfun (g-type-from-name "g_type_from_name") g-type
36 "Returns the numeric identifier of a GType by its name
38 @arg[name]{a string - name of GType}
42 (defcfun g-type-parent g-type-designator
43 "Returns the parent of a GType
45 @arg[type]{GType designator (see @class{g-type-designator})}
46 @return{GType designator}"
47 (type g-type-designator))
49 (defcfun g-type-depth :uint
50 "Returns the length of the ancestry of @code{type}. This includes the @code{type} itself, so that e.g. a fundamental type has depth 1.
51 @arg[type]{GType designator (see @class{g-type-designator})}
53 (type g-type-designator))
55 (defcfun g-type-next-base g-type-designator
56 "Determines the type that is derived directly from @code{root-type} which is also a base class of @code{leaf-type}.
57 @arg[leaf-type]{GType designator (see @class{g-type-designator})}
58 @arg[root-type]{GType designator}
59 @return{GType designator}"
60 (leaf-type g-type-designator)
61 (root-type g-type-designator))
63 (defcfun g-type-is-a :boolean
64 "If @code{is-a-type} is a derivable type, check whether type is a descendant of @code{is-a-type}. If @code{is-a-type} is an interface, check whether type conforms to it.
65 @arg[type]{GType designator (see @class{g-type-designator})}
66 @arg[is-a-type]{GType designator}
68 (type g-type-designator)
69 (is-a-type g-type-designator))
71 (defcfun g-type-class-ref (:pointer g-type-class)
72 (type g-type-designator))
74 (defcfun g-type-class-unref :void
75 (class (:pointer g-type-class)))
77 (defcfun g-type-class-add-private :void
78 (class (:pointer g-type-class))
81 (defcfun g-type-default-interface-ref :pointer
82 (type g-type-designator))
84 (defcfun g-type-default-interface-unref :void
87 (defcfun (%g-type-children "g_type_children") (:pointer g-type)
88 (type g-type-designator)
89 (n-children (:pointer :uint)))
91 (defun g-type-children (g-type)
92 "Returns the list of types inherited from @code{g-type}.
94 @arg[g-type]{GType designator (see @class{g-type-designator})}
95 @return{list of GType designators}"
96 (with-foreign-object (n-children :uint)
97 (let ((g-types-ptr (%g-type-children g-type n-children)))
100 for i from 0 below (mem-ref n-children :uint)
101 collect (mem-aref g-types-ptr 'g-type-designator i))
102 (g-free g-types-ptr)))))
104 (defcfun (%g-type-interfaces "g_type_interfaces") (:pointer g-type)
105 (type g-type-designator)
106 (n-interfaces (:pointer :uint)))
108 (defun g-type-interfaces (g-type)
109 "Returns the list of interfaces the @code{g-type} conforms to.
111 @arg[g-type]{GType designator (see @class{g-type-designator})}
112 @return{list of GType designators}"
113 (with-foreign-object (n-interfaces :uint)
114 (let ((g-types-ptr (%g-type-interfaces g-type n-interfaces)))
117 for i from 0 below (mem-ref n-interfaces :uint)
118 collect (mem-aref g-types-ptr 'g-type-designator i))
119 (g-free g-types-ptr)))))
121 (defcfun (%g-type-interface-prerequisites "g_type_interface_prerequisites") (:pointer g-type)
122 (type g-type-designator)
123 (n-interface-prerequisites (:pointer :uint)))
125 (defun g-type-interface-prerequisites (g-type)
126 "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.
127 @arg[g-type]{GType designator (see @class{g-type-designator})}
128 @return{list of GType designators}"
129 (with-foreign-object (n-interface-prerequisites :uint)
130 (let ((g-types-ptr (%g-type-interface-prerequisites g-type n-interface-prerequisites)))
133 for i from 0 below (mem-ref n-interface-prerequisites :uint)
134 collect (mem-aref g-types-ptr 'g-type-designator i))
135 (g-free g-types-ptr)))))
137 (defcfun g-type-register-static g-type-designator
138 (parent-type g-type-designator)
140 (info (:pointer g-type-info))
141 (flags g-type-flags))
143 (defcfun g-type-register-static-simple g-type-designator
144 (parent-type g-type-designator)
147 (class-init :pointer)
148 (instance-size :uint)
149 (instance-init :pointer)
150 (flags g-type-flags))
152 (defcfun g-type-add-interface-static :void
153 (instance-type g-type-designator)
154 (interface-type g-type-designator)
155 (info (:pointer g-interface-info)))
157 (defcfun g-type-interface-add-prerequisite :void
158 (interface-type g-type-designator)
159 (prerequisite-type g-type-designator))
161 (defun g-type-from-object (object)
162 "Returns the GType of an @code{object}
164 @arg[object]{C pointer to an object}
165 @return{GType designator (see @class{g-type-designator})}"
166 (g-type-from-instance object))
168 (defun g-type-from-class (g-class)
169 (g-type-name (foreign-slot-value g-class 'g-type-class 'type)))
171 (defun g-type-from-instance (type-instance)
172 (g-type-from-class (foreign-slot-value type-instance 'g-type-instance 'class)))
174 (defun g-type-from-interface (type-interface)
175 (g-type-name (foreign-slot-value type-interface 'g-type-interface 'type)))
177 (defcfun g-strv-get-type g-type-designator)
179 (at-init nil (g-strv-get-type))
181 (defcfun g-closure-get-type g-type-designator)
183 (at-init nil (g-closure-get-type))
185 (defcfun g-type-query :void
186 (type g-type-designator)
187 (query (:pointer g-type-query)))