diff options
Diffstat (limited to 'cmamut.lisp')
-rw-r--r-- | cmamut.lisp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/cmamut.lisp b/cmamut.lisp index 7017a93..e608c25 100644 --- a/cmamut.lisp +++ b/cmamut.lisp @@ -294,15 +294,23 @@ (string/= (gethash "tag" x) "const"))) raw-spec)) -(defun run (path-to-header-file &key package-name shared-object additional-directories name-transformer) - (unless (probe-file path-to-header-file) - (error (format t "The header file ~a doesn't exist!" path-to-header-file))) +(defun default-name-transformer (name type) + (cond ((eq type :const) + (concatenate 'string "+" (string-upcase (str:underscore->hyphen name)) "+")) + (t (string-upcase + (str:pascal->kebab + (str:upcase->pascal + (str:underscore->hyphen name))))))) + +(defun run (header-file &key package-name shared-object additional-directories name-transformer) + (unless (probe-file header-file) + (error (format t "The header file ~a doesn't exist!" header-file))) (when (not (find-package +target-package+)) (make-package +target-package+)) - (setf path-to-header-file (parse-namestring path-to-header-file)) - (push (directory-namestring path-to-header-file) additional-directories) - (let* ((raw-spec (get-raw-spec (namestring path-to-header-file) additional-directories)) + (setf header-file (parse-namestring header-file)) + (push (directory-namestring header-file) additional-directories) + (let* ((raw-spec (get-raw-spec (namestring header-file) additional-directories)) (spec (classify-definitions (filter-directories additional-directories raw-spec))) - (code (codegen spec (or name-transformer (lambda (name kind) name))))) - (to-file code (concatenate 'string (pathname-name path-to-header-file) ".lisp") package-name shared-object)) + (code (codegen spec (or name-transformer #'default-name-transformer)))) + (to-file code (concatenate 'string (pathname-name header-file) ".lisp") package-name shared-object)) (delete-package (find-package +target-package+))) |