glib: make arguments in type decision procedure ignorable to inhibit warnings
[cl-gtk2.git] / glib / gobject.boxed.lisp
1 (in-package :gobject)
2
3 (define-foreign-type g-boxed-foreign-type ()
4   ((info :initarg :info
5          :accessor g-boxed-foreign-info
6          :initform (error "info must be specified"))
7    (return-p :initarg :return-p
8              :accessor g-boxed-foreign-return-p
9              :initform nil))
10   (:actual-type :pointer))
11
12 (eval-when (:compile-toplevel :load-toplevel :execute)
13   (defstruct g-boxed-info
14     name
15     g-type))
16
17 (eval-when (:compile-toplevel :load-toplevel :execute)
18   (defun get-g-boxed-foreign-info (name)
19     (get name 'g-boxed-foreign-info)))
20
21 (defvar *g-type-name->g-boxed-foreign-info* (make-hash-table :test 'equal))
22
23 (defun get-g-boxed-foreign-info-for-gtype (g-type-designator)
24   (or (gethash (g-type-string g-type-designator) *g-type-name->g-boxed-foreign-info*)
25       (error "Unknown GBoxed type '~A'" (g-type-string g-type-designator))))
26
27 (defgeneric make-foreign-type (info &key return-p))
28
29 (define-parse-method g-boxed-foreign (name &rest options)
30   (let ((info (get-g-boxed-foreign-info name)))
31     (assert info nil "Unknown foreign GBoxed type ~A" name)
32     (make-foreign-type info :return-p (member :return options))))
33
34 (defgeneric boxed-copy-fn (type-info native)
35   (:method (type-info native)
36     (g-boxed-copy (g-boxed-info-g-type type-info) native)))
37
38 (defmethod boxed-copy-fn :before (type-info native)
39   (format t "(boxed-copy-fn ~A ~A)~%" (g-boxed-info-name type-info) native))
40
41 (defgeneric boxed-free-fn (type-info native)
42   (:method (type-info native)
43     (g-boxed-free (g-boxed-info-g-type type-info) native)))
44
45 (defmethod boxed-free-fn :before (type-info native)
46   (format t "(boxed-free-fn ~A ~A)~%" (g-boxed-info-name type-info) native))
47
48 (defmethod has-callback-cleanup ((type g-boxed-foreign-type))
49   t)
50
51 (eval-when (:load-toplevel :compile-toplevel :execute)
52   (defstruct (g-boxed-cstruct-wrapper-info (:include g-boxed-info))
53     cstruct-description))
54
55 (defclass boxed-cstruct-foreign-type (g-boxed-foreign-type) ())
56
57 (defstruct cstruct-slot-description
58   name
59   type
60   count
61   initform)
62
63 (defmethod make-load-form ((object cstruct-slot-description) &optional environment)
64   (make-load-form-saving-slots object :environment environment))
65
66 (defstruct cstruct-description
67   name
68   slots)
69
70 (defmethod make-load-form ((object cstruct-description) &optional environment)
71   (make-load-form-saving-slots object :environment environment))
72
73 (defun parse-cstruct-slot (slot)
74   (destructuring-bind (name type &key count initform) slot
75     (make-cstruct-slot-description :name name :type type :count count :initform initform)))
76
77 (defun parse-cstruct-definition (name slots)
78   (make-cstruct-description :name name
79                             :slots (mapcar #'parse-cstruct-slot slots)))
80
81 (defmacro define-g-boxed-cstruct (name g-type-name &body slots)
82   (let ((cstruct-description (parse-cstruct-definition name slots)))
83     `(progn
84        (defstruct ,name
85          ,@(iter (for slot in (cstruct-description-slots cstruct-description))
86                  (for name = (cstruct-slot-description-name slot))
87                  (for initform = (cstruct-slot-description-initform slot))
88                  (collect (list name initform))))
89        (defcstruct ,(generated-cstruct-name name)
90          ,@(iter (for slot in (cstruct-description-slots cstruct-description))
91                  (for name = (cstruct-slot-description-name slot))
92                  (for type = (cstruct-slot-description-type slot))
93                  (for count = (cstruct-slot-description-count slot))
94                  (collect `(,name ,type ,@(when count `(:count ,count))))))
95        (defcunion ,(generated-cunion-name name)
96          (,name ,(generated-cstruct-name name)))
97        (eval-when (:compile-toplevel :load-toplevel :execute)
98          (setf (get ',name 'g-boxed-foreign-info)
99                (make-g-boxed-cstruct-wrapper-info :name ',name
100                                                   :g-type ,g-type-name
101                                                   :cstruct-description ,cstruct-description)
102                (gethash ,g-type-name *g-type-name->g-boxed-foreign-info*)
103                (get ',name 'g-boxed-foreign-info))))))
104
105 (defmethod make-foreign-type ((info g-boxed-cstruct-wrapper-info) &key return-p)
106   (make-instance 'boxed-cstruct-foreign-type :info info :return-p return-p))
107
108 (defun memcpy (target source bytes)
109   (iter (for i from 0 below bytes)
110         (setf (mem-aref target :uchar i)
111               (mem-aref source :uchar i))))
112
113 (defmethod boxed-copy-fn ((info g-boxed-cstruct-wrapper-info) native)
114   (if (g-boxed-info-g-type info)
115       (g-boxed-copy (g-boxed-info-g-type info) native)
116       (let ((copy (foreign-alloc (generated-cstruct-name (g-boxed-info-name info)))))
117         (memcpy copy native (foreign-type-size (generated-cstruct-name (g-boxed-info-name info))))
118         copy)))
119
120 (defmethod boxed-free-fn ((info g-boxed-cstruct-wrapper-info) native)
121   (if (g-boxed-info-g-type info)
122       (g-boxed-free (g-boxed-info-g-type info) native)
123       (foreign-free native)))
124
125 (defun copy-slots-to-native (proxy native cstruct-description)
126   (iter (with cstruct-type = (generated-cstruct-name (cstruct-description-name cstruct-description)))
127         (for slot in (cstruct-description-slots cstruct-description))
128         (for slot-name = (cstruct-slot-description-name slot))
129         (cond
130           ((cstruct-slot-description-count slot)
131            (iter (with ptr = (foreign-slot-pointer native cstruct-type slot-name))
132                  (with array = (slot-value proxy slot-name))
133                  (for i from 0 below (cstruct-slot-description-count slot))
134                  (setf (mem-aref ptr (cstruct-slot-description-type slot) i)
135                        (aref array i))))
136           (t
137            (setf (foreign-slot-value native cstruct-type slot-name)
138                  (slot-value proxy slot-name))))))
139
140 (defun copy-slots-to-proxy (proxy native cstruct-description)
141   (iter (with cstruct-type = (generated-cstruct-name (cstruct-description-name cstruct-description)))
142         (for slot in (cstruct-description-slots cstruct-description))
143         (for slot-name = (cstruct-slot-description-name slot))
144         (cond
145           ((cstruct-slot-description-count slot)
146            (setf (slot-value proxy slot-name) (make-array (list (cstruct-slot-description-count slot))))
147            (iter (with ptr = (foreign-slot-pointer native cstruct-type slot-name))
148                  (with array = (slot-value proxy slot-name))
149                  (for i from 0 below (cstruct-slot-description-count slot))
150                  (setf (aref array i)
151                        (mem-aref ptr (cstruct-slot-description-type slot) i))))
152           (t (setf (slot-value proxy slot-name)
153                    (foreign-slot-value native cstruct-type slot-name))))))
154
155 (defmethod translate-to-foreign (proxy (type boxed-cstruct-foreign-type))
156   (if (null proxy)
157       (null-pointer)
158       (let* ((info (g-boxed-foreign-info type))
159              (native-structure-type (generated-cstruct-name (g-boxed-info-name info))))
160         (with-foreign-object (native-structure native-structure-type)
161           (copy-slots-to-native proxy native-structure (g-boxed-cstruct-wrapper-info-cstruct-description info))
162           (values (boxed-copy-fn info native-structure) proxy)))))
163
164 (defmethod free-translated-object (native-structure (type boxed-cstruct-foreign-type) proxy)
165   (when proxy
166     (let ((info (g-boxed-foreign-info type)))
167       (copy-slots-to-proxy proxy native-structure (g-boxed-cstruct-wrapper-info-cstruct-description info))
168       (boxed-free-fn info native-structure))))
169
170 (defmethod translate-from-foreign (native-structure (type boxed-cstruct-foreign-type))
171   (unless (null-pointer-p native-structure)
172     (let* ((info (g-boxed-foreign-info type))
173            (proxy-structure-type (g-boxed-info-name info))
174            (proxy (make-instance proxy-structure-type)))
175       (copy-slots-to-proxy proxy native-structure (g-boxed-cstruct-wrapper-info-cstruct-description info))
176       (when (g-boxed-foreign-return-p type)
177         (boxed-free-fn info native-structure))
178       proxy)))
179
180 (defmethod cleanup-translated-object-for-callback ((type boxed-cstruct-foreign-type) proxy native-structure)
181   (when proxy
182     (let ((info (g-boxed-foreign-info type)))
183       (copy-slots-to-native proxy native-structure (g-boxed-cstruct-wrapper-info-cstruct-description info)))))
184
185 (eval-when (:compile-toplevel :load-toplevel :execute)
186   (defstruct (g-boxed-opaque-wrapper-info (:include g-boxed-info))
187     alloc free))
188
189 (define-foreign-type boxed-opaque-foreign-type (g-boxed-foreign-type) ())
190
191 (defclass g-boxed-opaque ()
192   ((pointer :initarg :pointer
193             :initform nil
194             :accessor g-boxed-opaque-pointer)))
195
196 (defmethod make-foreign-type ((info g-boxed-opaque-wrapper-info) &key return-p)
197   (make-instance 'boxed-opaque-foreign-type :info info :return-p return-p))
198
199 (defmethod translate-to-foreign (proxy (type boxed-opaque-foreign-type))
200   (prog1 (g-boxed-opaque-pointer proxy)
201     (when (g-boxed-foreign-return-p type)
202       (tg:cancel-finalization proxy)
203       (setf (g-boxed-opaque-pointer proxy) nil))))
204
205 (defmethod free-translated-object (native (type boxed-opaque-foreign-type) param)
206   (declare (ignore native type param)))
207
208 (defun make-boxed-free-finalizer (type pointer)
209   (lambda () (boxed-free-fn type pointer)))
210
211 (defmethod translate-from-foreign (native (foreign-type boxed-opaque-foreign-type))
212   (let* ((type (g-boxed-foreign-info foreign-type))
213          (proxy (make-instance (g-boxed-info-name type) :pointer native)))
214     (tg:finalize proxy (make-boxed-free-finalizer type native))))
215
216 (defmethod cleanup-translated-object-for-callback ((type boxed-opaque-foreign-type) proxy native)
217   (tg:cancel-finalization proxy)
218   (setf (g-boxed-opaque-pointer proxy) nil))
219
220 (defmacro define-g-boxed-opaque (name g-type-name &key
221                                  (alloc (error "Alloc must be specified")))
222   (let ((native-copy (gensym "NATIVE-COPY-"))
223         (instance (gensym "INSTANCE-"))
224         (finalizer (gensym "FINALIZER-")))
225     `(progn (defclass ,name (g-boxed-opaque) ())
226             (defmethod initialize-instance :after ((,instance ,name) &key &allow-other-keys)
227               (unless (g-boxed-opaque-pointer ,instance)
228                 (let ((,native-copy ,alloc))
229                   (flet ((,finalizer () (boxed-free-fn ,g-type-name ,native-copy)))
230                     (setf (g-boxed-opaque-pointer ,instance) ,native-copy)
231                     (finalize ,instance (make-boxed-free-finalizer (get ',name 'g-boxed-foreign-info) ,native-copy))))))
232             (eval-when (:compile-toplevel :load-toplevel :execute)
233               (setf (get ',name 'g-boxed-foreign-info)
234                     (make-g-boxed-opaque-wrapper-info :name ',name
235                                                       :g-type ,g-type-name)
236                     (gethash ,g-type-name *g-type-name->g-boxed-foreign-info*)
237                     (get ',name 'g-boxed-foreign-info))))))
238
239 (defstruct var-structure
240   name
241   parent
242   slots
243   discriminator-slot
244   variants
245   resulting-cstruct-description)
246
247 (defstruct var-structure-variant
248   discriminating-values
249   structure)
250
251 (defmethod make-load-form ((object var-structure) &optional env)
252   (make-load-form-saving-slots object :environment env))
253
254 (defmethod make-load-form ((object var-structure-variant) &optional env)
255   (make-load-form-saving-slots object :environment env))
256
257 (defun var-struct-all-slots (struct)
258   (when struct
259     (append (var-struct-all-slots (var-structure-parent struct))
260             (var-structure-slots struct))))
261
262 (defun all-structures (structure)
263   (append (iter (for variant in (var-structure-variants structure))
264                 (appending (all-structures (var-structure-variant-structure variant))))
265           (list structure)))
266
267 (defun parse-variant-structure-definition (name slots &optional parent)
268   (iter (with result = (make-var-structure :name name
269                                            :parent parent
270                                            :slots nil
271                                            :discriminator-slot nil
272                                            :variants nil))
273         (for slot in slots)
274         (if (eq :variant (first slot))
275             (progn
276               (when (var-structure-discriminator-slot result)
277                 (error "Structure has more than one discriminator slot"))
278               (setf (var-structure-discriminator-slot result) (second slot)
279                     (var-structure-variants result) (parse-variants result (nthcdr 2 slot))))
280             (push (parse-cstruct-slot slot) (var-structure-slots result)))
281         (finally (setf (var-structure-slots result)
282                        (reverse (var-structure-slots result)))
283                  (unless parent
284                    (set-variant-result-structure result))
285                  (return result))))
286
287 (defun set-variant-result-structure (var-structure)
288   (setf (var-structure-resulting-cstruct-description var-structure)
289         (make-cstruct-description
290          :name
291          (var-structure-name var-structure)
292          :slots
293          (append
294           (when (var-structure-parent var-structure)
295             (cstruct-description-slots (var-structure-resulting-cstruct-description (var-structure-parent var-structure))))
296           (var-structure-slots var-structure))))
297   (iter (for variant in (var-structure-variants var-structure))
298         (for child-var-structure = (var-structure-variant-structure variant))
299         (set-variant-result-structure child-var-structure)))
300
301 (defun ensure-list (thing)
302   (if (listp thing)
303       thing
304       (list thing)))
305
306 (defun parse-variants (parent variants)
307   (iter (for var-descr in variants)
308         (for (options variant-name . slots) in variants)
309         (for variant =
310              (make-var-structure-variant
311               :discriminating-values (ensure-list options)
312               :structure (parse-variant-structure-definition variant-name slots parent)))
313         (collect variant)))
314
315 (defpackage :gobject.boxed.generated-names)
316
317 (defun generated-cstruct-name (symbol)
318   (or (get symbol 'generated-cstruct-name)
319       (setf (get symbol 'generated-cstruct-name) (gentemp (format nil "CSTRUCT-~A" (symbol-name symbol)) (find-package :gobject.boxed.generated-names)))))
320
321 (defun generated-cunion-name (symbol)
322   (or (get symbol 'generated-cunion-name)
323       (setf (get symbol 'generated-cunion-name) (gentemp (format nil "CUNION-~A" (symbol-name symbol)) (find-package :gobject.boxed.generated-names)))))
324
325 (defun generate-cstruct-1 (struct)
326   `(defcstruct ,(generated-cstruct-name (cstruct-description-name struct))
327      ,@(iter (for slot in (cstruct-description-slots struct))
328              (collect `(,(cstruct-slot-description-name slot) ,(cstruct-slot-description-type slot)
329                          ,@(when (cstruct-slot-description-count slot)
330                                  `(:count ,(cstruct-slot-description-count slot))))))))
331
332 (defun generate-c-structures (structure)
333   (iter (for str in (all-structures structure))
334         (for cstruct = (var-structure-resulting-cstruct-description str))
335         (collect (generate-cstruct-1 cstruct))))
336
337 (defun generate-variant-union (struct)
338   `(defcunion ,(generated-cunion-name (var-structure-name struct))
339      ,@(iter (for str in (all-structures struct))
340              (collect `(,(var-structure-name str)
341                          ,(generated-cstruct-name (var-structure-name str)))))))
342
343 (defun generate-structure-1 (str)
344   `(defstruct ,(if (var-structure-parent str)
345                    `(,(var-structure-name str) (:include ,(var-structure-name (var-structure-parent str))
346                                                          (,(var-structure-discriminator-slot (var-structure-parent str))
347                                                            ,(first (var-structure-variant-discriminating-values
348                                                                     (find str
349                                                                           (var-structure-variants
350                                                                            (var-structure-parent str))
351                                                                           :key #'var-structure-variant-structure))))))
352                    `,(var-structure-name str))
353      ,@(iter (for slot in (var-structure-slots str))
354              (collect `(,(cstruct-slot-description-name slot)
355                          ,(cstruct-slot-description-initform slot))))))
356
357 (defun generate-structures (str)
358   (iter (for variant in (reverse (all-structures str)))
359         (collect (generate-structure-1 variant))))
360
361 (defun generate-native-type-decision-procedure-1 (str proxy-var)
362   (if (null (var-structure-discriminator-slot str))
363       `(values ',(var-structure-resulting-cstruct-description str))
364       `(typecase ,proxy-var
365          ,@(iter (for variant in (var-structure-variants str))
366                  (for v-str = (var-structure-variant-structure variant))
367                  (collect `(,(var-structure-name v-str)
368                              ,(generate-native-type-decision-procedure-1 v-str proxy-var))))
369          (,(var-structure-name str)
370           (values ',(var-structure-resulting-cstruct-description str))))))
371
372 (defun generate-proxy-type-decision-procedure-1 (str native-var)
373   (if (null (var-structure-discriminator-slot str))
374       `(values ',(var-structure-name str)
375                ',(var-structure-resulting-cstruct-description str))
376       `(case (foreign-slot-value ,native-var
377                                  ',(generated-cstruct-name (var-structure-name str))
378                                  ',(var-structure-discriminator-slot str))
379          ,@(iter (for variant in (var-structure-variants str))
380                  (for v-str = (var-structure-variant-structure variant))
381                  (collect `(,(var-structure-variant-discriminating-values variant)
382                              ,(generate-proxy-type-decision-procedure-1
383                                v-str
384                                native-var))))
385          (t (values ',(var-structure-name str)
386                     ',(var-structure-resulting-cstruct-description str))))))
387
388 (defun generate-proxy-type-decision-procedure (str)
389   (let ((native (gensym "NATIVE-")))
390     `(lambda (,native)
391        (declare (ignorable ,native))
392        ,(generate-proxy-type-decision-procedure-1 str native))))
393
394 (defun generate-native-type-decision-procedure (str)
395   (let ((proxy (gensym "PROXY-")))
396     `(lambda (,proxy)
397        (declare (ignorable ,proxy))
398        ,(generate-native-type-decision-procedure-1 str proxy))))
399
400 (defun compile-proxy-type-decision-procedure (str)
401   (compile nil (generate-proxy-type-decision-procedure str)))
402
403 (defun compile-native-type-decision-procedure (str)
404   (compile nil (generate-native-type-decision-procedure str)))
405
406 (defstruct (g-boxed-variant-cstruct-info (:include g-boxed-info))
407   root
408   native-type-decision-procedure
409   proxy-type-decision-procedure)
410
411 (defmethod make-load-form ((object g-boxed-variant-cstruct-info) &optional env)
412   (make-load-form-saving-slots object :environment env))
413
414 (define-foreign-type boxed-variant-cstruct-foreign-type (g-boxed-foreign-type) ())
415
416 (defmethod make-foreign-type ((info g-boxed-variant-cstruct-info) &key return-p)
417   (make-instance 'boxed-variant-cstruct-foreign-type :info info :return-p return-p))
418
419 (defmacro define-g-boxed-variant-cstruct (name g-type-name &body slots)
420   (let* ((structure (parse-variant-structure-definition name slots)))
421     `(progn ,@(generate-c-structures structure)
422             ,(generate-variant-union structure)
423             ,@(generate-structures structure)
424             (eval-when (:compile-toplevel :load-toplevel :execute)
425               (setf (get ',name 'g-boxed-foreign-info)
426                     (make-g-boxed-variant-cstruct-info :name ',name
427                                                        :g-type ,g-type-name
428                                                        :root ,structure
429                                                        :native-type-decision-procedure
430                                                        ,(generate-native-type-decision-procedure structure)
431                                                        :proxy-type-decision-procedure
432                                                        ,(generate-proxy-type-decision-procedure structure))
433                     (gethash ,g-type-name *g-type-name->g-boxed-foreign-info*)
434                     (get ',name 'g-boxed-foreign-info))))))
435
436 (defun decide-native-type (info proxy)
437   (funcall (g-boxed-variant-cstruct-info-native-type-decision-procedure info) proxy))
438
439 (defmethod boxed-copy-fn ((info g-boxed-variant-cstruct-info) native)
440   (if (g-boxed-info-g-type info)
441       (g-boxed-copy (g-boxed-info-g-type info) native)
442       (let ((copy (foreign-alloc (generated-cunion-name (g-boxed-info-name info)))))
443         (memcpy copy native (foreign-type-size (generated-cunion-name (g-boxed-info-name info))))
444         copy)))
445
446 (defmethod boxed-free-fn ((info g-boxed-variant-cstruct-info) native)
447   (if (g-boxed-info-g-type info)
448       (g-boxed-free (g-boxed-info-g-type info) native)
449       (foreign-free native)))
450
451 (defmethod translate-to-foreign (proxy (foreign-type boxed-variant-cstruct-foreign-type))
452   (if (null proxy)
453       (null-pointer)
454       (let* ((type (g-boxed-foreign-info foreign-type))
455              (cstruct-description (decide-native-type type proxy)))
456         (with-foreign-object (native-structure (generated-cstruct-name
457                                                 (var-structure-name
458                                                  (g-boxed-variant-cstruct-info-root type))))
459           (copy-slots-to-native proxy native-structure cstruct-description)
460           (values (boxed-copy-fn type native-structure) proxy)))))
461
462 (defun decide-proxy-type (info native-structure)
463   (funcall (g-boxed-variant-cstruct-info-proxy-type-decision-procedure info) native-structure))
464
465 (defmethod free-translated-object (native (foreign-type boxed-variant-cstruct-foreign-type) proxy)
466   (when proxy
467     (let ((type (g-boxed-foreign-info foreign-type)))
468       (multiple-value-bind (actual-struct cstruct-description) (decide-proxy-type type native)
469         (unless (eq (type-of proxy) actual-struct)
470           (restart-case
471               (error "Expected type of boxed variant structure ~A and actual type ~A do not match"
472                      (type-of proxy) actual-struct)
473             (skip-parsing-values () (return-from free-translated-object))))
474         (copy-slots-to-proxy proxy native cstruct-description)
475         (boxed-free-fn type native)))))
476
477 (defmethod translate-from-foreign (native (foreign-type boxed-variant-cstruct-foreign-type))
478   (unless (null-pointer-p native)
479     (let ((type (g-boxed-foreign-info foreign-type)))
480       (multiple-value-bind (actual-struct cstruct-description) (decide-proxy-type type native)
481         (let ((proxy (make-instance actual-struct)))
482           (copy-slots-to-proxy proxy native cstruct-description)
483           (when (g-boxed-foreign-return-p foreign-type)
484             (boxed-free-fn type native))
485           proxy)))))
486
487 (defmethod cleanup-translated-object-for-callback ((foreign-type boxed-variant-cstruct-foreign-type) proxy native)
488   (when proxy
489     (let ((type (g-boxed-foreign-info foreign-type)))
490       (let ((cstruct-description (decide-native-type type proxy)))
491         (copy-slots-to-native proxy native cstruct-description)))))
492
493 (defgeneric boxed-parse-g-value (gvalue-ptr info))
494
495 (defgeneric boxed-set-g-value (gvalue-ptr info proxy))
496
497 (defmethod parse-g-value-for-type (gvalue-ptr (type-numeric (eql +g-type-boxed+)) parse-kind)
498   (declare (ignore parse-kind))
499   (if (g-type= (g-value-type gvalue-ptr) (g-strv-get-type))
500       (convert-from-foreign (g-value-get-boxed gvalue-ptr) '(glib:gstrv :free-from-foreign nil))
501       (let ((boxed-type (get-g-boxed-foreign-info-for-gtype type-numeric)))
502         (boxed-parse-g-value gvalue-ptr boxed-type))))
503
504 (defmethod set-gvalue-for-type (gvalue-ptr (type-numeric (eql +g-type-boxed+)) value)
505   (if (g-type= (g-value-type gvalue-ptr) (g-strv-get-type))
506       (g-value-set-boxed gvalue-ptr (convert-to-foreign value '(glib:gstrv :free-from-foreign nil)))
507       (let ((boxed-type (get-g-boxed-foreign-info-for-gtype type-numeric)))
508         (boxed-set-g-value gvalue-ptr boxed-type value))))
509
510 (defmethod boxed-parse-g-value (gvalue-ptr (info g-boxed-cstruct-wrapper-info))
511   (translate-from-foreign (g-value-get-boxed gvalue-ptr) (make-foreign-type info :return-p nil)))
512
513 (defmethod boxed-set-g-value (gvalue-ptr (info g-boxed-cstruct-wrapper-info) proxy)
514   (g-value-take-boxed gvalue-ptr (translate-to-foreign proxy (make-foreign-type info :return-p nil))))
515
516 (defmethod boxed-parse-g-value (gvalue-ptr (info g-boxed-variant-cstruct-info))
517   (translate-from-foreign (g-value-get-boxed gvalue-ptr) (make-foreign-type info :return-p nil)))
518
519 (defmethod boxed-set-g-value (gvalue-ptr (info g-boxed-variant-cstruct-info) proxy)
520   (g-value-take-boxed gvalue-ptr (translate-to-foreign proxy (make-foreign-type info :return-p nil))))
521
522 (defmethod boxed-parse-g-value (gvalue-ptr (info g-boxed-opaque-wrapper-info))
523   (translate-from-foreign (boxed-copy-fn info (g-value-get-boxed gvalue-ptr)) (make-foreign-type info :return-p nil)))
524
525 (defmethod boxed-set-g-value (gvalue-ptr (info g-boxed-opaque-wrapper-info) proxy)
526   (g-value-set-boxed gvalue-ptr (translate-to-foreign proxy (make-foreign-type info :return-p nil))))