diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2023-10-03 19:00:12 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2023-10-03 19:00:12 -0300 |
commit | a57be65f1003c57c2e39c651b2d6e97e6d853a6b (patch) | |
tree | 1c6a89205e9fd0524aefdfedd9496c9854a82aec /cmamut.lisp | |
parent | deca718bea1610759128688e5975bf58c6f11c36 (diff) | |
download | cmamut-a57be65f1003c57c2e39c651b2d6e97e6d853a6b.tar.gz cmamut-a57be65f1003c57c2e39c651b2d6e97e6d853a6b.zip |
Add a default name transformer
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+))) |