; code shapes for C-FFI declarations (in-package "VERRAZANO-CFFI") ; output a C-FFI defcfun (defmacro defcfun-declaration (fn cn tg) ``("cffi:defcfun" (,(quote-string ,cn) ,,fn) ,@(collect-output ,tg 'returns) ,@(collect-output ,tg 'receives))) ; output a C-FFI defcenum (defmacro defcenum-declaration (en tg) ``("cffi:defcenum" ,,en ,@(remove-duplicates (collect-output ,tg 'allocates) :key #'cadr :test #'equal))) ; output a C-FFI defcstruct or defcunion (defmacro struct-union-declaration (tp nm tg) ```(,,,tp ,,,nm ,@(collect-output ,,tg 'allocates))) ; output a C-FFI defcstruct (defmacro defcstruct-declaration (nm tg) (struct-union-declaration "cffi:defcstruct" nm tg)) ; output a C-FFI defcunion (defmacro defcunion-declaration (nm tg) (struct-union-declaration "cffi:defcunion" nm tg)) ; output a member tuple in a struct or union (defmacro member-tuple-declaration (nm tg) `(let ((rn (resolved-node ,tg))) (if (array-type? rn) `(,,nm ,(call-next-method) ,(array-type-length rn)) `(,,nm ,(call-next-method))))) ; output a C-FFI typedef (defmacro define-foreign-type-declaration (sname tname tg) ``("cffi:define-foreign-type" ,,sname ,,tname ',(car (collect-output ,tg 'extends))))