Simplify Chibi code
This commit is contained in:
parent
a91d07398c
commit
ad9a6778af
|
|
@ -165,8 +165,7 @@
|
||||||
|
|
||||||
(define argument->pointer
|
(define argument->pointer
|
||||||
(lambda (value type)
|
(lambda (value type)
|
||||||
(cond ((pffi-pointer? value) value)
|
(cond ((procedure? value) (scheme-procedure-to-pointer value))
|
||||||
((procedure? value) (scheme-procedure-to-pointer value))
|
|
||||||
(else (let ((pointer (pffi-pointer-allocate (size-of-type type))))
|
(else (let ((pointer (pffi-pointer-allocate (size-of-type type))))
|
||||||
(pffi-pointer-set! pointer type 0 value)
|
(pffi-pointer-set! pointer type 0 value)
|
||||||
pointer)))))
|
pointer)))))
|
||||||
|
|
|
||||||
|
|
@ -256,16 +256,7 @@
|
||||||
ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, (ffi_type*)rtype, (ffi_type**)atypes);
|
ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, (ffi_type*)rtype, (ffi_type**)atypes);
|
||||||
void* c_avalues[nargs];
|
void* c_avalues[nargs];
|
||||||
for(int i = 0; i < nargs; i++) {
|
for(int i = 0; i < nargs; i++) {
|
||||||
if(atypes[i] == &ffi_type_pointer) {
|
c_avalues[i] = sexp_cpointer_value(avalues[i]);
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ffi_call(&cif, FFI_FN(fn), rvalue, c_avalues);
|
ffi_call(&cif, FFI_FN(fn), rvalue, c_avalues);
|
||||||
}")
|
}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue