Updated documentation
This commit is contained in:
parent
fe7822cb29
commit
5d04b79a2b
2
Makefile
2
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 \
|
||||
|
|
|
|||
128
README.md
128
README.md
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: Portable Foreign Function Interface for R7RS Documentation
|
||||
version: 0.6.0
|
||||
---
|
||||
|
||||
# Portable Foreign Function Interface for R7RS
|
||||
|
|
@ -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
|
||||
<a name="usage-chicken"></a>
|
||||
|
|
@ -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
|
||||
<a name="reference"></a>
|
||||
|
||||
#### Types
|
||||
### Types
|
||||
<a name="types"></a>
|
||||
|
||||
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
|
||||
<a name="procedures-and-macros"></a>
|
||||
|
||||
Some of these are procedures and some macros, it might also change implementation to implementation.
|
||||
|
||||
##### **pffi-init**
|
||||
<a name="pffi-init"></a>
|
||||
#### pffi-init <a name="pffi-init"></a>
|
||||
|
||||
**pffi-init**
|
||||
|
||||
Always call this first, on most implementation it does nothing but some implementations might need
|
||||
initialisation run.
|
||||
|
||||
##### **pffi-size-of** object -> number
|
||||
<a name="pffi-size-of"></a>
|
||||
#### pffi-size-of <a name="pffi-size-of"></a>
|
||||
|
||||
**pffi-size-of** object -> number
|
||||
|
||||
Returns the size of the pffi-struct, pffi-enum or pffi-type.
|
||||
|
||||
##### **pffi-align-of** type -> number
|
||||
<a name="pffi-align-of"></a>
|
||||
#### pffi-align-of <a name="pffi-align-of"></a>
|
||||
|
||||
**pffi-align-of** type -> number
|
||||
|
||||
Returns the align of the type.
|
||||
|
||||
##### **pffi-shared-object-auto-load** headers shared-object-name [options] -> object
|
||||
<a name="pffi-shared-object-auto-load"></a>
|
||||
#### pffi-shared-object-auto-load <a name="pffi-shared-object-auto-load"></a>
|
||||
|
||||
**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]
|
||||
<a name="pffi-shared-object-load"></a>
|
||||
#### pffi-shared-object-load <a name="pffi-shared-object-load"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-pointer-null"></a>
|
||||
#### pffi-pointer-null <a name="pffi-pointer-null"></a>
|
||||
|
||||
**pffi-pointer-null** -> pointer
|
||||
|
||||
Returns a new NULL pointer.
|
||||
|
||||
##### **pffi-pointer-null?** pointer -> boolean
|
||||
<a name="pffi-pointer-null?"></a>
|
||||
#### pffi-pointer-null? <a name="pffi-pointer-null?"></a>
|
||||
|
||||
**pffi-pointer-null?** pointer -> boolean
|
||||
|
||||
Returns #t if given pointer is null pointer, #f otherwise.
|
||||
|
||||
##### **pffi-pointer-allocate** size -> pointer
|
||||
<a name="pffi-pointer-allocate"></a>
|
||||
#### pffi-pointer-allocate <a name="pffi-pointer-allocate"></a>
|
||||
|
||||
**pffi-pointer-allocate** size -> pointer
|
||||
|
||||
Returns newly allocated pointer of given size.
|
||||
|
||||
##### **pffi-pointer-address** pointer -> number
|
||||
<a name="pffi-pointer-address"></a>
|
||||
#### pffi-pointer-address <a name="pffi-pointer-address"></a>
|
||||
|
||||
**pffi-pointer-address** pointer -> number
|
||||
|
||||
Returns the address of given pointer as number.
|
||||
|
||||
##### **pffi-pointer?** object -> boolean
|
||||
<a name="pffi-pointer?"></a>
|
||||
#### pffi-pointer? <a name="pffi-pointer?"></a>
|
||||
|
||||
**pffi-pointer?** object -> boolean
|
||||
|
||||
Returns #t if given object is pointer, #f otherwise.
|
||||
|
||||
##### **pffi-pointer-free** pointer
|
||||
<a name="pffi-pointer-free"></a>
|
||||
#### pffi-pointer-free <a name="pffi-pointer-free"></a>
|
||||
|
||||
**pffi-pointer-free** pointer
|
||||
|
||||
Frees given pointer.
|
||||
|
||||
##### **pffi-pointer-set!** pointer type offset value
|
||||
<a name="pffi-pointer-set!"></a>
|
||||
#### pffi-pointer-set! <a name="pffi-pointer-set!"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-pointer-get"></a>
|
||||
#### pffi-pointer-get <a name="pffi-pointer-get"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-string-to-pointer"></a>
|
||||
#### pffi-string->pointer <a name="pffi-string-to-pointer"></a>
|
||||
|
||||
**pffi-string->pointer** string -> pointer
|
||||
|
||||
Makes pointer out of a given string.
|
||||
|
||||
##### **pffi-pointer->string** pointer -> string
|
||||
<a name="pffi-pointer-to-string"></a>
|
||||
#### pffi-pointer->string <a name="pffi-pointer-to-string"></a>
|
||||
|
||||
**pffi-pointer->string** pointer -> string
|
||||
|
||||
Makes string out of a given pointer.
|
||||
|
||||
##### **pffi-struct-make** c-type members . pointer -> pffi-struct
|
||||
<a name="pffi-struct-make"></a>
|
||||
#### pffi-struct-make <a name="pffi-struct-make"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-struct-pointer"></a>
|
||||
#### pffi-struct-pointer <a name="pffi-struct-pointer"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-struct-offset-get"></a>
|
||||
#### pffi-struct-offset-get <a name="pffi-struct-offset-get"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-struct-get"></a>
|
||||
#### pffi-struct-get <a name="pffi-struct-get"></a>
|
||||
|
||||
**pffi-struct-get** pffi-struct member-name -> object
|
||||
|
||||
Returns the value of the givens struct member.
|
||||
|
||||
##### **pffi-struct-set!** pffi-struct member-name value
|
||||
<a name="pffi-struct-set!"></a>
|
||||
#### pffi-struct-set! <a name="pffi-struct-set!"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-define"></a>
|
||||
#### pffi-define <a name="pffi-define"></a>
|
||||
|
||||
**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
|
||||
<a name="pffi-define-callback"></a>
|
||||
#### pffi-define-callback <a name="pffi-define-callback"></a>
|
||||
|
||||
**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:
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="date" content=''>
|
||||
<title>Portable Foreign Function Interface for R7RS
|
||||
Documentation</title>
|
||||
Documentation - 0.6.0</title>
|
||||
<style>
|
||||
h5 { font-weight: normal; }
|
||||
table { width: 250%; }
|
||||
nav { float: left; width: 20%;}
|
||||
main { float: right; width: 80%; }
|
||||
|
|
@ -53,7 +51,9 @@ Documentation</title>
|
|||
<li><a href="#usage-racket">Racket</a></li>
|
||||
<li><a href="#usage-kawa">Kawa</a></li>
|
||||
</ul></li>
|
||||
<li><a href="#reference">Reference</a></li>
|
||||
</ul></li>
|
||||
<li><a href="#reference">Reference</a>
|
||||
<ul>
|
||||
<li><a href="#types">Types</a></li>
|
||||
<li><a href="#procedures-and-macros">Procedures and macros</a>
|
||||
<ul>
|
||||
|
|
@ -697,8 +697,7 @@ Documentation</title>
|
|||
<p>Needs libffi-dev, on Debina/Ubuntu/Mint install with:</p>
|
||||
<pre><code>apt install libffi-dev</code></pre>
|
||||
<p>Build with:</p>
|
||||
<pre><code>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</code></pre>
|
||||
<pre><code>make chibi</code></pre>
|
||||
<h4 id="chicken">Chicken</h4>
|
||||
<p><a name="usage-chicken"></a></p>
|
||||
<p>Needs <a href="https://wiki.call-cc.org/eggref/5/r7rs">r7rs
|
||||
|
|
@ -715,16 +714,17 @@ gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-p
|
|||
<p>Kawa Needs at least Java version 22</p>
|
||||
<p>Needs jvm flags:</p>
|
||||
<ul>
|
||||
<li>–add-exports
|
||||
<li>--add-exports
|
||||
java.base/jdk.internal.foreign.abi=ALL-UNNAMED</li>
|
||||
<li>–add-exports
|
||||
<li>--add-exports
|
||||
java.base/jdk.internal.foreign.layout=ALL-UNNAMED</li>
|
||||
<li>–add-exports java.base/jdk.internal.foreign=ALL-UNNAMED</li>
|
||||
<li>–enable-native-access=ALL-UNNAMED</li>
|
||||
<li>--add-exports
|
||||
java.base/jdk.internal.foreign=ALL-UNNAMED</li>
|
||||
<li>--enable-native-access=ALL-UNNAMED</li>
|
||||
</ul>
|
||||
<h3 id="reference">Reference</h3>
|
||||
<h2 id="reference">Reference</h2>
|
||||
<p><a name="reference"></a></p>
|
||||
<h4 id="types">Types</h4>
|
||||
<h3 id="types">Types</h3>
|
||||
<p><a name="types"></a></p>
|
||||
<p>Types are given as symbols, for example ’int8 or
|
||||
’pointer.</p>
|
||||
|
|
@ -753,30 +753,29 @@ gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-p
|
|||
<li>Callback function</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<h4 id="procedures-and-macros">Procedures and macros</h4>
|
||||
<h3 id="procedures-and-macros">Procedures and macros</h3>
|
||||
<p><a name="procedures-and-macros"></a></p>
|
||||
<p>Some of these are procedures and some macros, it might also
|
||||
change implementation to implementation.</p>
|
||||
<h5 id="pffi-init"><strong>pffi-init</strong></h5>
|
||||
<p><a name="pffi-init"></a></p>
|
||||
<h4 id="pffi-init">pffi-init <a name="pffi-init"></a></h4>
|
||||
<p><strong>pffi-init</strong></p>
|
||||
<p>Always call this first, on most implementation it does
|
||||
nothing but some implementations might need initialisation
|
||||
run.</p>
|
||||
<h5
|
||||
id="pffi-size-of-object---number"><strong>pffi-size-of</strong>
|
||||
object -> number</h5>
|
||||
<p><a name="pffi-size-of"></a></p>
|
||||
<h4 id="pffi-size-of">pffi-size-of
|
||||
<a name="pffi-size-of"></a></h4>
|
||||
<p><strong>pffi-size-of</strong> object -> number</p>
|
||||
<p>Returns the size of the pffi-struct, pffi-enum or
|
||||
pffi-type.</p>
|
||||
<h5
|
||||
id="pffi-align-of-type---number"><strong>pffi-align-of</strong>
|
||||
type -> number</h5>
|
||||
<p><a name="pffi-align-of"></a></p>
|
||||
<h4 id="pffi-align-of">pffi-align-of
|
||||
<a name="pffi-align-of"></a></h4>
|
||||
<p><strong>pffi-align-of</strong> type -> number</p>
|
||||
<p>Returns the align of the type.</p>
|
||||
<h5
|
||||
id="pffi-shared-object-auto-load-headers-shared-object-name-options---object"><strong>pffi-shared-object-auto-load</strong>
|
||||
headers shared-object-name [options] -> object</h5>
|
||||
<p><a name="pffi-shared-object-auto-load"></a></p>
|
||||
<h4
|
||||
id="pffi-shared-object-auto-load">pffi-shared-object-auto-load
|
||||
<a name="pffi-shared-object-auto-load"></a></h4>
|
||||
<p><strong>pffi-shared-object-auto-load</strong> headers
|
||||
shared-object-name [options] -> object</p>
|
||||
<p>Load given shared object automatically searching many
|
||||
predefined paths.</p>
|
||||
<p>Takes as argument a list of C headers, these are for the
|
||||
|
|
@ -807,10 +806,10 @@ gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-p
|
|||
"c"
|
||||
'(additional-versions . ("6"))
|
||||
'(additional-search-paths . ("."))))))</code></pre>
|
||||
<h5
|
||||
id="pffi-shared-object-load-headers-path-options"><strong>pffi-shared-object-load</strong>
|
||||
headers path [options]</h5>
|
||||
<p><a name="pffi-shared-object-load"></a></p>
|
||||
<h4 id="pffi-shared-object-load">pffi-shared-object-load
|
||||
<a name="pffi-shared-object-load"></a></h4>
|
||||
<p><strong>pffi-shared-object-load</strong> headers path
|
||||
[options]</p>
|
||||
<p>It is recommended to use the pffi-shared-object-auto-load
|
||||
instead of this directly.</p>
|
||||
<p>Headers is a list of strings needed to be included, for
|
||||
|
|
@ -827,104 +826,98 @@ gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-p
|
|||
(list “.0” “.1”)</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<h5
|
||||
id="pffi-pointer-null---pointer"><strong>pffi-pointer-null</strong>
|
||||
-> pointer</h5>
|
||||
<p><a name="pffi-pointer-null"></a></p>
|
||||
<h4 id="pffi-pointer-null">pffi-pointer-null
|
||||
<a name="pffi-pointer-null"></a></h4>
|
||||
<p><strong>pffi-pointer-null</strong> -> pointer</p>
|
||||
<p>Returns a new NULL pointer.</p>
|
||||
<h5
|
||||
id="pffi-pointer-null-pointer---boolean"><strong>pffi-pointer-null?</strong>
|
||||
pointer -> boolean</h5>
|
||||
<p><a name="pffi-pointer-null?"></a></p>
|
||||
<h4 id="pffi-pointer-null-1">pffi-pointer-null?
|
||||
<a name="pffi-pointer-null?"></a></h4>
|
||||
<p><strong>pffi-pointer-null?</strong> pointer -> boolean</p>
|
||||
<p>Returns #t if given pointer is null pointer, #f
|
||||
otherwise.</p>
|
||||
<h5
|
||||
id="pffi-pointer-allocate-size---pointer"><strong>pffi-pointer-allocate</strong>
|
||||
size -> pointer</h5>
|
||||
<p><a name="pffi-pointer-allocate"></a></p>
|
||||
<h4 id="pffi-pointer-allocate">pffi-pointer-allocate
|
||||
<a name="pffi-pointer-allocate"></a></h4>
|
||||
<p><strong>pffi-pointer-allocate</strong> size -> pointer</p>
|
||||
<p>Returns newly allocated pointer of given size.</p>
|
||||
<h5
|
||||
id="pffi-pointer-address-pointer---number"><strong>pffi-pointer-address</strong>
|
||||
pointer -> number</h5>
|
||||
<p><a name="pffi-pointer-address"></a></p>
|
||||
<h4 id="pffi-pointer-address">pffi-pointer-address
|
||||
<a name="pffi-pointer-address"></a></h4>
|
||||
<p><strong>pffi-pointer-address</strong> pointer ->
|
||||
number</p>
|
||||
<p>Returns the address of given pointer as number.</p>
|
||||
<h5
|
||||
id="pffi-pointer-object---boolean"><strong>pffi-pointer?</strong>
|
||||
object -> boolean</h5>
|
||||
<p><a name="pffi-pointer?"></a></p>
|
||||
<h4 id="pffi-pointer">pffi-pointer?
|
||||
<a name="pffi-pointer?"></a></h4>
|
||||
<p><strong>pffi-pointer?</strong> object -> boolean</p>
|
||||
<p>Returns #t if given object is pointer, #f otherwise.</p>
|
||||
<h5
|
||||
id="pffi-pointer-free-pointer"><strong>pffi-pointer-free</strong>
|
||||
pointer</h5>
|
||||
<p><a name="pffi-pointer-free"></a></p>
|
||||
<h4 id="pffi-pointer-free">pffi-pointer-free
|
||||
<a name="pffi-pointer-free"></a></h4>
|
||||
<p><strong>pffi-pointer-free</strong> pointer</p>
|
||||
<p>Frees given pointer.</p>
|
||||
<h5
|
||||
id="pffi-pointer-set-pointer-type-offset-value"><strong>pffi-pointer-set!</strong>
|
||||
pointer type offset value</h5>
|
||||
<p><a name="pffi-pointer-set!"></a></p>
|
||||
<h4 id="pffi-pointer-set">pffi-pointer-set!
|
||||
<a name="pffi-pointer-set!"></a></h4>
|
||||
<p><strong>pffi-pointer-set!</strong> pointer type offset
|
||||
value</p>
|
||||
<p>Sets the value on a pointer on given offset. For example:</p>
|
||||
<pre><code>(define p (pffi-pointer-allocate 128))
|
||||
(pffi-pointer-set! p 'int 64 100)</code></pre>
|
||||
<p>Would set the offset of 64, on pointer p to value 100.</p>
|
||||
<h5
|
||||
id="pffi-pointer-get-pointer-type-offset---object"><strong>pffi-pointer-get</strong>
|
||||
pointer type offset -> object</h5>
|
||||
<p><a name="pffi-pointer-get"></a></p>
|
||||
<h4 id="pffi-pointer-get">pffi-pointer-get
|
||||
<a name="pffi-pointer-get"></a></h4>
|
||||
<p><strong>pffi-pointer-get</strong> pointer type offset ->
|
||||
object</p>
|
||||
<p>Gets the value from a pointer on given offset. For
|
||||
example:</p>
|
||||
<pre><code>(define p (pffi-pointer-allocate 128))
|
||||
(pffi-pointer-set! p 'int 64 100)
|
||||
(pffi-pointer-get p 'int 64)
|
||||
> 100</code></pre>
|
||||
<h5
|
||||
id="pffi-string-pointer-string---pointer"><strong>pffi-string->pointer</strong>
|
||||
string -> pointer</h5>
|
||||
<p><a name="pffi-string-to-pointer"></a></p>
|
||||
<h4 id="pffi-string-pointer">pffi-string->pointer
|
||||
<a name="pffi-string-to-pointer"></a></h4>
|
||||
<p><strong>pffi-string->pointer</strong> string ->
|
||||
pointer</p>
|
||||
<p>Makes pointer out of a given string.</p>
|
||||
<h5
|
||||
id="pffi-pointer-string-pointer---string"><strong>pffi-pointer->string</strong>
|
||||
pointer -> string</h5>
|
||||
<p><a name="pffi-pointer-to-string"></a></p>
|
||||
<h4 id="pffi-pointer-string">pffi-pointer->string
|
||||
<a name="pffi-pointer-to-string"></a></h4>
|
||||
<p><strong>pffi-pointer->string</strong> pointer ->
|
||||
string</p>
|
||||
<p>Makes string out of a given pointer.</p>
|
||||
<h5
|
||||
id="pffi-struct-make-c-type-members-.-pointer---pffi-struct"><strong>pffi-struct-make</strong>
|
||||
c-type members . pointer -> pffi-struct</h5>
|
||||
<p><a name="pffi-struct-make"></a></p>
|
||||
<h4 id="pffi-struct-make">pffi-struct-make
|
||||
<a name="pffi-struct-make"></a></h4>
|
||||
<p><strong>pffi-struct-make</strong> c-type members . pointer
|
||||
-> pffi-struct</p>
|
||||
<p>Creates a new pffi-struct and allocates pointer for it. The
|
||||
members argument is a list of member names and types. For
|
||||
example:</p>
|
||||
<pre><code>(define color (pffi-struct-make 'color '((int8 . r) (int8 . g) (int8 . b) (int8 .a ))))
|
||||
(define test (pffi-struct-make "struct test" '((int8 . r) (int8 . g) (int8 . b) (int8 .a ))))</code></pre>
|
||||
<p>C-type argument can be symbol or a string.</p>
|
||||
<h5
|
||||
id="pffi-struct-pointer-pffi-struct---pointer"><strong>pffi-struct-pointer</strong>
|
||||
pffi-struct -> pointer</h5>
|
||||
<p><a name="pffi-struct-pointer"></a></p>
|
||||
<h4 id="pffi-struct-pointer">pffi-struct-pointer
|
||||
<a name="pffi-struct-pointer"></a></h4>
|
||||
<p><strong>pffi-struct-pointer</strong> pffi-struct ->
|
||||
pointer</p>
|
||||
<p>Returns the pointer that holds the struct content. You need
|
||||
to use this when passing a struct as a pointer to foreign
|
||||
functions.</p>
|
||||
<pre><code>(define s (pffi-struct-make 'test '((int . r) (int . g) (int . b))))
|
||||
(pffi-struct-pointer s)</code></pre>
|
||||
<h5
|
||||
id="pffi-struct-offset-get-member-name---number"><strong>pffi-struct-offset-get</strong>
|
||||
member-name -> number</h5>
|
||||
<p><a name="pffi-struct-offset-get"></a></p>
|
||||
<h4 id="pffi-struct-offset-get">pffi-struct-offset-get
|
||||
<a name="pffi-struct-offset-get"></a></h4>
|
||||
<p><strong>pffi-struct-offset-get</strong> member-name ->
|
||||
number</p>
|
||||
<p>Returns the offset of a struct member with given name.</p>
|
||||
<h5
|
||||
id="pffi-struct-get-pffi-struct-member-name---object"><strong>pffi-struct-get</strong>
|
||||
pffi-struct member-name -> object</h5>
|
||||
<p><a name="pffi-struct-get"></a></p>
|
||||
<h4 id="pffi-struct-get">pffi-struct-get
|
||||
<a name="pffi-struct-get"></a></h4>
|
||||
<p><strong>pffi-struct-get</strong> pffi-struct member-name
|
||||
-> object</p>
|
||||
<p>Returns the value of the givens struct member.</p>
|
||||
<h5
|
||||
id="pffi-struct-set-pffi-struct-member-name-value"><strong>pffi-struct-set!</strong>
|
||||
pffi-struct member-name value</h5>
|
||||
<p><a name="pffi-struct-set!"></a></p>
|
||||
<h4 id="pffi-struct-set">pffi-struct-set!
|
||||
<a name="pffi-struct-set!"></a></h4>
|
||||
<p><strong>pffi-struct-set!</strong> pffi-struct member-name
|
||||
value</p>
|
||||
<p>Sets the value of the givens struct member. It is up to you
|
||||
to make sure that the type of value is correct.</p>
|
||||
<h5
|
||||
id="pffi-define-scheme-name-shared-object-c-name-return-type-argument-types"><strong>pffi-define</strong>
|
||||
scheme-name shared-object c-name return-type argument-types</h5>
|
||||
<p><a name="pffi-define"></a></p>
|
||||
<h4 id="pffi-define">pffi-define <a name="pffi-define"></a></h4>
|
||||
<p><strong>pffi-define</strong> scheme-name shared-object c-name
|
||||
return-type argument-types</p>
|
||||
<p>Defines a new foreign function to be used from Scheme code.
|
||||
For example:</p>
|
||||
<pre><code>(define libc-stdlib
|
||||
|
|
@ -933,10 +926,10 @@ gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-p
|
|||
(else (pffi-shared-object-auto-load (list "stdlib.h") (list) "c" (list "" "6")))))
|
||||
(pffi-define c-puts libc-stdlib 'puts 'int (list 'pointer))
|
||||
(c-puts "Message brought to you by FFI!")</code></pre>
|
||||
<h5
|
||||
id="pffi-define-callback-scheme-name-return-type-argument-types-procedure"><strong>pffi-define-callback</strong>
|
||||
scheme-name return-type argument-types procedure</h5>
|
||||
<p><a name="pffi-define-callback"></a></p>
|
||||
<h4 id="pffi-define-callback">pffi-define-callback
|
||||
<a name="pffi-define-callback"></a></h4>
|
||||
<p><strong>pffi-define-callback</strong> scheme-name return-type
|
||||
argument-types procedure</p>
|
||||
<p>Defines a new Sceme function to be used as callback to C
|
||||
code. For example:</p>
|
||||
<pre><code>; Load the shared library
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,2 +1,2 @@
|
|||
h5 { font-weight: normal; }
|
||||
table { width: 250%; }
|
||||
pre { background-color: lightgrey; }
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="date" content='$date-meta$'>
|
||||
<title>$title$</title>
|
||||
<title>${title} - ${version}</title>
|
||||
<style>
|
||||
h5 { font-weight: normal; }
|
||||
table { width: 250%; }
|
||||
nav { float: left; width: 20%;}
|
||||
main { float: right; width: 80%; }
|
||||
|
|
@ -13,6 +11,6 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
$body$
|
||||
${body}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue