; write the declaration tree to a package (in-package "VERRAZANO-CFFI") ; write declarations to a file (defun write-declarations (defns cfg bst) (with-open-file (out (configuration-output-filename cfg) :direction :output :if-exists :supersede) (let ((pkgform `("defpackage" ,(configuration-binding-name cfg) (":use" "#:CFFI") ,(cons ":nicknames" (configuration-binding-nicknames cfg)) ,(cons ":export" (generate-export-list cfg bst))))) (format out "~A~%~%" pkgform) (format out "(in-package ~A)~%" (configuration-binding-name cfg)) (format out "(asdf:operate 'asdf:load-op 'verrazano-support)~%")) (dolist (defn defns) (format out "~A~%" defn)))) ; generate a list of symbols to export (defun generate-export-list (cfg bst) (let ((hidden (configuration-symbols-hidden cfg)) (explist nil)) (maphash #'(lambda (tp ttab) (declare (ignore tp)) (maphash #'(lambda (sk sv) (declare (ignore sv)) (when (not (member sk hidden)) (push (string-upcase (quote-string sk)) explist))) ttab)) (cffi-state-symbols bst)) explist))