Skip to content

Commit

Permalink
Add switch between operation modes
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Sep 17, 2017
1 parent 3500328 commit 6bd67da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions autowrap/parse.lisp
Expand Up @@ -13,6 +13,8 @@
(defvar *foreign-symbol-exceptions* nil)
(defvar *foreign-symbol-regex* nil)

(declaim (special *filter-spec-p*))

;; Collecting symbols

(defmacro collecting-symbols (&body body)
Expand Down Expand Up @@ -347,6 +349,7 @@ Return the appropriate CFFI name."))
(loop for form in (read-json in-spec)
as name = (aval :name form)
as location = (aval :location form)
when (or *filter-spec-p* (not (excluded-p name location)))
collect (parse-form form (aval :tag form)) into forms
finally (return (remove-if #'null forms))))

Expand Down Expand Up @@ -394,7 +397,7 @@ Return the appropriate CFFI name."))
(extern-package accessor-package)
constant-accessor exclude-constants
(trace-c2ffi *trace-c2ffi*) no-accessors no-functions
release-p version
release-p version filter-spec-p
type-symbol-function c-to-lisp-function)
(let ((*foreign-symbol-exceptions* (alist-hash-table symbol-exceptions :test 'equal))
(*foreign-symbol-regex* (make-scanners symbol-regex))
Expand All @@ -411,6 +414,7 @@ Return the appropriate CFFI name."))
(*exclude-definitions* (mapcar #'ppcre:create-scanner exclude-definitions))
(*exclude-sources* (mapcar #'ppcre:create-scanner exclude-sources))
(*package* (find-package definition-package))
(*filter-spec-p* filter-spec-p)
(h-file (path-or-asdf (eval h-file)))
(spec-path (path-or-asdf (eval spec-path)))
(sysincludes (eval sysincludes))
Expand All @@ -429,7 +433,9 @@ Return the appropriate CFFI name."))
:arch-excludes exclude-arch
:sysincludes sysincludes
:version version
:spec-processor #'squash-unrelated-definitions))
:spec-processor (if *filter-spec-p*
#'squash-unrelated-definitions
#'pass-through-processor)))
(with-open-file (in-spec spec-name)
(collecting-symbols
`(progn
Expand Down
8 changes: 4 additions & 4 deletions autowrap/processing.lisp
Expand Up @@ -41,16 +41,16 @@ of array type taking all the struct available space"
append (extract-type (aval :type field))))

(defun extract-function-types (descriptor)
(cons (extract-type (aval :return-type descriptor))
(loop for parameter in (aval :parameters descriptor)
collect (extract-type (aval :type parameter)))))
(append (extract-type (aval :return-type descriptor))
(loop for parameter in (aval :parameters descriptor)
append (extract-type (aval :type parameter)))))

(defun extract-struct-types (descriptor)
(cons (aval :name descriptor) (extract-field-types descriptor)))

(defun extract-type (type-descriptor)
(switch ((aval :tag type-descriptor) :test #'equal)
(":pointer" (list (extract-type (aval :type type-descriptor))))
(":pointer" (extract-type (aval :type type-descriptor)))
("struct" (extract-struct-types type-descriptor))
(":struct" (extract-struct-types type-descriptor))
("union" (extract-field-types type-descriptor))
Expand Down

0 comments on commit 6bd67da

Please sign in to comment.