Added uniformity to pffi-define-library argument passing and made it work on Chicken too

This commit is contained in:
retropikzel 2025-03-22 19:05:08 +02:00
parent 75405a3135
commit d5fd1eb953
3 changed files with 28 additions and 17 deletions

View File

@ -266,9 +266,9 @@ Returns the size of the pffi-struct, pffi-enum or pffi-type.
Returns the align of the type. Returns the align of the type.
#### pffi-load <a name="pffi-load"></a> #### pffi-define-library <a name="pffi-define-library"></a>
**pffi-load** headers shared-object-name [options] -> object **pffi-define-library** headers shared-object-name [options] -> object
Load given shared object automatically searching many predefined paths. Load given shared object automatically searching many predefined paths.
@ -288,13 +288,25 @@ keyword. The options are:
Example: Example:
(define libc-stdlib
(cond-expand (cond-expand
(windows (pffi-load (list "stdlib.h") "ucrtbase")) (windows (pffi-define-library libc-stdlib
(else (pffi-load (list "stdlib.h") (list "stdlib.h")
"ucrtbase"
'((additional-versions ("0" "6"))
(additiona-paths (".")))))
(else (pffi-define-library libc-stdlib
(list "stdlib.h")
"c" "c"
'(additional-versions . ("6")) '((additional-versions ("0" "6"))
'(additional-search-paths . (".")))))) (additiona-paths ("."))))))
#### Notes
- Do not cond-expand inside the arguments, that might lead to problems on some
implementations.
- Do pass the headers using quote
- As '(... and not (list...
- Do pass the options using quote
- As '(... and not (list...
#### pffi-pointer-null <a name="pffi-pointer-null"></a> #### pffi-pointer-null <a name="pffi-pointer-null"></a>

View File

@ -183,7 +183,7 @@
(define-syntax pffi-shared-object-load (define-syntax pffi-shared-object-load
(er-macro-transformer (er-macro-transformer
(lambda (expr rename compare) (lambda (expr rename compare)
(let* ((headers (cdr (car (cdr expr))))) (let* ((headers (cadr (car (cdr expr)))))
`(begin `(begin
,@ (map ,@ (map
(lambda (header) (lambda (header)

View File

@ -405,12 +405,11 @@
(cond-expand (cond-expand
(windows (pffi-define-library libc-stdlib (windows (pffi-define-library libc-stdlib
(list "stdlib.h") '("stdlib.h")
"ucrtbase" "ucrtbase"
'((additional-versions ("0" "6"))) '((additional-versions ("0" "6")))))
))
(else (pffi-define-library libc-stdlib (else (pffi-define-library libc-stdlib
(list "stdlib.h") '("stdlib.h")
"c" "c"
'((additional-versions ("0" "6")))))) '((additional-versions ("0" "6"))))))
@ -418,18 +417,18 @@
(cond-expand (cond-expand
(windows (pffi-define-library libc-stdio (windows (pffi-define-library libc-stdio
(list "stdio.h") '("stdio.h")
"ucrtbase" "ucrtbase"
'((additional-versions ("0" "6"))))) '((additional-versions ("0" "6")))))
(else (pffi-define-library libc-stdio (else (pffi-define-library libc-stdio
(list "stdio.h") '("stdio.h")
"c" "c"
'((additional-versions ("0" "6")))))) '((additional-versions ("0" "6"))))))
(debug libc-stdio) (debug libc-stdio)
(pffi-define-library c-testlib (pffi-define-library c-testlib
(list "libtest.h") '("libtest.h")
"test" "test"
'((additional-paths ("." "./tests")))) '((additional-paths ("." "./tests"))))