![]() |
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 acquired 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. [supported returnTypes:] int uint uint8 uint16 uint32 uint64 sint sint8 sint16 sint32 sint64 long system dependent sint32 or sint64 ulong system dependent uint32 or uint64 bool float double void pointer, handle, charPointer, bytePointer, floatPointer doublePointer intPointer shortPointer wcharPointer <name of subclass of ExternalAddress> [supported argumentTypes:] handle pointer voidPointer long, ulong - system dependent int, uint8, sint8, uint16, sint16, uint32, sint32, float, double void charPointer, floatPointer, doublePointer, <name of subclass of ExternalAddress> Class protocol:constants helpers
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. 'address can be passed to C'. Transcript showCR:cb code. ExternalFunctionCallback testCall:cb withArgument:123. cb action:[:args | Transcript show:'hello '; showCR:args. true]. ExternalFunctionCallback testCall:cb withArgument:123. cb release |
|
ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Sep 2023 04:01:32 GMT
|