summaryrefslogtreecommitdiff
path: root/cmamut.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'cmamut.lisp')
-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)))