From 8cf94127ccc6a587fd4536d900df9082d428751d Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Thu, 6 Aug 2009 02:13:11 +0400 Subject: [PATCH] glib: Fixed generation of union for variant struct; fixed boxed-copy-fn for variant-cstruct --- glib/gobject.boxed.lisp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/glib/gobject.boxed.lisp b/glib/gobject.boxed.lisp index 2cfbd15..fe84adb 100644 --- a/glib/gobject.boxed.lisp +++ b/glib/gobject.boxed.lisp @@ -314,16 +314,11 @@ (for cstruct = (var-structure-resulting-cstruct-description str)) (collect (generate-cstruct-1 cstruct)))) -(defun generate-union-1 (struct) +(defun generate-variant-union (struct) `(defcunion ,(generated-cunion-name (var-structure-name struct)) - ,@(iter (for variant in (all-structures struct)) - (unless (eq struct variant) - (collect `(,(var-structure-name variant) - ,(generated-cunion-name (var-structure-name variant)))))))) - -(defun generate-unions (struct) - (iter (for str in (all-structures struct)) - (collect (generate-union-1 str)))) + ,@(iter (for str in (all-structures struct)) + (collect `(,(var-structure-name str) + ,(generated-cstruct-name (var-structure-name str))))))) (defun generate-structure-1 (str) `(defstruct ,(if (var-structure-parent str) @@ -402,7 +397,7 @@ (defmacro define-g-boxed-variant-cstruct (name g-type-name &body slots) (let* ((structure (parse-variant-structure-definition name slots))) `(progn ,@(generate-c-structures structure) - ,@(generate-unions structure) + ,(generate-variant-union structure) ,@(generate-structures structure) (eval-when (:compile-toplevel :load-toplevel :execute) (setf (get ',name 'g-boxed-foreign-info) @@ -422,8 +417,8 @@ (defmethod boxed-copy-fn ((info g-boxed-variant-cstruct-info) native) (if (g-boxed-info-g-type info) (g-boxed-copy (g-boxed-info-g-type info) native) - (let ((copy (foreign-alloc (generated-cstruct-name (g-boxed-info-name info))))) - (memcpy copy native (foreign-type-size (generated-cstruct-name (g-boxed-info-name info)))) + (let ((copy (foreign-alloc (generated-cunion-name (g-boxed-info-name info))))) + (memcpy copy native (foreign-type-size (generated-cunion-name (g-boxed-info-name info)))) copy))) (defmethod boxed-free-fn ((info g-boxed-variant-cstruct-info) native) -- 1.7.10.4