Started adding documentation

This commit is contained in:
retropikzel 2024-05-09 21:03:13 +03:00
parent b6254e946c
commit e5cf7c23ca
4 changed files with 47 additions and 4 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.swp
docuptmp

View File

@ -7,6 +7,14 @@ KAWA=java --add-exports java.base/jdk.internal.foreign.abi=ALL-UNNAMED --add-exp
build: build-rkt documentation
update-documentation:
schubert document
mkdir -p docuptmp
cd docuptmp && git clone git@codeberg.org:r7rs-pffi/pffi.wiki.git
cp retropikzel/pffi/${VERSION}/schubert-doc.md docuptmp/pffi.wiki/Documentation.md
cd docuptmp/pffi.wiki && git add Documentation.md ; git commit -m "Update documentation" ; git push
rm -rf docutmp
build-rkt:
echo "#lang r7rs" > retropikzel/pffi/${VERSION}/main.rkt
cat retropikzel/pffi/${VERSION}/main.scm >> retropikzel/pffi/${VERSION}/main.rkt
@ -49,3 +57,6 @@ test/sdl2.scm: build
#${RACKET} $@
#${STKLOS} $@
${KAWA} $@
clean:
rm -rf docuptmp

View File

@ -1,3 +1,4 @@
;> # pffi
(define-library
(retropikzel pffi v0.1.0 main)
(cond-expand
@ -36,8 +37,9 @@
(scheme file)
(scheme process-context)))
(else (error "Implementation not supported by r7rs-pffi")))
(export pffi-call
pffi-types
(export pffi-shared-object-auto-load
pffi-shared-object-load
pffi-call
pffi-size-of
pffi-pointer-allocate
pffi-pointer-null
@ -47,8 +49,6 @@
pffi-pointer-free
pffi-pointer?
pffi-pointer-null?
pffi-shared-object-load
pffi-shared-object-auto-load
pffi-pointer-set!
pffi-pointer-get
pffi-pointer-deref)
@ -81,6 +81,8 @@
(java.lang.Char value))
(else value))))))
;> ## Procedures
(define platform-file-extension
(cond-expand
(racket (if (equal? (system-type 'os) 'windows) ".dll" ".so"))
@ -460,6 +462,13 @@
(static-field java.lang.foreign.ValueLayout
'JAVA_BYTE))))))
;> ### 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:
;>
(define pffi-shared-object-load
(lambda (path)
(cond-expand (sagittarius (open-shared-library path))
@ -483,6 +492,16 @@
(list (cons 'linker linker)
(cons 'lookup lookup)))))))
;> ### 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 pffi-shared-object-auto-load
(lambda (object-name additional-paths)
(let* ((paths (append auto-load-paths additional-paths))

View File

@ -1,3 +1,9 @@
# pffi test
## Procedures
### pffi-call
Arguments:
@ -28,3 +34,9 @@ Example:
(cons 'int 4))
### pffi-shared-object-auto-load
Arguments:
- object-name (symbol)