summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-04 06:45:59 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-04 06:45:59 -0700
commit06352f1874845023738ab9eeb50c5612b1affcb4 (patch)
tree02e46f9a1e4e4b7b10c370b86f9c2bcc69e0d5f1 /txr.1
parent57c9049794f108fe7ba593a5ed29511bdeb8314c (diff)
downloadtxr-06352f1874845023738ab9eeb50c5612b1affcb4.tar.gz
txr-06352f1874845023738ab9eeb50c5612b1affcb4.tar.bz2
txr-06352f1874845023738ab9eeb50c5612b1affcb4.zip
FFI: big improvement in bad call diagnosis.
FFI has the problem that when things go wrong in calls, or in specifications of functions, the diagnostics refer to an internal function like ffi-call or ffi-make-call-desc, which is not helpful in identifying the error. We want the diagnostics to refer to the foreign function, or foreignb callback wrapper, to which the problem pertains. The approach taken is to stick the name symbol into the ffi-call-desc object. Functions which work with a ffi-call-desc can pull out the name and use it for reporting. * ffi.c (struct txr_ffi_call_desc): Add name member. (ffi_call_desc_print_op): Include name in printed representation. (ffi_desc_mark_op): Mark the name. (ffi_make_call_desc): Take new argument to specify the name, storing it into the structure. If it is specified,then use that name for reporting errors, otherwise stick with ffi-make-call-desc. (ffi_call_wrap, ffi_closure_dispatch, ffi_closure_dispatch_safe, ffi_make_closure): Use the name from the call descriptor, or else the function's own name if that is nil. (ffi_init): Update registration of ffi-make-call-desc intrinsic to five arguments with four required. * ffi.h (ffi_make_call_desc): Declaration updated. * share/txr/stdlib/ffi.tl (deffi, deffi-cb-expander): Pass the name symbol down to ffi-make-call-desc. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.111
1 files changed, 10 insertions, 1 deletions
diff --git a/txr.1 b/txr.1
index d3e3a769..d4b58266 100644
--- a/txr.1
+++ b/txr.1
@@ -74953,7 +74953,8 @@ a Lisp expression denoting FFI syntax.
.coNP Function @ ffi-make-call-desc
.synb
-.mets (ffi-make-call-desc < ntotal < nfixed < rettype << argtypes )
+.mets (ffi-make-call-desc < ntotal < nfixed < rettype
+.mets \ \ < argtypes <> [ name ])
.syne
.desc
The
@@ -74992,6 +74993,14 @@ If the function is variadic, then the first
elements of this list specify the types of the fixed arguments;
the remaining elements specify the variadic arguments.
+The
+.meta name
+argument gives the name of the function for which this description is intended,
+or some other identifying symbol. This symbols is used in diagnostic messages
+related to errors in the construction of the descriptor itself or its
+subsequent use. If this parameter is omitted, then the involved FFI functions
+use their own names in reporting diagnostics.
+
Note: variadic functions must not be called using a non-variadic
descriptor, and
.IR "vice versa" ,