The type of the object to pass by reference.
If non-nil, if the input argument is
a null pointer is passed instead of a reference to an object containing
If non-nil, allow conversion from Lisp to the foreign language. The default value is
If non-nil, allow conversion from the foreign language to Lisp. The default value is
type is essentially the same as a :pointer type, except that
is automatically dereferenced when it is processed.
type is useful as a foreign function argument. When a function is called with an argument of the type
, an object of
is dynamically allocated across the scope of the foreign function, and is automatically de-allocated once the foreign function terminates. The value of the argument is not copied into the temporary instance of the object if
, and similarly, the return value is not copied back into a Lisp object if
If the argument is of an aggregate type and foreign-to-lisp-p is true, then a malloc'd copy is made which you should later free explicitly. It is usually better to use:pointer, make the temporary foreign object using with-dynamic-foreign-objects and then copy whatever slots you need into a normal Lisp object on return.
In the following example an
is allocated, and a pointer to the integer is bound to the Lisp variable
. Then a pointer to
, is defined. The pointer
is set to point to
, itself a pointer, but to an
(setq number (fli:allocate-foreign-object :type :int))
(setf (fli:dereference number) 42)
(setf (fli:dereference point1) number)
(fli:dereference (fli:dereference point1))
(fli:dereference point1 :type '(:reference :int))