--- a/ExternalFunctionCallback.st Mon Aug 08 19:20:22 2011 +0200
+++ b/ExternalFunctionCallback.st Wed Aug 10 01:20:10 2011 +0200
@@ -260,13 +260,13 @@
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].
+ cb action:[:args | Transcript showCR:args. true].
Eventually, the callback MUST be released:
- cb release.
+ cb release.
[author:]
- Claus Gittinger
+ Claus Gittinger
"
!
@@ -295,7 +295,7 @@
callbackFor:aBlock returnType:returnType argumentTypes:argumentTypes
"generate a callback for the ErrorCallbackProc signature:
- ErrorCallbackProc(HWND hWnd, int nErrID, LPTSTR lpErrorText)
+ ErrorCallbackProc(HWND hWnd, int nErrID, LPTSTR lpErrorText)
which, can be given to an external API call and which invokes the
three arg block when clled.
Do not forget to eventually release the callback to avoid a memory leak."
@@ -323,15 +323,15 @@
errorCallbackProcFor:aThreeArgBlock
"generate a callback for the ErrorCallbackProc signature:
- ErrorCallbackProc(HWND hWnd, int nErrID, LPTSTR lpErrorText)
+ ErrorCallbackProc(HWND hWnd, int nErrID, LPTSTR lpErrorText)
which, can be given to an external API call and which invokes the
three arg block when clled.
Do not forget to eventually release the callback to avoid a memory leak."
- ^ self
- callbackFor:aThreeArgBlock
- returnType:#long
- argumentTypes:#(handle int charPointer)
+ ^ self
+ callbackFor:aThreeArgBlock
+ returnType:#long
+ argumentTypes:#(handle int charPointer)
"
|cb|
@@ -384,32 +384,32 @@
testCall:aCallback withArguments:args
"a simple test, if I can be called"
%{
-# define MAX_ARGS 5
+# define MAX_CALLBACK_ARGS 5
INTFUNC f = __externalAddressVal(aCallback);
INT result;
int i;
- void *c_args[MAX_ARGS];
+ void *c_args[MAX_CALLBACK_ARGS];
if (! __isArray(args))
- goto badArg;
- if (__arraySize(args) > MAX_ARGS)
- goto badArg;
+ goto badArg;
+ if (__arraySize(args) > MAX_CALLBACK_ARGS)
+ goto badArg;
for (i=0; i < __arraySize(args); i++) {
- OBJ arg = __ArrayInstPtr(args)->a_element[i];
+ OBJ arg = __ArrayInstPtr(args)->a_element[i];
- if (__isSmallInteger(arg)) {
- c_args[i] = (void *)(__intVal(arg));
- } else if (arg == true) {
- c_args[i] = (void *)1;
- } else if (arg == false) {
- c_args[i] = (void *)0;
- } else if (__isStringLike(arg)) {
- c_args[i] = (void *)__stringVal(arg);
- } else if (__isByteArrayLike(arg)) {
- c_args[i] = (void *)__byteArrayVal(arg);
- } else
- goto badArg;
+ if (__isSmallInteger(arg)) {
+ c_args[i] = (void *)(__intVal(arg));
+ } else if (arg == true) {
+ c_args[i] = (void *)1;
+ } else if (arg == false) {
+ c_args[i] = (void *)0;
+ } else if (__isStringLike(arg)) {
+ c_args[i] = (void *)__stringVal(arg);
+ } else if (__isByteArrayLike(arg)) {
+ c_args[i] = (void *)__byteArrayVal(arg);
+ } else
+ goto badArg;
}
fprintf(stderr, "ExternalFunctionCallback: calling callBack %x(%x, %x)\n", f, c_args[0], c_args[1]);
result = (*f)(c_args[0], c_args[1], c_args[2], c_args[3], c_args[4]);
@@ -819,8 +819,8 @@
__INST(code_) = 0;
if (pcl) {
- free(pcl);
- RETURN(self);
+ free(pcl);
+ RETURN(self);
}
%}.
self invalidateReference.
@@ -829,9 +829,9 @@
!ExternalFunctionCallback class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunctionCallback.st,v 1.15 2009-11-05 16:25:17 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunctionCallback.st,v 1.16 2011-08-09 23:20:10 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunctionCallback.st,v 1.15 2009-11-05 16:25:17 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalFunctionCallback.st,v 1.16 2011-08-09 23:20:10 cg Exp $'
! !