Simplify Chibi code

This commit is contained in:
retropikzel 2025-03-15 06:55:49 +02:00
parent a91d07398c
commit ad9a6778af
2 changed files with 2 additions and 12 deletions

View File

@ -165,8 +165,7 @@
(define argument->pointer
(lambda (value type)
(cond ((pffi-pointer? value) value)
((procedure? value) (scheme-procedure-to-pointer value))
(cond ((procedure? value) (scheme-procedure-to-pointer value))
(else (let ((pointer (pffi-pointer-allocate (size-of-type type))))
(pffi-pointer-set! pointer type 0 value)
pointer)))))

View File

@ -256,16 +256,7 @@
ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, (ffi_type*)rtype, (ffi_type**)atypes);
void* c_avalues[nargs];
for(int i = 0; i < nargs; i++) {
if(atypes[i] == &ffi_type_pointer) {
if(sexp_booleanp(avalues[i])) {
void* p = NULL;
c_avalues[i] = &p;
} else {
c_avalues[i] = &sexp_cpointer_value(avalues[i]);
}
} else {
c_avalues[i] = sexp_cpointer_value(avalues[i]);
}
c_avalues[i] = sexp_cpointer_value(avalues[i]);
}
ffi_call(&cif, FFI_FN(fn), rvalue, c_avalues);
}")