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.
#### 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.
@ -288,13 +288,25 @@ keyword. The options are:
Example:
(define libc-stdlib
(cond-expand
(windows (pffi-load (list "stdlib.h") "ucrtbase"))
(else (pffi-load (list "stdlib.h")
"c"
'(additional-versions . ("6"))
'(additional-search-paths . ("."))))))
(cond-expand
(windows (pffi-define-library libc-stdlib
(list "stdlib.h")
"ucrtbase"
'((additional-versions ("0" "6"))
(additiona-paths (".")))))
(else (pffi-define-library libc-stdlib
(list "stdlib.h")
"c"
'((additional-versions ("0" "6"))
(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>

View File

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

View File

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