From 6fe5ef864e99555ea81bcfe08be9a764394502da Mon Sep 17 00:00:00 2001 From: retropikzel Date: Wed, 1 May 2024 11:21:28 +0300 Subject: [PATCH] Started adding documentation --- Makefile | 5 ++++ README.md | 9 ++++++- doc/generate.sh | 6 +++++ documentation.md | 34 +++++++++++++++++++++++++ retropikzel/pffi/v0.1.0/main.scm | 28 ++++++++++++++++++++ retropikzel/pffi/v0.1.0/schubert-doc.md | 30 ++++++++++++++++++++++ 6 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 doc/generate.sh create mode 100644 documentation.md create mode 100644 retropikzel/pffi/v0.1.0/schubert-doc.md diff --git a/Makefile b/Makefile index a51698d..49b033d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ VERSION=v0.1.0 RACKETEXE=${HOME}/.wine/drive_c/Program Files/Racket/racket.exe +documentation: + schubert document + VERSION=${VERSION} bash doc/generate.sh > documentation.md + + test-sagittatius-sdl2: sash -r7 -L . test/sdl2.scm diff --git a/README.md b/README.md index 7476dcd..2d45e5b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ # Portable Foreign Function Interface for R7RS schemes Currently supported implementations -* Sagittarius [https://bitbucket.org/ktakashi/sagittarius-scheme/wiki/Home] +* [Sagittarius](https://bitbucket.org/ktakashi/sagittarius-scheme/wiki/Home) +* [Guile](https://www.gnu.org/software/guile/) + +For documentation see +[Wiki](https://codeberg.org/r7rs-pffi/pffi/wiki/Documentation) + +For bugs you can use the +[Bugs](https://codeberg.org/r7rs-pffi/pffi/projects/9101) diff --git a/doc/generate.sh b/doc/generate.sh new file mode 100644 index 0000000..de8affb --- /dev/null +++ b/doc/generate.sh @@ -0,0 +1,6 @@ + +echo "# PFFI" +echo "" +echo "## Procedures" +echo "" +cat retropikzel/pffi/${VERSION}/schubert-doc.md diff --git a/documentation.md b/documentation.md new file mode 100644 index 0000000..ca9dac8 --- /dev/null +++ b/documentation.md @@ -0,0 +1,34 @@ +# PFFI + +## Procedures + +### pffi-call + +Arguments: + +- shared-object (object) + - Shared object returned by pffi-shared-object-load or pffi-shared-object-auto-load +- name (symbol) + - Name of the C function you want to call +- type (symbol) + - Return type of the C function you want to call +- arguments (list (cons type value)...) + - Arguments you want to pass to the C function as pairs of type and value + +Example: + +(define sdl2* (pffi-shared-object-auto-load "SDL2" (list)) + +(pffi-call sdl2* 'SDL_Init 'int '((int . 32))) + +(define window* (pffi-call sdl2* + 'SDL_CreateWindow + 'pointer + (list (cons 'pointer (pffi-string->pointer "Hello")) + (cons 'int 1) + (cons 'int 1) + (cons 'int 400) + (cons 'int 400) + (cons 'int 4)) + + diff --git a/retropikzel/pffi/v0.1.0/main.scm b/retropikzel/pffi/v0.1.0/main.scm index f5b1ae5..7a08c5b 100644 --- a/retropikzel/pffi/v0.1.0/main.scm +++ b/retropikzel/pffi/v0.1.0/main.scm @@ -246,6 +246,34 @@ (guile (pointer? object)) (racket (cpointer? object))))) + ;> ### pffi-call + ;> + ;> Arguments: + ;> + ;> - shared-object (object) + ;> - Shared object returned by pffi-shared-object-load or pffi-shared-object-auto-load + ;> - name (symbol) + ;> - Name of the C function you want to call + ;> - type (symbol) + ;> - Return type of the C function you want to call + ;> - arguments (list (cons type value)...) + ;> - Arguments you want to pass to the C function as pairs of type and value + ;> + ;> Example: + ;> + ;> (define sdl2* (pffi-shared-object-auto-load "SDL2" (list)) + ;> + ;> (pffi-call sdl2* 'SDL_Init 'int '((int . 32))) + ;> + ;> (define window* (pffi-call sdl2* + ;> 'SDL_CreateWindow + ;> 'pointer + ;> (list (cons 'pointer (pffi-string->pointer "Hello")) + ;> (cons 'int 1) + ;> (cons 'int 1) + ;> (cons 'int 400) + ;> (cons 'int 400) + ;> (cons 'int 4)) (define pffi-call (lambda (shared-object name type arguments) (let ((types (map pffi-type->native-type (map car arguments))) diff --git a/retropikzel/pffi/v0.1.0/schubert-doc.md b/retropikzel/pffi/v0.1.0/schubert-doc.md new file mode 100644 index 0000000..d33ca86 --- /dev/null +++ b/retropikzel/pffi/v0.1.0/schubert-doc.md @@ -0,0 +1,30 @@ +### pffi-call + +Arguments: + +- shared-object (object) + - Shared object returned by pffi-shared-object-load or pffi-shared-object-auto-load +- name (symbol) + - Name of the C function you want to call +- type (symbol) + - Return type of the C function you want to call +- arguments (list (cons type value)...) + - Arguments you want to pass to the C function as pairs of type and value + +Example: + +(define sdl2* (pffi-shared-object-auto-load "SDL2" (list)) + +(pffi-call sdl2* 'SDL_Init 'int '((int . 32))) + +(define window* (pffi-call sdl2* + 'SDL_CreateWindow + 'pointer + (list (cons 'pointer (pffi-string->pointer "Hello")) + (cons 'int 1) + (cons 'int 1) + (cons 'int 400) + (cons 'int 400) + (cons 'int 4)) + +