don't place allocate, read_ptr and deallocate between use_foreign_module and its helper predicates

This commit is contained in:
Skgland
2025-08-09 17:50:30 +02:00
committed by Bennet Bleßmann
parent 20d52c093a
commit d8346b1651

View File

@@ -73,23 +73,6 @@ use_foreign_module(LibName, Predicates) :-
'$load_foreign_lib'(LibName, Predicates),
maplist(assert_predicate, Predicates).
allocate(Allocator, Type, Args, Ptr) :-
must_be(var, Ptr),
must_be(atom, Type),
must_be(atom, Allocator),
'$ffi_allocate'(Allocator, Type, Args, Ptr).
read_ptr(Type, Ptr, Value) :-
must_be(var, Value),
must_be(atom, Type),
must_be(integer, Ptr),
'$ffi_read_ptr'(Type, Ptr, Value).
deallocate(Allocator, Type, Ptr) :-
must_be(atom, Allocator),
must_be(integer, Ptr),
'$ffi_deallocate'(Allocator, Type, Ptr).
assert_predicate(PredicateDefinition) :-
PredicateDefinition =.. [Name, Inputs, void],
length(Inputs, NumInputs),
@@ -125,3 +108,22 @@ assert_predicate(PredicateDefinition) :-
),
Predicate = (Head:-Body),
assertz(ffi:Predicate).
allocate(Allocator, Type, Args, Ptr) :-
must_be(var, Ptr),
must_be(atom, Type),
must_be(atom, Allocator),
'$ffi_allocate'(Allocator, Type, Args, Ptr).
read_ptr(Type, Ptr, Value) :-
must_be(var, Value),
must_be(atom, Type),
must_be(integer, Ptr),
'$ffi_read_ptr'(Type, Ptr, Value).
deallocate(Allocator, Type, Ptr) :-
must_be(atom, Allocator),
must_be(integer, Ptr),
'$ffi_deallocate'(Allocator, Type, Ptr).