387230e8 |
1 | ;; Common Lisp bindings for GTK+ v2.0 |
2 | ;; Copyright (C) 2000 Espen S. Johnsen <esj@stud.cs.uit.no> |
3 | ;; |
4 | ;; This library is free software; you can redistribute it and/or |
5 | ;; modify it under the terms of the GNU Lesser General Public |
6 | ;; License as published by the Free Software Foundation; either |
7 | ;; version 2 of the License, or (at your option) any later version. |
8 | ;; |
9 | ;; This library is distributed in the hope that it will be useful, |
10 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | ;; Lesser General Public License for more details. |
13 | ;; |
14 | ;; You should have received a copy of the GNU Lesser General Public |
15 | ;; License along with this library; if not, write to the Free Software |
16 | ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | |
4c32c936 |
18 | ;; $Id: gparam.lisp,v 1.6 2002-03-19 17:01:42 espen Exp $ |
387230e8 |
19 | |
20 | (in-package "GLIB") |
21 | |
22 | (deftype gvalue () 'pointer) |
23 | |
4c32c936 |
24 | (defconstant +gvalue-size+ (+ (size-of 'type-number) (* 2 (size-of 'double-float)))) |
387230e8 |
25 | (defconstant +gvalue-value-offset+ (size-of 'type-number)) |
26 | |
4eb73e10 |
27 | (defbinding (gvalue-init "g_value_init") () nil |
387230e8 |
28 | (type type-number)) |
29 | |
30 | (defun gvalue-new (type) |
31 | (let ((gvalue (allocate-memory +gvalue-size+))) |
32 | (setf (system:sap-ref-32 gvalue 0) type) |
33 | ; (gvalue-init (type-number-of type)) |
34 | gvalue)) |
35 | |
36 | (defun gvalue-free (gvalue free-content) |
37 | (unless (null-pointer-p gvalue) |
38 | (when free-content |
39 | (funcall |
df0b4e7d |
40 | (intern-destroy-function (gvalue-type gvalue)) |
387230e8 |
41 | gvalue +gvalue-value-offset+)) |
42 | (deallocate-memory gvalue))) |
43 | |
44 | (defun gvalue-type (gvalue) |
45 | (type-from-number (system:sap-ref-32 gvalue 0))) |
46 | |
47 | (defun gvalue-get (gvalue) |
48 | (funcall |
df0b4e7d |
49 | (intern-reader-function (gvalue-type gvalue)) |
387230e8 |
50 | gvalue +gvalue-value-offset+)) |
51 | |
52 | (defun gvalue-set (gvalue value) |
53 | (funcall |
df0b4e7d |
54 | (intern-writer-function (gvalue-type gvalue)) |
387230e8 |
55 | value gvalue +gvalue-value-offset+) |
56 | value) |
57 | |
df0b4e7d |
58 | |
59 | (deftype param-flag-type () |
60 | '(flags |
4eb73e10 |
61 | (:readable 1) |
62 | (:writable 2) |
63 | (:construct 4) |
64 | (:construct-only 8) |
65 | (:lax-validation 16) |
66 | (:private 32))) |
df0b4e7d |
67 | |
68 | (eval-when (:compile-toplevel :load-toplevel :execute) |
69 | (defclass param (ginstance) |
70 | ((name |
71 | :allocation :alien |
72 | :reader param-name |
73 | :type string) |
df0b4e7d |
74 | (flags |
75 | :allocation :alien |
76 | :reader param-flags |
77 | :type param-flag-type) |
c630da1b |
78 | (value-type |
79 | :allocation :alien |
80 | :reader param-value-type |
81 | :type type-number) |
82 | (owner-type |
df0b4e7d |
83 | :allocation :alien |
c630da1b |
84 | :reader param-owner-type |
85 | :type type-number) |
86 | (nickname |
87 | :allocation :virtual |
f784870f |
88 | :getter "g_param_spec_get_nick" |
c630da1b |
89 | :reader param-nickname |
90 | :type string) |
91 | (documentation |
92 | :allocation :virtual |
f784870f |
93 | :getter "g_param_spec_get_blurb" |
c630da1b |
94 | :reader param-documentation |
95 | :type string)) |
df0b4e7d |
96 | (:metaclass ginstance-class) |
97 | (:ref "g_param_spec_ref") |
98 | (:unref "g_param_spec_unref"))) |
99 | |
100 | |
101 | (defclass param-char (param) |
102 | ((minimum |
103 | :allocation :alien |
104 | :reader param-char-minimum |
105 | :type char) |
106 | (maximum |
107 | :allocation :alien |
108 | :reader param-char-maximum |
109 | :type char) |
110 | (default-value |
111 | :allocation :alien |
112 | :reader param-char-default-value |
113 | :type char)) |
114 | (:metaclass ginstance-class)) |
115 | |
116 | (defclass param-unsigned-char (param) |
117 | ( |
118 | ; (minimum |
119 | ; :allocation :alien |
120 | ; :reader param-unsigned-char-minimum |
121 | ; :type unsigned-char) |
122 | ; (maximum |
123 | ; :allocation :alien |
124 | ; :reader param-unsigned-char-maximum |
125 | ; :type unsigned-char) |
126 | ; (default-value |
127 | ; :allocation :alien |
128 | ; :reader param-unsigned-char-default-value |
129 | ; :type unsigned-char) |
130 | ) |
131 | (:metaclass ginstance-class) |
132 | (:alien-name "GParamUChar")) |
133 | |
134 | (defclass param-boolean (param) |
135 | ((default-value |
136 | :allocation :alien |
137 | :reader param-boolean-default-value |
138 | :type boolean)) |
139 | (:metaclass ginstance-class)) |
140 | |
141 | (defclass param-int (param) |
142 | ((minimum |
143 | :allocation :alien |
144 | :reader param-int-minimum |
145 | :type int) |
146 | (maximum |
147 | :allocation :alien |
148 | :reader param-int-maximum |
149 | :type int) |
150 | (default-value |
151 | :allocation :alien |
152 | :reader param-int-default-value |
153 | :type int)) |
154 | (:metaclass ginstance-class)) |
155 | |
156 | (defclass param-unsigned-int (param) |
157 | ((minimum |
158 | :allocation :alien |
159 | :reader param-unsigned-int-minimum |
160 | :type unsigned-int) |
161 | (maximum |
162 | :allocation :alien |
163 | :reader param-unsigned-int-maximum |
164 | :type unsigned-int) |
165 | (default-value |
166 | :allocation :alien |
167 | :reader param-unsigned-int-default-value |
168 | :type unsigned-int)) |
169 | (:metaclass ginstance-class) |
170 | (:alien-name "GParamUInt")) |
171 | |
172 | (defclass param-long (param) |
173 | ((minimum |
174 | :allocation :alien |
175 | :reader param-long-minimum |
176 | :type long) |
177 | (maximum |
178 | :allocation :alien |
179 | :reader param-long-maximum |
180 | :type long) |
181 | (default-value |
182 | :allocation :alien |
183 | :reader param-long-default-value |
184 | :type long)) |
185 | (:metaclass ginstance-class)) |
186 | |
187 | (defclass param-unsigned-long (param) |
188 | ((minimum |
189 | :allocation :alien |
190 | :reader param-unsigned-long-minimum |
191 | :type unsigned-long) |
192 | (maximum |
193 | :allocation :alien |
194 | :reader param-unsigned-long-maximum |
195 | :type unsigned-long) |
196 | (default-value |
197 | :allocation :alien |
198 | :reader param-unsigned-long-default-value |
199 | :type unsigned-long)) |
200 | (:metaclass ginstance-class) |
201 | (:alien-name "GParamULong")) |
202 | |
203 | (defclass param-unichar (param) |
204 | () |
205 | (:metaclass ginstance-class)) |
206 | |
207 | (defclass param-enum (param) |
208 | ((class |
209 | :allocation :alien |
210 | :reader param-enum-class |
211 | :type pointer) |
212 | (default-value |
213 | :allocation :alien |
214 | :reader param-enum-default-value |
215 | :type long)) |
216 | (:metaclass ginstance-class)) |
217 | |
218 | (defclass param-flags (param) |
219 | ((class |
220 | :allocation :alien |
221 | :reader param-flags-class |
222 | :type pointer) |
223 | (default-value |
224 | :allocation :alien |
225 | :reader param-flags-default-value |
226 | :type long)) |
227 | (:metaclass ginstance-class)) |
228 | |
229 | (defclass param-single-float (param) |
230 | ((minimum |
231 | :allocation :alien |
232 | :reader param-single-float-minimum |
233 | :type single-float) |
234 | (maximum |
235 | :allocation :alien |
236 | :reader param-single-float-maximum |
237 | :type single-float) |
238 | (default-value |
239 | :allocation :alien |
240 | :reader param-single-float-default-value |
241 | :type single-float) |
242 | (epsilon |
243 | :allocation :alien |
244 | :reader param-single-float-epsilon |
245 | :type single-float)) |
246 | (:metaclass ginstance-class) |
247 | (:alien-name "GParamFloat")) |
248 | |
249 | (defclass param-double-float (param) |
250 | ((minimum |
251 | :allocation :alien |
252 | :reader param-double-float-minimum |
253 | :type double-float) |
254 | (maximum |
255 | :allocation :alien |
256 | :reader param-double-float-maximum |
257 | :type double-float) |
258 | (default-value |
259 | :allocation :alien |
260 | :reader param-double-float-default-value |
261 | :type double-float) |
262 | (epsilon |
263 | :allocation :alien |
264 | :reader param-double-float-epsilon |
265 | :type double-float)) |
266 | (:metaclass ginstance-class) |
267 | (:alien-name "GParamDouble")) |
268 | |
269 | (defclass param-string (param) |
270 | ((default-value |
271 | :allocation :alien |
272 | :reader param-string-default-value |
273 | :type string)) |
274 | (:metaclass ginstance-class)) |
275 | |
276 | (defclass param-param (param) |
277 | () |
278 | (:metaclass ginstance-class)) |
279 | |
280 | (defclass param-boxed (param) |
281 | () |
282 | (:metaclass ginstance-class)) |
283 | |
284 | (defclass param-pointer (param) |
285 | () |
286 | (:metaclass ginstance-class)) |
287 | |
288 | (defclass param-value-array (param) |
289 | ((element-spec |
290 | :allocation :alien |
291 | :reader param-value-array-element-spec |
292 | :type param) |
293 | (length |
294 | :allocation :alien |
295 | :reader param-value-array-length |
296 | :type unsigned-int)) |
297 | (:metaclass ginstance-class)) |
298 | |
f784870f |
299 | ;; (defclass param-closure (param) |
300 | ;; () |
301 | ;; (:metaclass ginstance-class)) |
df0b4e7d |
302 | |
303 | (defclass param-object (param) |
304 | () |
305 | (:metaclass ginstance-class)) |
306 | |
307 | |
308 | |