--- a/ExternalLibraryFunction.st Thu Feb 22 17:07:47 2018 +0100
+++ b/ExternalLibraryFunction.st Sat Feb 24 13:13:46 2018 +0100
@@ -605,43 +605,43 @@
"let this execute in a separate thread, in par with the other execution thread(s).
Ignored under unix/linux (until those support multiple threads too)."
- flags := (flags ? 0) bitOr: FLAG_ASYNC.
+ flags := flags bitOr: FLAG_ASYNC.
"Created: / 01-08-2006 / 13:42:38 / cg"
!
beCallTypeAPI
- flags := (flags ? 0) bitOr: CALLTYPE_API.
+ flags := flags bitOr: CALLTYPE_API.
"Created: / 01-08-2006 / 15:12:40 / cg"
!
beCallTypeC
- flags := (flags ? 0) bitOr: CALLTYPE_C.
+ flags := flags bitOr: CALLTYPE_C.
"Created: / 01-08-2006 / 15:12:40 / cg"
!
beCallTypeOLE
- flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
+ flags := flags bitOr: FLAG_VIRTUAL.
"Created: / 01-08-2006 / 15:12:40 / cg"
!
beCallTypeUNIX64
- flags := (flags ? 0) bitOr: CALLTYPE_UNIX64.
+ flags := flags bitOr: CALLTYPE_UNIX64.
"Created: / 01-08-2006 / 15:13:38 / cg"
!
beCallTypeV8
- flags := (flags ? 0) bitOr: CALLTYPE_V8.
+ flags := flags bitOr: CALLTYPE_V8.
"Created: / 01-08-2006 / 15:13:28 / cg"
!
beCallTypeV9
- flags := (flags ? 0) bitOr: CALLTYPE_V9.
+ flags := flags bitOr: CALLTYPE_V9.
"Created: / 01-08-2006 / 15:13:31 / cg"
!
@@ -656,7 +656,7 @@
"specify that a pointer return value is not to be finalized
(i.e. points to static data or data which is freed by c)"
- flags := (flags ? 0) bitOr: FLAG_RETVAL_IS_CONST.
+ flags := flags bitOr: FLAG_RETVAL_IS_CONST.
"Created: / 01-08-2006 / 13:56:48 / cg"
!
@@ -665,7 +665,7 @@
"specify that a pointer return value is to be freed explicitly by st/x
(i.e. points to mallocd data which is not freed by c)"
- flags := (flags ? 0) bitOr: FLAG_RETVAL_MUST_FREE.
+ flags := flags bitOr: FLAG_RETVAL_MUST_FREE.
"Created: / 12-02-2017 / 23:41:48 / cg"
!
@@ -673,7 +673,7 @@
beNonVirtualCPP
"specify this as a non-virtual c++-function"
- flags := (flags ? 0) bitOr: FLAG_NONVIRTUAL.
+ flags := flags bitOr: FLAG_NONVIRTUAL.
"Created: / 01-08-2006 / 13:56:44 / cg"
!
@@ -681,7 +681,7 @@
beObjectiveC
"specify this as an objective-c message send"
- flags := (flags ? 0) bitOr: FLAG_OBJECTIVEC.
+ flags := flags bitOr: FLAG_OBJECTIVEC.
"Created: / 01-08-2006 / 13:56:48 / cg"
!
@@ -691,7 +691,7 @@
for unlimited auto-sized-stack under unix/linux.
Ignored under windows."
- flags := (flags ? 0) bitOr: FLAG_UNLIMITEDSTACK.
+ flags := flags bitOr: FLAG_UNLIMITEDSTACK.
"Created: / 01-08-2006 / 13:41:54 / cg"
!
@@ -699,13 +699,13 @@
beVirtualCPP
"specify this as a virtual c++-function"
- flags := (flags ? 0) bitOr: FLAG_VIRTUAL.
+ flags := flags bitOr: FLAG_VIRTUAL.
"Created: / 01-08-2006 / 13:56:48 / cg"
!
callTypeNumber
- ^ (flags ? 0) bitAnd: CALLTYPE_MASK.
+ ^ flags bitAnd: CALLTYPE_MASK.
"Created: / 01-08-2006 / 15:12:10 / cg"
!
@@ -713,7 +713,7 @@
isAsync
"is this executed in a separate thread, in par with the other execution thread(s) ?"
- ^ (flags ? 0) bitTest: FLAG_ASYNC.
+ ^ flags bitTest: FLAG_ASYNC.
"Created: / 01-08-2006 / 13:46:53 / cg"
!
@@ -721,7 +721,7 @@
isCPPFunction
"is this a virtual or non-virtual c++-function ?"
- ^ (flags ? 0) bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
+ ^ flags bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL).
"Created: / 01-08-2006 / 13:56:54 / cg"
!
@@ -732,7 +732,7 @@
and MUST be declared as such for many Kernel functions.
The calltype API is one of the worst historic garbage kept by MS..."
- ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
+ ^ (flags bitAnd: CALLTYPE_MASK) == CALLTYPE_API.
"Created: / 01-08-2006 / 15:21:16 / cg"
!
@@ -740,7 +740,7 @@
isCallTypeC
"is this a regular C-call (attention: on windows, there are two kinds of calls)"
- ^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
+ ^ (flags bitAnd: CALLTYPE_MASK) == CALLTYPE_C.
"Created: / 01-08-2006 / 15:21:23 / cg"
!
@@ -748,7 +748,7 @@
isCallTypeOLE
"is this an OLE-object call ? (eg. a virtual c++ call; same as isCallTypeCPP)"
- ^ (flags ? 0) bitTest: FLAG_VIRTUAL.
+ ^ flags bitTest: FLAG_VIRTUAL.
"Created: / 01-08-2006 / 15:21:23 / cg"
"Modified (format): / 12-11-2016 / 11:37:38 / cg"
@@ -758,7 +758,7 @@
"is the pointer return value not to be finalized
(i.e. points to static data or data which is freed by c)"
- ^ (flags ? 0) bitTest: FLAG_RETVAL_IS_CONST.
+ ^ flags bitTest: FLAG_RETVAL_IS_CONST.
"Created: / 01-08-2006 / 13:56:48 / cg"
!
@@ -766,7 +766,7 @@
isNonVirtualCPP
"is this a non-virtual c++-function ?"
- ^ (flags ? 0) bitTest: FLAG_NONVIRTUAL.
+ ^ flags bitTest: FLAG_NONVIRTUAL.
"Created: / 01-08-2006 / 13:56:51 / cg"
!
@@ -774,7 +774,7 @@
isObjectiveC
"is this an objective-C message?"
- ^ (flags ? 0) bitTest: FLAG_OBJECTIVEC.
+ ^ flags bitTest: FLAG_OBJECTIVEC.
!
isUnlimitedStack
@@ -782,7 +782,7 @@
for unlimited auto-sized-stack under unix/linux.
Ignored under windows."
- ^ (flags ? 0) bitTest: FLAG_UNLIMITEDSTACK.
+ ^ flags bitTest: FLAG_UNLIMITEDSTACK.
"Created: / 01-08-2006 / 14:17:07 / cg"
!
@@ -790,7 +790,7 @@
isVirtualCPP
"is this a virtual c++-function (same as isCallTypeOLE) ?"
- ^ (flags ? 0) bitTest: FLAG_VIRTUAL.
+ ^ flags bitTest: FLAG_VIRTUAL.
"Created: / 01-08-2006 / 13:56:54 / cg"
!
@@ -800,10 +800,10 @@
!
mustFreeReturnValue
- "specify that a pointer to some C-datum is returned, which must be freed by ST/X.
+ "answer true, if a pointer to some C-datum is returned, which must be freed by ST/X.
(i.e. points to malloc'd data which is NOT freed by c)"
- flags := (flags ? 0) bitOr: FLAG_RETVAL_MUST_FREE.
+ ^ flags bitTest: FLAG_RETVAL_MUST_FREE.
"Created: / 12-02-2017 / 23:31:27 / cg"
!
@@ -919,7 +919,7 @@
self isCallTypeC ifTrue:[
'C:' printOn:aStream.
] ifFalse:[
- self error.
+ aStream nextPutAll:'Error: unknown call type '.
].
].
].
@@ -1109,9 +1109,10 @@
!ExternalLibraryFunction methodsFor:'private-accessing'!
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes
+ flags := 0.
name := functionNameOrVirtualIndex.
functionNameOrVirtualIndex isNumber ifTrue:[
- self beVirtualCPP.
+ self beVirtualCPP.
].
moduleName := aModuleName.
returnType := aReturnType.
@@ -2685,13 +2686,13 @@
returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
} else if (returnTypeSymbol == @symbol(charPointer)) {
returnValue = __MKSTRING(__returnValue.pointerVal);
- if (mustFreeRetVal) {
+ if (mustFreeRetVal == true) {
free(__returnValue.pointerVal);
alreadyFreed = true;
}
} else if (returnTypeSymbol == @symbol(wcharPointer)) {
returnValue = __MKU16STRING(__returnValue.pointerVal);
- if (mustFreeRetVal) {
+ if (mustFreeRetVal == true) {
free(__returnValue.pointerVal);
alreadyFreed = true;
}