summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2023-02-04 10:25:13 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2023-02-04 10:25:13 -0300
commit62ad9729952a053ec687649f6d82aae21a3da793 (patch)
tree58b6b4d1ea49546d551fc1cef29b13dfcfac29d3
parent392e71d70e443b73713ed82c6eae7c054c36b469 (diff)
downloadcmamut-62ad9729952a053ec687649f6d82aae21a3da793.tar.gz
cmamut-62ad9729952a053ec687649f6d82aae21a3da793.zip
Optionally filter function names
-rw-r--r--cmamut.lisp11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmamut.lisp b/cmamut.lisp
index dddd512..7076936 100644
--- a/cmamut.lisp
+++ b/cmamut.lisp
@@ -5,9 +5,10 @@
; To avoid collisions the created package shouldn't import any symbols.
; Only define functions from the target library, but get all other definitions.
+; TODO: Order composite types so that size is known on definition.
; TODO: Get constants from macro file generated by c2ffi -M
-
; TODO: Use c2ffi to extract the spec.json using the header file as parameter
+
(defun get-raw-spec (filename)
(json:from-file filename))
@@ -180,7 +181,7 @@
(push def (spec-composite spec)))))
spec)
-(defun codegen (spec)
+(defun codegen (spec function-filter)
(let ((enum-references (generate-enum-references (spec-typedefs spec)))
(type-associations (generate-type-associations (spec-typedefs spec))))
(let ((enums (mapcar (lambda (x) (cook-enum x enum-references))
@@ -189,7 +190,7 @@
`(sb-alien:define-alien-type nil ,(cook-composite x type-associations)))
(spec-composite spec)))
(functions (mapcar (lambda (x) (cook-function x type-associations))
- (spec-functions spec))))
+ (remove-if-not function-filter (spec-functions spec)))))
(remove-duplicates (concatenate 'list enums composite functions) :test #'equal))))
(defun to-file (code filename)
@@ -201,8 +202,8 @@
(*print-level* nil))
(format f "~{~s~&~}" code))))
-(defun run (input output)
+(defun run (input output &optional function-filter)
(let* ((raw-spec (get-raw-spec input))
(spec (classify-definitions raw-spec))
- (code (codegen spec)))
+ (code (codegen spec function-filter)))
(to-file code output)))