Make many implementations pass all tests, clean up repo

This commit is contained in:
retropikzel 2024-05-18 16:40:39 +03:00
parent d94cbd9baa
commit de665ce967
9 changed files with 81 additions and 87 deletions

View File

@ -31,6 +31,7 @@ clean:
rm -rf retropikzel/pffi/${VERSION}/*.o*
rm -rf retropikzel/pffi/${VERSION}/*.so
rm -rf retropikzel/pffi/${VERSION}/*.meta
rm -rf retropikzel/pffi/${VERSION}/retropikzel.*
rm -rf retropikzel.*
rm -rf test/*.c
rm -rf test/*.o*

View File

@ -6,7 +6,7 @@ For documentation see
For bugs you can use the
[Bugs](https://codeberg.org/r7rs-pffi/pffi/projects/9101)
## Supports
## All tests pass
- [Sagittarius](https://bitbucket.org/ktakashi/sagittarius-scheme/wiki/Home)
- [Guile](https://www.gnu.org/software/guile/)
@ -14,22 +14,69 @@ For bugs you can use the
- Needs atleast java 21
- Needs jvm flags
- java --add-exports java.base/jdk.internal.foreign.abi=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign.layout=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED --enable-native-access=ALL-UNNAMED --enable-preview -jar kawa.jar FILENAME.scm
## Support is work in progress
- [Racket](https://racket-lang.org/)
- [STKlos](https://stklos.net/)
- [Cyclone](https://justinethier.github.io/cyclone/)
- [Chicken](https://www.call-cc.org/)
## Support is waiting for the implementation
## Not all tests pass
- [STKlos](https://stklos.net/)
- [Cyclone](https://justinethier.github.io/cyclone/)
- [Gambit](https://gambitscheme.org)
## Waiting for the implementation
- [LIPS](https://lips.js.org/)
- Waiting for implementation to have cond-expand and library support
- Will only work on nodejs
## Not supported
- [Chibi](https://synthcode.com/scheme/chibi)
- FFI requires C code
- [MIT-Scheme](https://www.gnu.org/software/mit-scheme/)
- FF requires C code
- [tr7](https://gitlab.com/jobol/tr7)
- FFI requires C code
- [Gauche](https://practical-scheme.net/gauche/)
- FFI requires C code
## Hacking
main.sld is the real main which is copied to other suffixes like .scm and .rkt.
main.sld is the real main which is copied to main.scm
## Documentation
On some implementations these are procedures, on some macros.
### pffi-shared-object-auto-load
Arguments:
- object-name (symbol)
- The name of the dynamic library file you want to load without the "lib" in fron of it or .so/.dll at the end
- addition-paths (list (string)...)
- Any additional paths you want to search for the library
Returns:
- (object) Shared object, the type depends on the implementation
### pffi-shared-object-load
It is recommended to use the pffi-shared-object-auto-load instead of this
directly.
Arguments:
- headers (list (string) ...) Headers that need to be included
- Example (list "curl/curl.h")
- path (string) The full path to the shared object you want to load, including any "lib" infront and .so/.dll at the end
- Example "libcurl.so"
Returns:
- (object) Shared object, the type depends on the implementation

View File

@ -3,17 +3,23 @@
;; that accepts a '--manifest' (or '-m') option.
(specifications->manifest
(list "guile"
"racket-minimal"
"gambit-c"
"chicken"
"gerbil"
"openjdk"
"curl"
"sdl2"
"sdl2-image"
"sdl2-ttf"
"sdl2-mixer"
"ck"
"zig"
"gcc-toolchain"))
(list
; Guile
"guile"
; Racket
"racket-minimal"
; Gambit
"gambit-c"
; Chicken
"chicken"
; Gerbil
"gerbil"
; Cyclone
"ck"
; Kawa
"openjdk"
; Test libraries
"curl"
; Compilers
"zig"
"gcc-toolchain"))

View File

@ -92,7 +92,8 @@
(define pffi-pointer-null?
(lambda (pointer)
(null-pointer? pointer)))
(and (pffi-pointer? pointer)
(null-pointer? pointer))))
(define pffi-pointer-set!
(lambda (pointer type offset value)

View File

@ -136,7 +136,7 @@
(define pffi-pointer-free
(lambda (pointer)
(invoke pointer 'unload)))
#t))
(define pffi-pointer-null?
(lambda (pointer)

View File

@ -1,6 +1,3 @@
;> # pffi
;> ## Procedures
(define-library
(retropikzel pffi v0-1-0 main)
(cond-expand
@ -73,7 +70,6 @@
pffi-pointer-null
pffi-string->pointer
pffi-pointer->string
pffi-pointer->bytevector
pffi-pointer-free
pffi-pointer?
pffi-pointer-null?
@ -81,13 +77,8 @@
pffi-pointer-get
pffi-pointer-deref)
(begin
(define library-version "v0-1-0")
;> ## Procedures
(define platform-file-extension
(cond-expand
(racket (if (equal? (system-type 'os) 'windows) ".dll" ".so"))
@ -174,28 +165,6 @@
"/usr/lib/x86_64-linux-gnu"
"/usr/local/lib"))))))
;> ### pffi-shared-object-load
;>
;> Arguments:
;> - path (string) The path to the shared object you want to load, including any "lib" infront and .so/.dll at the end
;>
;> Returns:
;>
;> ### pffi-shared-object-auto-load
;>
;> Arguments:
;> - object-name (symbol)
;> - The name of the dynamic library file you want to load without the "lib" in fron of it or .so/.dll at the end
;> - addition-paths (list (string)...)
;> - Any additional paths you want to search for the library
;>
;> Returns:
;> - (object) Shared object, the type depends on the implementation
(define-syntax pffi-shared-object-auto-load
(syntax-rules ()
((pffi-shared-object-auto-load headers object-name additional-paths)

View File

@ -1,6 +1,3 @@
;> # pffi
;> ## Procedures
(define-library
(retropikzel pffi v0-1-0 main)
(cond-expand
@ -80,13 +77,8 @@
pffi-pointer-get
pffi-pointer-deref)
(begin
(define library-version "v0-1-0")
;> ## Procedures
(define platform-file-extension
(cond-expand
(racket (if (equal? (system-type 'os) 'windows) ".dll" ".so"))
@ -173,28 +165,6 @@
"/usr/lib/x86_64-linux-gnu"
"/usr/local/lib"))))))
;> ### pffi-shared-object-load
;>
;> Arguments:
;> - path (string) The path to the shared object you want to load, including any "lib" infront and .so/.dll at the end
;>
;> Returns:
;>
;> ### pffi-shared-object-auto-load
;>
;> Arguments:
;> - object-name (symbol)
;> - The name of the dynamic library file you want to load without the "lib" in fron of it or .so/.dll at the end
;> - addition-paths (list (string)...)
;> - Any additional paths you want to search for the library
;>
;> Returns:
;> - (object) Shared object, the type depends on the implementation
(define-syntax pffi-shared-object-auto-load
(syntax-rules ()
((pffi-shared-object-auto-load headers object-name additional-paths)

View File

@ -68,7 +68,7 @@
(define pffi-pointer-allocate
(lambda (size)
(malloc size)))
(malloc size 'raw)))
(define pffi-pointer-null
(lambda ()

View File

@ -83,7 +83,7 @@
(define pffi-pointer-allocate
(lambda (size)
(allocate-pointer size)))
(c-malloc size)))
(define pffi-pointer-null
(lambda ()