summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-06 16:01:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-06 16:01:35 -0700
commitdb161112abb1c684bf91b2c434e18b488c0aa2ca (patch)
tree9776e07d278953ebb82d4ebec239c174e1658e14 /txr.1
parent662d19a6e7fc9dad3ed7eafe50215028f65a456d (diff)
downloadtxr-db161112abb1c684bf91b2c434e18b488c0aa2ca.tar.gz
txr-db161112abb1c684bf91b2c434e18b488c0aa2ca.tar.bz2
txr-db161112abb1c684bf91b2c434e18b488c0aa2ca.zip
ffi: allow nil object to convert under closure type.
* ffi.c (ffi_closure_put): Only diagnose a bad object if it's not nil, otherwise let the null value of p through. This is useful because there are sometimes C interfaces which take an optional function pointer, whereby a null value indicates that the pointer is not specified.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.133
1 files changed, 30 insertions, 3 deletions
diff --git a/txr.1 b/txr.1
index 58439d26..72cff575 100644
--- a/txr.1
+++ b/txr.1
@@ -73233,11 +73233,29 @@ the foreign function alters the pointer.
.coNP FFI type @ closure
The
.code closure
-type converts two kinds of Lisp objects to a C pointer: the
+type converts three kinds of Lisp objects to a C pointer: the object
+.codn nil ,
+the
.code cptr
-type, and the special
+type, or the special
.code ffi-closure
-type, whose instances are produced by the
+type.
+
+When the
+.code nil
+symbol is converted to a
+.code closure
+type, it becomes a null function pointer.
+
+A
+.code cptr
+object of any kind converts to a
+.codn closure ;
+the internal pointer is converted to a function pointer.
+
+Instances of the
+.code ffi-closure
+type are produced by the
.code ffi-make-closure
function, or by calls to functions defined by the
.code deffi-cb
@@ -73246,6 +73264,15 @@ macro. The
type is useful for passing callbacks to foreign functions: Lisp functions
which appear to be C functions to foreign code.
+In the reverse direction, when a
+.code closure
+object is converted from the foreign function pointer representation
+to a Lisp object, it becomes a
+.code cptr
+object whose tag is the
+.code closure
+symbol.
+
.coNP FFI type @ void
The
.code void