Started adding documentation

This commit is contained in:
retropikzel 2024-05-01 11:21:28 +03:00
parent c3736015f8
commit 6fe5ef864e
6 changed files with 111 additions and 1 deletions

View File

@ -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

View File

@ -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)

6
doc/generate.sh Normal file
View File

@ -0,0 +1,6 @@
echo "# PFFI"
echo ""
echo "## Procedures"
echo ""
cat retropikzel/pffi/${VERSION}/schubert-doc.md

34
documentation.md Normal file
View File

@ -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))

View File

@ -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)))

View File

@ -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))