Updating readme

This commit is contained in:
retropikzel 2025-01-25 14:07:01 +02:00
parent e86069ffd8
commit 6cb243bc2d
1 changed files with 21 additions and 20 deletions

View File

@ -23,6 +23,7 @@ Any help in form of constructive advice and bug reports are appreciated.
- [Reference](#reference)
- [Types](#types)
- [Procedures and macros](#procedures-and-macros)
- [pffi-init](#strongpffi-initstrong)
## Goals
@ -176,15 +177,15 @@ initialisation run.
Returns the size of the type.
**pffi-align-of** type -> number
##### **pffi-align-of** type -> number
Returns the align of the type.
**pffi-shared-object-auto-load**
##### **pffi-shared-object-auto-load**
TODO
**pffi-shared-object-load** headers path
##### **pffi-shared-object-load** headers path
It is recommended to use the pffi-shared-object-auto-load instead of this
directly.
@ -197,27 +198,27 @@ Path is the full path of the shared object without any "lib" prefix or ".so/.dll
"curl"
**pffi-pointer-null** -> pointer
##### **pffi-pointer-null** -> pointer
Returns a new NULL pointer.
**pffi-pointer-null?** pointer -> boolean
##### **pffi-pointer-null?** pointer -> boolean
Returns #t if given pointer is null pointer, #f otherwise.
**pffi-pointer-allocate** size -> pointer
##### **pffi-pointer-allocate** size -> pointer
Returns newly allocated pointer of given size.
**pffi-pointer?** object -> boolean
##### **pffi-pointer?** object -> boolean
Returns #t if given object is pointer, #f otherwise.
**pffi-pointer-free** pointer
##### **pffi-pointer-free** pointer
Frees given pointer.
**pffi-pointer-set!** pointer type offset value
##### **pffi-pointer-set!** pointer type offset value
Sets the value on a pointer on given offset. For example:
@ -226,7 +227,7 @@ 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** pointer type offset -> object
Gets the value from a pointer on given offset. For example:
@ -235,22 +236,22 @@ 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** string -> pointer
Makes pointer out of a given string.
**pffi-pointer->string** pointer -> string
##### **pffi-pointer->string** pointer -> string
Makes string out of a given pointer.
**pffi-struct-make** name members . pointer -> pffi-struct
##### **pffi-struct-make** name 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:
(define s (pffi-struct-make 'test '((int . r) (int . g) (int . b))))
**pffi-struct-size** pffi-struct -> number
##### **pffi-struct-size** pffi-struct -> number
Returns the size of a given pffi-struct. For example:
@ -258,7 +259,7 @@ Returns the size of a given pffi-struct. For example:
(pffi-struct-size s)
> 12
**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.
@ -266,20 +267,20 @@ 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** 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 member-name -> object
Returns the value of the givens struct member.
**pffi-struct-set!** pffi-struct member-name value
##### **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** scheme-name shared-object c-name return-type argument-types
Defines a new foreign function to be used from Scheme code. For example:
@ -290,7 +291,7 @@ 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** scheme-name return-type argument-types procedure
Defines a new Sceme function to be used as callback to C code. For example: