]> Repositorios git - scryer-prolog.git/commitdiff
update docs
authorBennet Bleßmann <[email protected]>
Wed, 16 Jul 2025 23:45:13 +0000 (01:45 +0200)
committerBennet Bleßmann <[email protected]>
Fri, 1 Aug 2025 17:42:02 +0000 (19:42 +0200)
src/lib/ffi.pl

index cce60ff614782c1313043d630da6eff14fb46e0b..165d5d04ae78d04310baa86621ee30e43f5e4511 100644 (file)
@@ -11,8 +11,8 @@ The main predicate is `use_foreign_module/2`. It takes a library name (which dep
 operating system could be a `.so`, `.dylib` or `.dll` file). and a list of functions. Each
 function is defined by its name, a list of the type of the arguments, and the return argument.
 
-Types available are: `sint8`, `uint8`, `sint16`, `uint16`, `sint32`, `uint32`, `sint64`,
-`uint64`, `f32`, `f64`, `cstr`, `void`, `bool`, `ptr` and custom structs, which can be defined
+Types available are: `sint8`/`i8`, `uint8`/`u8`, `sint16`/`i16`, `uint16`/`u16`, `sint32`/`i32`, `uint32`/`u32`, `sint64`/`i64`,
+`uint64`/`u64`, `f32`, `f64`, `cstr`, `void`, `bool`, `ptr` and custom structs, which can be defined
 with `foreign_struct/2`.
 
 After that, each function on the lists maps to a predicate created in the ffi module which
@@ -27,6 +27,12 @@ ffi:FUNCTION_NAME(+InputArg1, ..., +InputArgN, -ReturnArg). % for all return typ
 ffi:FUNCTION_NAME(+InputArg1, ..., +InputArgN). % for void and bool
 ```
 
+## Notes regarding cstr
+
+- When using `cstr` as an argument type the string will be deallocated once the function returns.
+- When using `cstr` as a return type the string will be copied and won't be deallocated.
+
+
 ## Example
 
 For example, let's see how to define a function from the [raylib](https://www.raylib.com/) library.