Next: , Previous: , Up: Alien Function Calls   [Contents][Index]

8.7.4 Calling Lisp from C

CMUCL supports calling Lisp from C via the def-callback macro:

Macro: alien:def-callback name (return-type {(arg-name arg-type)}*) &body body

This macro defines a Lisp function that can be called from C and a Lisp variable. The arguments to the function must be alien types, and the return type must also be an alien type. This Lisp function can be accessed via the callback macro.

name is the name of the Lisp function. It is also the name of a variable to be used by the callback macro.

return-type is the return type of the function. This must be a recognized alien type.

arg-name specifies the name of the argument to the function, and the argument has type arg-type, which must be an alien type.

Macro: alien:callback callback-symbol

This macro extracts the appropriate information for the function named callback-symbol so that it can be called by a C function. callback-symbol must be a symbol created by the def-callback macro.

Macro: alien:callback-funcall callback-name &rest args

This macro does the necessary stuff to call the callback named callback-name with the given arguments.