support cstr as an ffi return type and do some more restructuring

This commit is contained in:
Bennet Bleßmann
2025-07-17 01:28:52 +02:00
committed by Bennet Bleßmann
parent 9cccd509e3
commit 0c2c6124eb
6 changed files with 551 additions and 415 deletions

16
tests-pl/ffi_cstr.pl Normal file
View File

@@ -0,0 +1,16 @@
:- use_module(library(os)).
:- use_module(library(ffi)).
test :-
read(Body),
term_variables(Body, [LIB]),
Body,
use_foreign_module(LIB, [
'ffi_cstr_len'([cstr], u64),
'ffi_example_cstr'([], cstr)
]),
ffi:'ffi_cstr_len'("Scryer Prolog", Len),
ffi:'ffi_example_cstr'(Str),
write((Len-Str)).
:- initialization(test).