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 *.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 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: build-rkt:
echo "#lang r7rs" > retropikzel/pffi/${VERSION}/main.rkt echo "#lang r7rs" > retropikzel/pffi/${VERSION}/main.rkt
cat retropikzel/pffi/${VERSION}/main.scm >> 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} $@ #${RACKET} $@
#${STKLOS} $@ #${STKLOS} $@
${KAWA} $@ ${KAWA} $@
clean:
rm -rf docuptmp

View File

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

View File

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