From 62ad9729952a053ec687649f6d82aae21a3da793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sat, 4 Feb 2023 10:25:13 -0300 Subject: Optionally filter function names --- cmamut.lisp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'cmamut.lisp') 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))) -- cgit v1.2.3