diff --git a/Makefile b/Makefile index 1c2a799..e1287ec 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ CC=gcc DOCKER=docker run -it -v ${PWD}:/workdir DOCKER_INIT=cd /workdir && make clean && +VERSION=$(shell grep "version:" README.md | awk '{split\($0,a\); print a[2];}') all: chibi gauche libtest.so libtest.o libtest.a @@ -11,7 +12,6 @@ docs: pandoc --standalone \ --template templates/documentation.html README.md \ > documentation/R7RS-PFFI.html - #pandoc -s --pdf-engine=weasyprint -o documentation/R7RS-PFFI.pdf README.md pandoc -t html5 \ --pdf-engine=weasyprint \ --css templates/css/pdf-documentation.css \ diff --git a/README.md b/README.md index 9dc52c1..f596fe5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ --- title: Portable Foreign Function Interface for R7RS Documentation +version: 0.6.0 --- # Portable Foreign Function Interface for R7RS @@ -35,7 +36,7 @@ conforming to some specification. - [Chicken](#usage-chicken) - [Racket](#usage-racket) - [Kawa](#usage-kawa) - - [Reference](#reference) +- [Reference](#reference) - [Types](#types) - [Procedures and macros](#procedures-and-macros) - [pffi-init](#pffi-init) @@ -176,8 +177,7 @@ Needs libffi-dev, on Debina/Ubuntu/Mint install with: Build with: - chibi-ffi retropikzel/r7rs-pffi/r7rs-pffi-chibi.stub - gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-pffi/r7rs-pffi-chibi.c -lchibi-scheme -lffi + make chibi #### Chicken @@ -200,15 +200,15 @@ Kawa Needs at least Java version 22 Needs jvm flags: -- --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 +- \--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 -### Reference +## Reference -#### Types +### Types Types are given as symbols, for example 'int8 or 'pointer. @@ -235,29 +235,33 @@ Types are given as symbols, for example 'int8 or 'pointer. - callback - Callback function -#### Procedures and macros +### Procedures and macros Some of these are procedures and some macros, it might also change implementation to implementation. -##### **pffi-init** - +#### pffi-init + +**pffi-init** Always call this first, on most implementation it does nothing but some implementations might need initialisation run. -##### **pffi-size-of** object -> number - +#### pffi-size-of + +**pffi-size-of** object -> number Returns the size of the pffi-struct, pffi-enum or pffi-type. -##### **pffi-align-of** type -> number - +#### pffi-align-of + +**pffi-align-of** type -> number Returns the align of the type. -##### **pffi-shared-object-auto-load** headers shared-object-name [options] -> object - +#### pffi-shared-object-auto-load + +**pffi-shared-object-auto-load** headers shared-object-name [options] -> object Load given shared object automatically searching many predefined paths. @@ -286,8 +290,9 @@ Example: '(additional-search-paths . (".")))))) -##### **pffi-shared-object-load** headers path [options] - +#### pffi-shared-object-load + +**pffi-shared-object-load** headers path [options] It is recommended to use the pffi-shared-object-auto-load instead of this directly. @@ -306,38 +311,45 @@ Options: - additional-versions - List of different versions of library to try, for example (list ".0" ".1") -##### **pffi-pointer-null** -> pointer - +#### pffi-pointer-null + +**pffi-pointer-null** -> pointer Returns a new NULL pointer. -##### **pffi-pointer-null?** pointer -> boolean - +#### pffi-pointer-null? + +**pffi-pointer-null?** pointer -> boolean Returns #t if given pointer is null pointer, #f otherwise. -##### **pffi-pointer-allocate** size -> pointer - +#### pffi-pointer-allocate + +**pffi-pointer-allocate** size -> pointer Returns newly allocated pointer of given size. -##### **pffi-pointer-address** pointer -> number - +#### pffi-pointer-address + +**pffi-pointer-address** pointer -> number Returns the address of given pointer as number. -##### **pffi-pointer?** object -> boolean - +#### pffi-pointer? + +**pffi-pointer?** object -> boolean Returns #t if given object is pointer, #f otherwise. -##### **pffi-pointer-free** pointer - +#### pffi-pointer-free + +**pffi-pointer-free** pointer Frees given pointer. -##### **pffi-pointer-set!** pointer type offset value - +#### pffi-pointer-set! + +**pffi-pointer-set!** pointer type offset value Sets the value on a pointer on given offset. For example: @@ -346,8 +358,9 @@ Sets the value on a pointer on given offset. For example: Would set the offset of 64, on pointer p to value 100. -##### **pffi-pointer-get** pointer type offset -> object - +#### pffi-pointer-get + +**pffi-pointer-get** pointer type offset -> object Gets the value from a pointer on given offset. For example: @@ -356,18 +369,21 @@ Gets the value from a pointer on given offset. For example: (pffi-pointer-get p 'int 64) > 100 -##### **pffi-string->pointer** string -> pointer - +#### pffi-string->pointer + +**pffi-string->pointer** string -> pointer Makes pointer out of a given string. -##### **pffi-pointer->string** pointer -> string - +#### pffi-pointer->string + +**pffi-pointer->string** pointer -> string Makes string out of a given pointer. -##### **pffi-struct-make** c-type members . pointer -> pffi-struct - +#### pffi-struct-make + +**pffi-struct-make** c-type members . pointer -> pffi-struct Creates a new pffi-struct and allocates pointer for it. The members argument is a list of member names and types. For example: @@ -377,8 +393,9 @@ names and types. For example: C-type argument can be symbol or a string. -##### **pffi-struct-pointer** pffi-struct -> pointer - +#### pffi-struct-pointer + +**pffi-struct-pointer** pffi-struct -> pointer Returns the pointer that holds the struct content. You need to use this when passing a struct as a pointer to foreign functions. @@ -386,24 +403,28 @@ a pointer to foreign functions. (define s (pffi-struct-make 'test '((int . r) (int . g) (int . b)))) (pffi-struct-pointer s) -##### **pffi-struct-offset-get** member-name -> number - +#### pffi-struct-offset-get + +**pffi-struct-offset-get** member-name -> number Returns the offset of a struct member with given name. -##### **pffi-struct-get** pffi-struct member-name -> object - +#### pffi-struct-get + +**pffi-struct-get** pffi-struct member-name -> object Returns the value of the givens struct member. -##### **pffi-struct-set!** pffi-struct member-name value - +#### pffi-struct-set! + +**pffi-struct-set!** pffi-struct member-name value Sets the value of the givens struct member. It is up to you to make sure that the type of value is correct. -##### **pffi-define** scheme-name shared-object c-name return-type argument-types - +#### pffi-define + +**pffi-define** scheme-name shared-object c-name return-type argument-types Defines a new foreign function to be used from Scheme code. For example: @@ -414,8 +435,9 @@ Defines a new foreign function to be used from Scheme code. For example: (pffi-define c-puts libc-stdlib 'puts 'int (list 'pointer)) (c-puts "Message brought to you by FFI!") -##### **pffi-define-callback** scheme-name return-type argument-types procedure - +#### pffi-define-callback + +**pffi-define-callback** scheme-name return-type argument-types procedure Defines a new Sceme function to be used as callback to C code. For example: diff --git a/documentation/R7RS-PFFI.html b/documentation/R7RS-PFFI.html index b8a7187..3252142 100644 --- a/documentation/R7RS-PFFI.html +++ b/documentation/R7RS-PFFI.html @@ -2,11 +2,9 @@ - Portable Foreign Function Interface for R7RS -Documentation +Documentation - 0.6.0 - $body$ + ${body}