|
Smalltalk/X WebserverDocumentation of class 'ExternalFunctionCallback': |
|
|
Class: ExternalFunctionCallbackInheritance:Object | +--ExecutableFunction | +--ExternalFunction | +--ExternalFunctionCallback
Description:
an ExternalFunctionCallback wraps a block into a C-callable function;
i.e. it creates a closure, which as seen from C-code looks like an ordinary
function pointer, but when invoked evaluates a smalltalk block.
A callback is created with:
cb := ExternalFunctionCallback new.
the arguments (as passed from the C-caller into ST)
and the returnValue (from ST to the C-caller) are specified with:
cb returnType:#bool argumentTypes:#(uint).
Then, the code is generated with:
cb generateClosure.
After that, the callBack-functions address can be aquired with:
cb address. 'can be passed to C'.
and handed out to C. (you can also hand out the callBack directly - as it is a subclass of
ExternalBytes.
The actual action of the callback can be changed (at any time later) with:
cb action:[:args | Transcript showCR:args. true].
Eventually, the callback MUST be released:
cb release.
Class protocol:common callbacks
Instance protocol:accessing
Examples:|cb| cb := ExternalFunctionCallback new. cb returnType:#bool argumentTypes:#(uint). cb beCallTypeWINAPI. cb generateClosure. cb action:[:args | Transcript showCR:args. true]. cb code. 'can be passed to C'. ExternalFunctionCallback testCall:cb withArgument:123. cb action:[:args | Transcript show:'hello '; showCR:args. true]. ExternalFunctionCallback testCall:cb withArgument:123. cb release |
|
|
ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 09:06:51 GMT
|