diff options
-rw-r--r-- | ffi.c | 4 | ||||
-rw-r--r-- | share/txr/stdlib/ffi.tl | 4 | ||||
-rw-r--r-- | txr.1 | 9 |
3 files changed, 10 insertions, 7 deletions
@@ -4783,15 +4783,15 @@ val ffi_make_call_desc(val ntotal, val nfixed, val rettype, val argtypes, { val name = default_null_arg(name_in); val self = if3(name, name, lit("ffi-make-call-desc")); - cnum nf = c_num(default_arg(nfixed, zero), self); cnum nt = c_num(ntotal, self), i; + cnum nf = c_num(default_arg(nfixed, ntotal), self); struct txr_ffi_call_desc *tfcd = coerce(struct txr_ffi_call_desc *, chk_calloc(1, sizeof *tfcd)); ffi_type **args = coerce(ffi_type **, chk_xalloc(nt, sizeof *args, self)); val obj = cobj(coerce(mem_t *, tfcd), ffi_call_desc_s, &ffi_call_desc_ops); ffi_status ffis = FFI_OK; - tfcd->variadic = (nfixed != nil); + tfcd->variadic = (nt != nf); tfcd->nfixed = nf; tfcd->ntotal = nt; tfcd->argtypes = argtypes; diff --git a/share/txr/stdlib/ffi.tl b/share/txr/stdlib/ffi.tl index 73ee1936..dbf7888c 100644 --- a/share/txr/stdlib/ffi.tl +++ b/share/txr/stdlib/ffi.tl @@ -74,12 +74,12 @@ (arg-types-sym (gensym "arg-types-")) (call-desc-sym (gensym "call-desc-")) (fun-sym (gensym "ffi-fun-"))) - (tree-bind (nargs nvariadic . argtypes) (sys:analyze-argtypes f argtypes) + (tree-bind (nargs nfixed . argtypes) (sys:analyze-argtypes f argtypes) (let ((arg-syms (take nargs (gun (gensym))))) ^(progn (defvarl ,ret-type-sym (ffi-type-compile ',rettype)) (defvarl ,arg-types-sym [mapcar ffi-type-compile ',argtypes]) - (defvarl ,call-desc-sym (ffi-make-call-desc ,nargs ,nvariadic + (defvarl ,call-desc-sym (ffi-make-call-desc ,nargs ,nfixed ,ret-type-sym ,arg-types-sym ',name)) @@ -75185,13 +75185,16 @@ of arguments in the call. If the call denotes a variadic function, the .meta nfixed -argument must be an integer between 1 and +argument must be an integer at least 1 and less than .metn ntotal , denoting the number of fixed arguments. If the call denotes an ordinary, non-variadic function, then .meta nfixed -must be specified as -.codn nil . +must either be specified specified as +.code nil +or else equal to the +.meta ntotal +argument. The .meta rettype |