f72b125e91a5a1a970a2bbd753c82157858d5e19
[cl-gtk2.git] / glib / gobject.type.lisp
1 (in-package :gobject)
2
3 (defcfun (g-type-fundamental "g_type_fundamental") g-type
4   (type-id g-type))
5
6 (defcfun (%g-type-init "g_type_init") :void)
7
8 (at-init () (%g-type-init))
9
10 (defcfun (g-type-name "g_type_name") :string
11   "Returns the GType name
12
13 @arg[type]{an integer specifying the GType}
14 @return{a string - name of type}"
15   (type g-type))
16
17 (defcfun (g-type-from-name "g_type_from_name") g-type
18   "Looks up the GType by its name
19
20 @arg[name]{a string naming the type}
21 @return{an integer specifying GType}"
22   (name :string))
23
24 (defcfun g-type-parent g-type
25   "Returns the parent of a GType
26
27 @arg[type]{an integer specifying the GType}
28 @return{an integer specifying the parent GType}"
29   (type g-type))
30
31 (defcfun g-type-depth :uint
32   (type g-type))
33
34 (defcfun g-type-next-base g-type
35   (leaf-type g-type)
36   (root-type g-type))
37
38 (defcfun g-type-is-a :boolean
39   (type g-type)
40   (is-a-type g-type))
41
42 (defcfun g-type-class-ref (:pointer g-type-class)
43   (type g-type))
44
45 (defcfun g-type-class-unref :void
46   (class (:pointer g-type-class)))
47
48 (defcfun g-type-class-add-private :void
49   (class (:pointer g-type-class))
50   (private-size gsize))
51
52 (defcfun g-type-default-interface-ref :pointer
53   (type g-type))
54
55 (defcfun g-type-default-interface-unref :void
56   (interface :pointer))
57
58 (defcfun (%g-type-children "g_type_children") (:pointer g-type)
59   (type g-type)
60   (n-children (:pointer :uint)))
61
62 (defun g-type-children (g-type)
63   "Returns the list of types inherited from @code{g-type}.
64
65 @arg[g-type]{an integer or a string specifying type}"
66   (setf g-type (ensure-g-type g-type))
67   (with-foreign-object (n-children :uint)
68     (let ((g-types-ptr (%g-type-children g-type n-children)))
69       (prog1
70           (loop
71              for i from 0 below (mem-ref n-children :uint)
72              collect (mem-aref g-types-ptr 'g-type i))
73         (g-free g-types-ptr)))))
74
75 (defcfun (%g-type-interfaces "g_type_interfaces") (:pointer g-type)
76   (type g-type)
77   (n-interfaces (:pointer :uint)))
78
79 (defun g-type-interfaces (g-type)
80   (setf g-type (ensure-g-type g-type))
81   (with-foreign-object (n-interfaces :uint)
82     (let ((g-types-ptr (%g-type-interfaces g-type n-interfaces)))
83       (prog1
84           (loop
85              for i from 0 below (mem-ref n-interfaces :uint)
86              collect (mem-aref g-types-ptr 'g-type i))
87         (g-free g-types-ptr)))))
88
89 (defcfun (%g-type-interface-prerequisites "g_type_interface_prerequisites") (:pointer g-type)
90   (type g-type)
91   (n-interface-prerequisites (:pointer :uint)))
92
93 (defun g-type-interface-prerequisites (g-type)
94   (with-foreign-object (n-interface-prerequisites :uint)
95     (let ((g-types-ptr (%g-type-interface-prerequisites g-type n-interface-prerequisites)))
96       (prog1
97           (loop
98              for i from 0 below (mem-ref n-interface-prerequisites :uint)
99              collect (mem-aref g-types-ptr 'g-type i))
100         (g-free g-types-ptr)))))
101
102 (defcfun g-type-register-static g-type
103   (parent-type g-type)
104   (type-name :string)
105   (info (:pointer g-type-info))
106   (flags g-type-flags))
107
108 (defcfun g-type-register-static-simple g-type
109   (parent-type g-type)
110   (type-name :string)
111   (class-size :uint)
112   (class-init :pointer)
113   (instance-size :uint)
114   (instance-init :pointer)
115   (flags g-type-flags))
116
117 (defcfun g-type-add-interface-static :void
118   (instance-type g-type)
119   (interface-type g-type)
120   (info (:pointer g-interface-info)))
121
122 (defcfun g-type-interface-add-prerequisite :void
123   (interface-type g-type)
124   (prerequisite-type g-type))
125
126 (defun g-type-from-object (object)
127   "Returns the GType of an @code{object}
128
129 @arg[object]{C pointer to an object}
130 @return{an integer specifying the GType}"
131   (g-type-from-instance object))
132
133 (defun g-type-from-class (g-class)
134   (foreign-slot-value g-class 'g-type-class 'type))
135
136 (defun g-type-from-instance (type-instance)
137   (g-type-from-class (foreign-slot-value type-instance 'g-type-instance 'class)))
138
139 (defun g-type-from-interface (type-interface)
140   (foreign-slot-value type-interface 'g-type-interface 'type))
141
142 (defcfun g-strv-get-type g-type)
143
144 (g-strv-get-type)
145
146 (defcfun g-closure-get-type g-type)
147
148 (g-closure-get-type)
149
150 (defcfun g-type-query :void
151   (type g-type)
152   (query (:pointer g-type-query)))