Updated documentation

This commit is contained in:
retropikzel 2025-03-12 16:40:35 +02:00
parent fe7822cb29
commit 5d04b79a2b
6 changed files with 172 additions and 159 deletions

View File

@ -2,6 +2,7 @@
CC=gcc CC=gcc
DOCKER=docker run -it -v ${PWD}:/workdir DOCKER=docker run -it -v ${PWD}:/workdir
DOCKER_INIT=cd /workdir && make clean && 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 all: chibi gauche libtest.so libtest.o libtest.a
@ -11,7 +12,6 @@ docs:
pandoc --standalone \ pandoc --standalone \
--template templates/documentation.html README.md \ --template templates/documentation.html README.md \
> documentation/R7RS-PFFI.html > documentation/R7RS-PFFI.html
#pandoc -s --pdf-engine=weasyprint -o documentation/R7RS-PFFI.pdf README.md
pandoc -t html5 \ pandoc -t html5 \
--pdf-engine=weasyprint \ --pdf-engine=weasyprint \
--css templates/css/pdf-documentation.css \ --css templates/css/pdf-documentation.css \

130
README.md
View File

@ -1,5 +1,6 @@
--- ---
title: Portable Foreign Function Interface for R7RS Documentation title: Portable Foreign Function Interface for R7RS Documentation
version: 0.6.0
--- ---
# Portable Foreign Function Interface for R7RS # Portable Foreign Function Interface for R7RS
@ -35,7 +36,7 @@ conforming to some specification.
- [Chicken](#usage-chicken) - [Chicken](#usage-chicken)
- [Racket](#usage-racket) - [Racket](#usage-racket)
- [Kawa](#usage-kawa) - [Kawa](#usage-kawa)
- [Reference](#reference) - [Reference](#reference)
- [Types](#types) - [Types](#types)
- [Procedures and macros](#procedures-and-macros) - [Procedures and macros](#procedures-and-macros)
- [pffi-init](#pffi-init) - [pffi-init](#pffi-init)
@ -176,8 +177,7 @@ Needs libffi-dev, on Debina/Ubuntu/Mint install with:
Build with: Build with:
chibi-ffi retropikzel/r7rs-pffi/r7rs-pffi-chibi.stub make chibi
gcc -o retropikzel/r7rs-pffi/r7rs-pffi-chibi.so -fPIC -shared retropikzel/r7rs-pffi/r7rs-pffi-chibi.c -lchibi-scheme -lffi
#### Chicken #### Chicken
<a name="usage-chicken"></a> <a name="usage-chicken"></a>
@ -200,15 +200,15 @@ Kawa Needs at least Java version 22
Needs jvm flags: Needs jvm flags:
- --add-exports java.base/jdk.internal.foreign.abi=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.layout=ALL-UNNAMED
- --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED - \--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED
- --enable-native-access=ALL-UNNAMED - \--enable-native-access=ALL-UNNAMED
### Reference ## Reference
<a name="reference"></a> <a name="reference"></a>
#### Types ### Types
<a name="types"></a> <a name="types"></a>
Types are given as symbols, for example 'int8 or 'pointer. 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
- Callback function - Callback function
#### Procedures and macros ### Procedures and macros
<a name="procedures-and-macros"></a> <a name="procedures-and-macros"></a>
Some of these are procedures and some macros, it might also change implementation to implementation. Some of these are procedures and some macros, it might also change implementation to implementation.
##### **pffi-init** #### pffi-init <a name="pffi-init"></a>
<a name="pffi-init"></a>
**pffi-init**
Always call this first, on most implementation it does nothing but some implementations might need Always call this first, on most implementation it does nothing but some implementations might need
initialisation run. initialisation run.
##### **pffi-size-of** object -> number #### pffi-size-of <a name="pffi-size-of"></a>
<a name="pffi-size-of"></a>
**pffi-size-of** object -> number
Returns the size of the pffi-struct, pffi-enum or pffi-type. Returns the size of the pffi-struct, pffi-enum or pffi-type.
##### **pffi-align-of** type -> number #### pffi-align-of <a name="pffi-align-of"></a>
<a name="pffi-align-of"></a>
**pffi-align-of** type -> number
Returns the align of the type. Returns the align of the type.
##### **pffi-shared-object-auto-load** headers shared-object-name [options] -> object #### pffi-shared-object-auto-load <a name="pffi-shared-object-auto-load"></a>
<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. Load given shared object automatically searching many predefined paths.
@ -286,8 +290,9 @@ Example:
'(additional-search-paths . (".")))))) '(additional-search-paths . ("."))))))
##### **pffi-shared-object-load** headers path [options] #### pffi-shared-object-load <a name="pffi-shared-object-load"></a>
<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 It is recommended to use the pffi-shared-object-auto-load instead of this
directly. directly.
@ -306,38 +311,45 @@ Options:
- additional-versions - additional-versions
- List of different versions of library to try, for example (list ".0" ".1") - List of different versions of library to try, for example (list ".0" ".1")
##### **pffi-pointer-null** -> pointer #### pffi-pointer-null <a name="pffi-pointer-null"></a>
<a name="pffi-pointer-null"></a>
**pffi-pointer-null** -> pointer
Returns a new NULL pointer. Returns a new NULL pointer.
##### **pffi-pointer-null?** pointer -> boolean #### pffi-pointer-null? <a name="pffi-pointer-null?"></a>
<a name="pffi-pointer-null?"></a>
**pffi-pointer-null?** pointer -> boolean
Returns #t if given pointer is null pointer, #f otherwise. Returns #t if given pointer is null pointer, #f otherwise.
##### **pffi-pointer-allocate** size -> pointer #### pffi-pointer-allocate <a name="pffi-pointer-allocate"></a>
<a name="pffi-pointer-allocate"></a>
**pffi-pointer-allocate** size -> pointer
Returns newly allocated pointer of given size. Returns newly allocated pointer of given size.
##### **pffi-pointer-address** pointer -> number #### pffi-pointer-address <a name="pffi-pointer-address"></a>
<a name="pffi-pointer-address"></a>
**pffi-pointer-address** pointer -> number
Returns the address of given pointer as number. Returns the address of given pointer as number.
##### **pffi-pointer?** object -> boolean #### pffi-pointer? <a name="pffi-pointer?"></a>
<a name="pffi-pointer?"></a>
**pffi-pointer?** object -> boolean
Returns #t if given object is pointer, #f otherwise. Returns #t if given object is pointer, #f otherwise.
##### **pffi-pointer-free** pointer #### pffi-pointer-free <a name="pffi-pointer-free"></a>
<a name="pffi-pointer-free"></a>
**pffi-pointer-free** pointer
Frees given pointer. Frees given pointer.
##### **pffi-pointer-set!** pointer type offset value #### pffi-pointer-set! <a name="pffi-pointer-set!"></a>
<a name="pffi-pointer-set!"></a>
**pffi-pointer-set!** pointer type offset value
Sets the value on a pointer on given offset. For example: 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. Would set the offset of 64, on pointer p to value 100.
##### **pffi-pointer-get** pointer type offset -> object #### pffi-pointer-get <a name="pffi-pointer-get"></a>
<a name="pffi-pointer-get"></a>
**pffi-pointer-get** pointer type offset -> object
Gets the value from a pointer on given offset. For example: 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) (pffi-pointer-get p 'int 64)
> 100 > 100
##### **pffi-string->pointer** string -> pointer #### pffi-string->pointer <a name="pffi-string-to-pointer"></a>
<a name="pffi-string-to-pointer"></a>
**pffi-string->pointer** string -> pointer
Makes pointer out of a given string. Makes pointer out of a given string.
##### **pffi-pointer->string** pointer -> string #### pffi-pointer->string <a name="pffi-pointer-to-string"></a>
<a name="pffi-pointer-to-string"></a>
**pffi-pointer->string** pointer -> string
Makes string out of a given pointer. Makes string out of a given pointer.
##### **pffi-struct-make** c-type members . pointer -> pffi-struct #### pffi-struct-make <a name="pffi-struct-make"></a>
<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 Creates a new pffi-struct and allocates pointer for it. The members argument is a list of member
names and types. For example: names and types. For example:
@ -377,8 +393,9 @@ names and types. For example:
C-type argument can be symbol or a string. C-type argument can be symbol or a string.
##### **pffi-struct-pointer** pffi-struct -> pointer #### pffi-struct-pointer <a name="pffi-struct-pointer"></a>
<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 Returns the pointer that holds the struct content. You need to use this when passing a struct as
a pointer to foreign functions. 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)))) (define s (pffi-struct-make 'test '((int . r) (int . g) (int . b))))
(pffi-struct-pointer s) (pffi-struct-pointer s)
##### **pffi-struct-offset-get** member-name -> number #### pffi-struct-offset-get <a name="pffi-struct-offset-get"></a>
<a name="pffi-struct-offset-get"></a>
**pffi-struct-offset-get** member-name -> number
Returns the offset of a struct member with given name. Returns the offset of a struct member with given name.
##### **pffi-struct-get** pffi-struct member-name -> object #### pffi-struct-get <a name="pffi-struct-get"></a>
<a name="pffi-struct-get"></a>
**pffi-struct-get** pffi-struct member-name -> object
Returns the value of the givens struct member. Returns the value of the givens struct member.
##### **pffi-struct-set!** pffi-struct member-name value #### pffi-struct-set! <a name="pffi-struct-set!"></a>
<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 Sets the value of the givens struct member. It is up to you to make sure that the type of value is
correct. correct.
##### **pffi-define** scheme-name shared-object c-name return-type argument-types #### pffi-define <a name="pffi-define"></a>
<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: 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)) (pffi-define c-puts libc-stdlib 'puts 'int (list 'pointer))
(c-puts "Message brought to you by FFI!") (c-puts "Message brought to you by FFI!")
##### **pffi-define-callback** scheme-name return-type argument-types procedure #### pffi-define-callback <a name="pffi-define-callback"></a>
<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: Defines a new Sceme function to be used as callback to C code. For example:

View File

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

Binary file not shown.

View File

@ -1,2 +1,2 @@
h5 { font-weight: normal; } table { width: 250%; }
pre { background-color: lightgrey; } pre { background-color: lightgrey; }

View File

@ -2,10 +2,8 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="date" content='$date-meta$'> <title>${title} - ${version}</title>
<title>$title$</title>
<style> <style>
h5 { font-weight: normal; }
table { width: 250%; } table { width: 250%; }
nav { float: left; width: 20%;} nav { float: left; width: 20%;}
main { float: right; width: 80%; } main { float: right; width: 80%; }
@ -13,6 +11,6 @@
</style> </style>
</head> </head>
<body> <body>
$body$ ${body}
</body> </body>
</html> </html>