; generate declarations for structures (in-package "VERRAZANO") ; for structures, output defcstruct declaration (generate-for ((par namespace-type) (edg defines) (tgt struct-type) bst) (let ((struct-name (named-name tgt))) (define-symbol struct-name "structure" (list par edg tgt) bst) `("cffi:defcstruct" ,struct-name ,@(collect-output tgt bst 'allocates)))) ; for member variables, output tuple (generate-for ((par struct-type) (edg allocates) (tgt cpp-type) bst) (let ((rn (resolved-node tgt))) (if (array-type? rn) `(,(named-name edg) ,(call-next-method) ":count" ,(array-type-length rn)) `(,(named-name edg) ,(call-next-method))))) ; don't generate anything for default constructors (generate-for ((par struct-type) (edg allocates) (tgt function-type) bst) nil) ; for unions, output defcunion declaration (generate-for ((par namespace-type) (edg defines) (tgt union-type) bst) (let ((union-name (named-name tgt))) (define-symbol union-name "union" (list par edg tgt) bst) `("cffi:defcunion" ,union-name ,@(collect-output tgt bst 'allocates)))) ; for member variables, output tuple (generate-for ((par union-type) (edg allocates) (tgt cpp-type) bst) (let ((rn (resolved-node tgt))) (if (array-type? rn) `(,(named-name edg) ,(call-next-method) ":count" ,(array-type-length rn)) `(,(named-name edg) ,(call-next-method))))) ; ignore member functions for unions (generate-for ((par union-type) (edg allocates) (tgt function-type) bst) nil)