(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)
(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)
(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)