--- a/ExternalLibraryFunction.st Sun Apr 03 13:48:15 2016 +0200
+++ b/ExternalLibraryFunction.st Sun Apr 03 19:16:08 2016 +0200
@@ -62,6 +62,10 @@
extern ffi_type *__get_ffi_type_double();
extern ffi_type *__get_ffi_type_void();
extern ffi_type *__get_ffi_type_pointer();
+ extern INTFUNC __get_ffi_prep_cif();
+ extern INTFUNC __get_ffi_call();
+# define ffi_prep_cif (*(__get_ffi_prep_cif()))
+# define ffi_call (*(__get_ffi_call()))
# endif
#endif
@@ -199,9 +203,9 @@
oldPath := self dllPath.
(oldPath includes:aDirectoryPathName) ifFalse:[
- newPath := oldPath asOrderedCollection.
- newPath add:aDirectoryPathName.
- self dllPath:newPath
+ newPath := oldPath asOrderedCollection.
+ newPath add:aDirectoryPathName.
+ self dllPath:newPath
]
!
@@ -330,9 +334,9 @@
ffiTypeSymbolForType:aType
"map type to one of the ffi-supported ones:
- sint8, sint16, sint32, sint64
- uint8, uint16, uint32, uint64
- bool void pointer handle
+ sint8, sint16, sint32, sint64
+ uint8, uint16, uint32, uint64
+ bool void pointer handle
"
aType == #sint8 ifTrue:[^ aType ].
@@ -401,24 +405,24 @@
aType == #BYTE ifTrue:[^ #uint8 ].
aType == #DWORD ifTrue:[^ #uint32 ].
aType == #HANDLE ifTrue:[^ #pointer ].
- aType == #HRESULT ifTrue:[^ #hresult ].
+ aType == #HRESULT ifTrue:[^ #hresult ].
"/ care for 64bit machines
aType == #SIZE_T ifTrue:[^ ExternalAddress pointerSize == 8 ifTrue:[#uint64] ifFalse:[#uint32]].
aType == #BSTR ifTrue:[^ #wcharPointer].
(aType isString or:[aType isSymbol]) ifFalse:[
- CType isNil ifTrue:[
- self error:'unknown type'.
- ].
- ^ aType typeSymbol.
+ CType isNil ifTrue:[
+ self error:'unknown type'.
+ ].
+ ^ aType typeSymbol.
].
(aType endsWith:'*') ifTrue:[
- ^ #pointer.
+ ^ #pointer.
].
(aType endsWith:'Pointer') ifTrue:[
- ^ #pointer.
+ ^ #pointer.
].
^ aType
@@ -765,7 +769,7 @@
Also, this deals with pointer size differences."
argumentTypes notEmptyOrNil ifTrue:[
- argumentTypes := argumentTypes collect:[:argType | self class ffiTypeSymbolForType:argType].
+ argumentTypes := argumentTypes collect:[:argType | self class ffiTypeSymbolForType:argType].
].
returnType := self class ffiTypeSymbolForType:returnType.
!
@@ -777,43 +781,43 @@
|handle moduleNameUsed functionName|
name isNumber ifTrue:[
- self isCPPFunction ifTrue:[
- "/ no need to load a dll.
- ^ self
- ]
+ self isCPPFunction ifTrue:[
+ "/ no need to load a dll.
+ ^ self
+ ]
].
"/ in some other smalltalks, there is no moduleName in the ffi-spec;
"/ instead, the class provides the libraryName...
(moduleNameUsed := moduleName) isNil ifTrue:[
- owningClass isNil ifTrue:[
- self error:'Missing moduleName'.
- ].
- moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
+ owningClass isNil ifTrue:[
+ self error:'Missing moduleName'.
+ ].
+ moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol.
].
moduleHandle isNil ifTrue:[
- "/ speedup. in 95% of all calls, the same moduleName is resolved here
- (LastModuleHandleHolder isNil
- or:[ (handle := LastModuleHandleHolder at:1) isNil
- or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[
+ "/ speedup. in 95% of all calls, the same moduleName is resolved here
+ (LastModuleHandleHolder isNil
+ or:[ (handle := LastModuleHandleHolder at:1) isNil
+ or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[
- handle := self loadLibrary:moduleNameUsed.
- handle isNil ifTrue:[
- self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
- ].
- LastModuleHandleHolder := WeakArray with:handle.
- LastModuleHandleName := moduleNameUsed.
- ].
- moduleHandle := handle.
+ handle := self loadLibrary:moduleNameUsed.
+ handle isNil ifTrue:[
+ self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed).
+ ].
+ LastModuleHandleHolder := WeakArray with:handle.
+ LastModuleHandleName := moduleNameUsed.
+ ].
+ moduleHandle := handle.
].
name isNumber ifFalse:[
- functionName := name.
- (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
- (moduleHandle getFunctionAddress:('_', functionName) into:self) isNil ifTrue:[
- moduleHandle := nil.
- self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
- ].
- ].
+ functionName := name.
+ (moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[
+ (moduleHandle getFunctionAddress:('_', functionName) into:self) isNil ifTrue:[
+ moduleHandle := nil.
+ self error:'Missing function: ', name, ' in module: ', moduleNameUsed.
+ ].
+ ].
].
"Modified: / 10-04-2012 / 12:12:44 / cg"
@@ -829,7 +833,7 @@
filename := dllName.
DllMapping notNil ifTrue:[
- filename := DllMapping at:filename ifAbsent:[ filename ]
+ filename := DllMapping at:filename ifAbsent:[ filename ]
].
filename := filename asFilename.
@@ -840,25 +844,25 @@
handle notNil ifTrue:[^ handle ].
filename isAbsolute ifFalse:[
- "First ask the class defining the ExternalFunction for the location of the dlls ..."
- owningClass notNil ifTrue:[
- owningClass dllPath do:[:eachDirectory |
- handle := ObjectFileLoader
- loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
- handle notNil ifTrue:[^ handle ].
- ].
- ].
- ".. then ask the system"
- self class dllPath do:[:eachDirectory |
- handle := ObjectFileLoader
- loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
- handle notNil ifTrue:[^ handle ].
- ].
+ "First ask the class defining the ExternalFunction for the location of the dlls ..."
+ owningClass notNil ifTrue:[
+ owningClass dllPath do:[:eachDirectory |
+ handle := ObjectFileLoader
+ loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
+ handle notNil ifTrue:[^ handle ].
+ ].
+ ].
+ ".. then ask the system"
+ self class dllPath do:[:eachDirectory |
+ handle := ObjectFileLoader
+ loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
+ handle notNil ifTrue:[^ handle ].
+ ].
].
filename suffix isEmpty ifTrue:[
- "/ try again with the OS-specific dll-extension
- ^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
+ "/ try again with the OS-specific dll-extension
+ ^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
].
^ nil
@@ -868,12 +872,12 @@
prepareInvoke
"called before invoked.
- When called the very first time, moduleHandle is nil,
+ When called the very first time, moduleHandle is nil,
and we ensure that the dll is loaded, the function address is extracted"
(moduleHandle isNil or:[self hasCode not]) ifTrue:[
- self linkToModule.
- self adjustTypes.
+ self linkToModule.
+ self adjustTypes.
].
! !
@@ -941,36 +945,36 @@
virtual := self isVirtualCPP.
objectiveC := self isObjectiveC.
(virtual "or:[self isNonVirtualCPP]") ifTrue:[
- aReceiverOrNil isNil ifTrue:[
- "/ must have a c++ object instance
- self primitiveFailed.
- ].
+ aReceiverOrNil isNil ifTrue:[
+ "/ must have a c++ object instance
+ self primitiveFailed.
+ ].
- "/ and it must be a kind of ExternalStructure !!
- (aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
- self primitiveFailed.
- ].
- virtual ifTrue:[
- vtOffset := name.
- (vtOffset between:0 and:10000) ifFalse:[
- self primitiveFailed.
- ]
- ].
+ "/ and it must be a kind of ExternalStructure !!
+ (aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[
+ self primitiveFailed.
+ ].
+ virtual ifTrue:[
+ vtOffset := name.
+ (vtOffset between:0 and:10000) ifFalse:[
+ self primitiveFailed.
+ ]
+ ].
] ifFalse:[
- objectiveC ifTrue:[
- aReceiverOrNil isNil ifTrue:[
- "/ must have an objective-c object instance
- self primitiveFailed.
- ].
- (aReceiverOrNil isObjectiveCObject) ifFalse:[
- self primitiveFailed
- ]
- ] ifFalse:[
- aReceiverOrNil notNil ifTrue:[
- "/ must NOT have a c++/objectiveC object instance
- self primitiveFailed.
- ]
- ].
+ objectiveC ifTrue:[
+ aReceiverOrNil isNil ifTrue:[
+ "/ must have an objective-c object instance
+ self primitiveFailed.
+ ].
+ (aReceiverOrNil isObjectiveCObject) ifFalse:[
+ self primitiveFailed
+ ]
+ ] ifFalse:[
+ aReceiverOrNil notNil ifTrue:[
+ "/ must NOT have a c++/objectiveC object instance
+ self primitiveFailed.
+ ]
+ ].
].
async := self isAsync.
unlimitedStack := self isUnlimitedStack.
@@ -999,14 +1003,14 @@
ffi_type *__returnType = NULL;
union u {
- INT iVal;
- float fVal;
- double dVal;
- void *pointerVal;
+ INT iVal;
+ float fVal;
+ double dVal;
+ void *pointerVal;
# if 0 && defined(HAS_LONGLONG)
- long long longLongVal;
+ long long longLongVal;
# else
- __int64__ longLongVal;
+ __int64__ longLongVal;
# endif
};
union u __argValuesIncludingThis[MAX_ARGS+1];
@@ -1024,29 +1028,29 @@
# define __FAIL__(fcode) \
{ \
- failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \
+ failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \
}
if (argumentsOrNil == nil) {
- __numArgs = 0;
+ __numArgs = 0;
} else if (__isArray(argumentsOrNil)) {
- __numArgs = __arraySize(argumentsOrNil);
+ __numArgs = __arraySize(argumentsOrNil);
} else {
- __FAIL__(@symbol(BadArgumentVector))
+ __FAIL__(@symbol(BadArgumentVector))
}
if (argTypeSymbols == nil) {
- __numArgsWanted = 0;
+ __numArgsWanted = 0;
} else if (__isArray(argTypeSymbols)) {
- __numArgsWanted = __arraySize(argTypeSymbols);
+ __numArgsWanted = __arraySize(argTypeSymbols);
} else {
- __FAIL__(@symbol(BadArgumentTypeVector))
+ __FAIL__(@symbol(BadArgumentTypeVector))
}
if (__numArgs != __numArgsWanted) {
- __FAIL__(@symbol(ArgumentCountMismatch))
+ __FAIL__(@symbol(ArgumentCountMismatch))
}
if (__numArgs > MAX_ARGS) {
- __FAIL__(@symbol(TooManyArguments))
+ __FAIL__(@symbol(TooManyArguments))
}
/*
@@ -1055,136 +1059,136 @@
__returnValuePointer = &__returnValue;
if (returnTypeSymbol == @symbol(voidPointer)) {
- returnTypeSymbol = @symbol(handle);
+ returnTypeSymbol = @symbol(handle);
} else if (returnTypeSymbol == @symbol(hresult)) {
- returnTypeSymbol = @symbol(uint32);
+ returnTypeSymbol = @symbol(uint32);
}
if (returnTypeSymbol == @symbol(int)) {
- __returnType = __get_ffi_type_sint();
+ __returnType = __get_ffi_type_sint();
} else if (returnTypeSymbol == @symbol(uint)) {
- __returnType = __get_ffi_type_uint();
+ __returnType = __get_ffi_type_uint();
} else if (returnTypeSymbol == @symbol(uint8)) {
- __returnType = __get_ffi_type_uint8();
+ __returnType = __get_ffi_type_uint8();
} else if (returnTypeSymbol == @symbol(uint16)) {
- __returnType = __get_ffi_type_uint16();
+ __returnType = __get_ffi_type_uint16();
} else if (returnTypeSymbol == @symbol(uint32)) {
- __returnType = __get_ffi_type_uint32();
+ __returnType = __get_ffi_type_uint32();
} else if (returnTypeSymbol == @symbol(uint64)) {
- __returnType = __get_ffi_type_uint64();
+ __returnType = __get_ffi_type_uint64();
} else if (returnTypeSymbol == @symbol(sint)) {
- __returnType = __get_ffi_type_sint();
+ __returnType = __get_ffi_type_sint();
} else if (returnTypeSymbol == @symbol(sint8)) {
- __returnType = __get_ffi_type_sint8();
+ __returnType = __get_ffi_type_sint8();
} else if (returnTypeSymbol == @symbol(sint16)) {
- __returnType = __get_ffi_type_sint16();
+ __returnType = __get_ffi_type_sint16();
} else if (returnTypeSymbol == @symbol(sint32)) {
- __returnType = __get_ffi_type_sint32();
+ __returnType = __get_ffi_type_sint32();
} else if (returnTypeSymbol == @symbol(sint64)) {
- __returnType = __get_ffi_type_sint64();
+ __returnType = __get_ffi_type_sint64();
} else if (returnTypeSymbol == @symbol(long)) {
- if (sizeof(long) == 4) {
- returnTypeSymbol = @symbol(sint32);
- __returnType = __get_ffi_type_sint32();
- } else if (sizeof(long) == 8) {
- returnTypeSymbol = @symbol(sint64);
- __returnType = __get_ffi_type_sint64();
- } else {
- __FAIL__(@symbol(UnknownReturnType))
- }
+ if (sizeof(long) == 4) {
+ returnTypeSymbol = @symbol(sint32);
+ __returnType = __get_ffi_type_sint32();
+ } else if (sizeof(long) == 8) {
+ returnTypeSymbol = @symbol(sint64);
+ __returnType = __get_ffi_type_sint64();
+ } else {
+ __FAIL__(@symbol(UnknownReturnType))
+ }
} else if (returnTypeSymbol == @symbol(ulong)) {
- if (sizeof(long) == 4) {
- returnTypeSymbol = @symbol(uint32);
- __returnType = __get_ffi_type_uint32();
- }else if (sizeof(long) == 8) {
- returnTypeSymbol = @symbol(uint64);
- __returnType = __get_ffi_type_uint64();
- } else {
- __FAIL__(@symbol(UnknownReturnType))
- }
+ if (sizeof(long) == 4) {
+ returnTypeSymbol = @symbol(uint32);
+ __returnType = __get_ffi_type_uint32();
+ }else if (sizeof(long) == 8) {
+ returnTypeSymbol = @symbol(uint64);
+ __returnType = __get_ffi_type_uint64();
+ } else {
+ __FAIL__(@symbol(UnknownReturnType))
+ }
} else if (returnTypeSymbol == @symbol(bool)) {
- __returnType = __get_ffi_type_uint();
+ __returnType = __get_ffi_type_uint();
} else if (returnTypeSymbol == @symbol(float)) {
- __returnType = __get_ffi_type_float();
+ __returnType = __get_ffi_type_float();
} else if (returnTypeSymbol == @symbol(double)) {
- __returnType = __get_ffi_type_double();
+ __returnType = __get_ffi_type_double();
} else if (returnTypeSymbol == @symbol(void)) {
- __returnType = __get_ffi_type_void();
- __returnValuePointer = NULL;
+ __returnType = __get_ffi_type_void();
+ __returnValuePointer = NULL;
} else if ((returnTypeSymbol == @symbol(pointer))
- || (returnTypeSymbol == @symbol(handle))
- || (returnTypeSymbol == @symbol(charPointer))
- || (returnTypeSymbol == @symbol(bytePointer))
- || (returnTypeSymbol == @symbol(floatPointer))
- || (returnTypeSymbol == @symbol(doublePointer))
- || (returnTypeSymbol == @symbol(intPointer))
- || (returnTypeSymbol == @symbol(shortPointer))
- || (returnTypeSymbol == @symbol(wcharPointer))) {
- __returnType = __get_ffi_type_pointer();
+ || (returnTypeSymbol == @symbol(handle))
+ || (returnTypeSymbol == @symbol(charPointer))
+ || (returnTypeSymbol == @symbol(bytePointer))
+ || (returnTypeSymbol == @symbol(floatPointer))
+ || (returnTypeSymbol == @symbol(doublePointer))
+ || (returnTypeSymbol == @symbol(intPointer))
+ || (returnTypeSymbol == @symbol(shortPointer))
+ || (returnTypeSymbol == @symbol(wcharPointer))) {
+ __returnType = __get_ffi_type_pointer();
} else {
- if (__isSymbol(returnTypeSymbol)
- && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
- if (! __isBehaviorLike(returnValueClass)) {
- __FAIL__(@symbol(NonBehaviorReturnType))
- }
- if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
- __FAIL__(@symbol(NonExternalAddressReturnType))
- }
- __returnType = __get_ffi_type_pointer();
- returnTypeSymbol = @symbol(pointer);
- } else {
- __FAIL__(@symbol(UnknownReturnType))
- }
+ if (__isSymbol(returnTypeSymbol)
+ && ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) {
+ if (! __isBehaviorLike(returnValueClass)) {
+ __FAIL__(@symbol(NonBehaviorReturnType))
+ }
+ if (! __qIsSubclassOfExternalAddress(returnValueClass)) {
+ __FAIL__(@symbol(NonExternalAddressReturnType))
+ }
+ __returnType = __get_ffi_type_pointer();
+ returnTypeSymbol = @symbol(pointer);
+ } else {
+ __FAIL__(@symbol(UnknownReturnType))
+ }
}
/*
* validate the c++ object
*/
if (aReceiverOrNil != nil) {
- struct cPlusPlusInstance {
- void **vTable;
- };
- struct cPlusPlusInstance *inst;
+ struct cPlusPlusInstance {
+ void **vTable;
+ };
+ struct cPlusPlusInstance *inst;
- if (__isExternalAddressLike(aReceiverOrNil)) {
- inst = (void *)(__externalAddressVal(aReceiverOrNil));
- } else if (__isExternalBytesLike(aReceiverOrNil)) {
- inst = (void *)(__externalBytesVal(aReceiverOrNil));
- } else {
- __FAIL__(@symbol(InvalidInstance))
- }
- __argValues[0].pointerVal = inst;
- __argValuePointersIncludingThis[0] = &(__argValues[0]);
- __argTypes[0] = __get_ffi_type_pointer();
+ if (__isExternalAddressLike(aReceiverOrNil)) {
+ inst = (void *)(__externalAddressVal(aReceiverOrNil));
+ } else if (__isExternalBytesLike(aReceiverOrNil)) {
+ inst = (void *)(__externalBytesVal(aReceiverOrNil));
+ } else {
+ __FAIL__(@symbol(InvalidInstance))
+ }
+ __argValues[0].pointerVal = inst;
+ __argValuePointersIncludingThis[0] = &(__argValues[0]);
+ __argTypes[0] = __get_ffi_type_pointer();
- __argValuePointers = &__argValuePointersIncludingThis[1];
- __argTypes = &__argTypesIncludingThis[1];
- __argValues = &__argValuesIncludingThis[1];
- __numArgsIncludingThis = __numArgs + 1;
+ __argValuePointers = &__argValuePointersIncludingThis[1];
+ __argTypes = &__argTypesIncludingThis[1];
+ __argValues = &__argValuesIncludingThis[1];
+ __numArgsIncludingThis = __numArgs + 1;
- if (virtual == true) {
- if (! __isSmallInteger(vtOffset)) {
- __FAIL__(@symbol(InvalidVTableIndex))
- }
- codeAddress = inst->vTable[__intVal(vtOffset)];
+ if (virtual == true) {
+ if (! __isSmallInteger(vtOffset)) {
+ __FAIL__(@symbol(InvalidVTableIndex))
+ }
+ codeAddress = inst->vTable[__intVal(vtOffset)];
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("virtual %d codeAddress: %"_lx_"\n", __intVal(vtOffset), (INT)codeAddress);
- }
+ if (@global(Verbose) == true) {
+ printf("virtual %d codeAddress: %"_lx_"\n", __intVal(vtOffset), (INT)codeAddress);
+ }
# endif
- }
+ }
} else {
- __numArgsIncludingThis = __numArgs;
+ __numArgsIncludingThis = __numArgs;
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("codeAddress: %"_lx_"\n", (INT)codeAddress);
- }
+ if (@global(Verbose) == true) {
+ printf("codeAddress: %"_lx_"\n", (INT)codeAddress);
+ }
# endif
}
@@ -1192,514 +1196,514 @@
* validate all arg types, map each to an ffi_type, and setup arg-buffers
*/
for (i=0; i<__numArgs; i++) {
- ffi_type *thisType;
- void *argValuePtr;
- OBJ typeSymbol;
- OBJ arg;
+ ffi_type *thisType;
+ void *argValuePtr;
+ OBJ typeSymbol;
+ OBJ arg;
- failureInfo = __mkSmallInteger(i+1); /* in case there is one */
+ failureInfo = __mkSmallInteger(i+1); /* in case there is one */
- typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
- arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
+ typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i];
+ arg = __ArrayInstPtr(argumentsOrNil)->a_element[i];
- if (typeSymbol == @symbol(handle)) {
- typeSymbol = @symbol(pointer);
- } else if (typeSymbol == @symbol(voidPointer)) {
- typeSymbol = @symbol(pointer);
- } else if (returnTypeSymbol == @symbol(hresult)) {
- typeSymbol = @symbol(uint32);
- }
+ if (typeSymbol == @symbol(handle)) {
+ typeSymbol = @symbol(pointer);
+ } else if (typeSymbol == @symbol(voidPointer)) {
+ typeSymbol = @symbol(pointer);
+ } else if (returnTypeSymbol == @symbol(hresult)) {
+ typeSymbol = @symbol(uint32);
+ }
- if (typeSymbol == @symbol(long)) {
- if (sizeof(long) == sizeof(int)) {
- typeSymbol = @symbol(sint);
- } else {
- if (sizeof(long) == 4) {
- typeSymbol = @symbol(sint32);
- } else if (sizeof(long) == 8) {
- typeSymbol = @symbol(sint64);
- }
- }
- }
- if (typeSymbol == @symbol(ulong)) {
- if (sizeof(unsigned long) == sizeof(unsigned int)) {
- typeSymbol = @symbol(uint);
- } else {
- if (sizeof(long) == 4) {
- typeSymbol = @symbol(uint32);
- } else if (sizeof(long) == 8) {
- typeSymbol = @symbol(uint64);
- }
- }
- }
+ if (typeSymbol == @symbol(long)) {
+ if (sizeof(long) == sizeof(int)) {
+ typeSymbol = @symbol(sint);
+ } else {
+ if (sizeof(long) == 4) {
+ typeSymbol = @symbol(sint32);
+ } else if (sizeof(long) == 8) {
+ typeSymbol = @symbol(sint64);
+ }
+ }
+ }
+ if (typeSymbol == @symbol(ulong)) {
+ if (sizeof(unsigned long) == sizeof(unsigned int)) {
+ typeSymbol = @symbol(uint);
+ } else {
+ if (sizeof(long) == 4) {
+ typeSymbol = @symbol(uint32);
+ } else if (sizeof(long) == 8) {
+ typeSymbol = @symbol(uint64);
+ }
+ }
+ }
- if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
- thisType = __get_ffi_type_sint();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __signedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) {
+ thisType = __get_ffi_type_sint();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __signedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(uint)) {
- thisType = __get_ffi_type_uint();
+ } else if (typeSymbol == @symbol(uint)) {
+ thisType = __get_ffi_type_uint();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __unsignedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __unsignedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(uint8)) {
- thisType = __get_ffi_type_uint8();
- if (! __isSmallInteger(arg)) {
+ } else if (typeSymbol == @symbol(uint8)) {
+ thisType = __get_ffi_type_uint8();
+ if (! __isSmallInteger(arg)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- __argValues[i].iVal = __intVal(arg);
- if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ __argValues[i].iVal = __intVal(arg);
+ if (((unsigned)(__argValues[i].iVal)) > 0xFF) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(sint8)) {
- thisType = __get_ffi_type_sint8();
- if (! __isSmallInteger(arg)) {
+ } else if (typeSymbol == @symbol(sint8)) {
+ thisType = __get_ffi_type_sint8();
+ if (! __isSmallInteger(arg)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- __argValues[i].iVal = __intVal(arg);
- if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F)) {
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ __argValues[i].iVal = __intVal(arg);
+ if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(uint16)) {
- thisType = __get_ffi_type_uint16();
- if (! __isSmallInteger(arg)) {
+ } else if (typeSymbol == @symbol(uint16)) {
+ thisType = __get_ffi_type_uint16();
+ if (! __isSmallInteger(arg)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- __argValues[i].iVal = __intVal(arg);
- if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ __argValues[i].iVal = __intVal(arg);
+ if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(sint16)) {
- thisType = __get_ffi_type_sint16();
- if (! __isSmallInteger(arg)) {
+ } else if (typeSymbol == @symbol(sint16)) {
+ thisType = __get_ffi_type_sint16();
+ if (! __isSmallInteger(arg)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- __argValues[i].iVal = __intVal(arg);
- if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF)) {
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ __argValues[i].iVal = __intVal(arg);
+ if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(uint32)) {
- thisType = __get_ffi_type_uint32();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __unsignedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ } else if (typeSymbol == @symbol(uint32)) {
+ thisType = __get_ffi_type_uint32();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __unsignedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
# if __POINTER_SIZE__ == 8
- if ((__argValues[i].iVal) < 0) {
+ if ((__argValues[i].iVal) < 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
+ __FAIL__(@symbol(InvalidArgument))
+ }
# endif
- argValuePtr = &(__argValues[i].iVal);
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(sint32)) {
- thisType = __get_ffi_type_uint32();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __signedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ } else if (typeSymbol == @symbol(sint32)) {
+ thisType = __get_ffi_type_uint32();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __signedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
# if __POINTER_SIZE__ == 8
- if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL)) {
+ if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL)) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
+ __FAIL__(@symbol(InvalidArgument))
+ }
# endif
- argValuePtr = &(__argValues[i].iVal);
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(uint64)) {
- thisType = __get_ffi_type_uint64();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __unsignedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ } else if (typeSymbol == @symbol(uint64)) {
+ thisType = __get_ffi_type_uint64();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __unsignedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(sint64)) {
- thisType = __get_ffi_type_sint64();
- if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __signedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ } else if (typeSymbol == @symbol(sint64)) {
+ thisType = __get_ffi_type_sint64();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __signedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].iVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].iVal);
- } else if (typeSymbol == @symbol(float)) {
- thisType = __get_ffi_type_float();
- if (__isSmallInteger(arg)) {
- __argValues[i].fVal = (float)(__intVal(arg));
- } else if (__isFloat(arg)) {
- __argValues[i].fVal = (float)(__floatVal(arg));
- } else if (__isShortFloat(arg)) {
- __argValues[i].fVal = (float)(__shortFloatVal(arg));
- } else {
+ } else if (typeSymbol == @symbol(float)) {
+ thisType = __get_ffi_type_float();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].fVal = (float)(__intVal(arg));
+ } else if (__isFloat(arg)) {
+ __argValues[i].fVal = (float)(__floatVal(arg));
+ } else if (__isShortFloat(arg)) {
+ __argValues[i].fVal = (float)(__shortFloatVal(arg));
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].fVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].fVal);
- } else if (typeSymbol == @symbol(double)) {
- thisType = __get_ffi_type_double();
- if (__isSmallInteger(arg)) {
- __argValues[i].dVal = (double)(__intVal(arg));
- } else if (__isFloat(arg)) {
- __argValues[i].dVal = (double)(__floatVal(arg));
- } else if (__isShortFloat(arg)) {
- __argValues[i].dVal = (double)(__shortFloatVal(arg));
- } else {
+ } else if (typeSymbol == @symbol(double)) {
+ thisType = __get_ffi_type_double();
+ if (__isSmallInteger(arg)) {
+ __argValues[i].dVal = (double)(__intVal(arg));
+ } else if (__isFloat(arg)) {
+ __argValues[i].dVal = (double)(__floatVal(arg));
+ } else if (__isShortFloat(arg)) {
+ __argValues[i].dVal = (double)(__shortFloatVal(arg));
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].dVal);
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].dVal);
- } else if (typeSymbol == @symbol(void)) {
- thisType = __get_ffi_type_void();
- argValuePtr = &null;
+ } else if (typeSymbol == @symbol(void)) {
+ thisType = __get_ffi_type_void();
+ argValuePtr = &null;
- } else if (typeSymbol == @symbol(charPointer)) {
- thisType = __get_ffi_type_pointer();
- if (__isStringLike(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__stringVal(arg));
- } else if (__isBytes(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
- } else if (__isExternalAddressLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
- } else if (__isExternalBytesLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
- } else {
- if (arg == nil) {
- __argValues[i].pointerVal = (void *)0;
- } else {
+ } else if (typeSymbol == @symbol(charPointer)) {
+ thisType = __get_ffi_type_pointer();
+ if (__isStringLike(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__stringVal(arg));
+ } else if (__isBytes(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+ } else if (__isExternalAddressLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+ } else if (__isExternalBytesLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+ } else {
+ if (arg == nil) {
+ __argValues[i].pointerVal = (void *)0;
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].pointerVal);;
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].pointerVal);;
- } else if (typeSymbol == @symbol(wcharPointer)) {
- thisType = __get_ffi_type_pointer();
- if (__isUnicode16String(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
- } else if (__isBytes(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
- } else if (__isExternalAddressLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
- } else if (__isExternalBytesLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
- } else {
- if (arg == nil) {
- __argValues[i].pointerVal = (void *)0;
- } else {
+ } else if (typeSymbol == @symbol(wcharPointer)) {
+ thisType = __get_ffi_type_pointer();
+ if (__isUnicode16String(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__unicode16StringVal(arg));
+ } else if (__isBytes(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+ } else if (__isExternalAddressLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+ } else if (__isExternalBytesLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+ } else {
+ if (arg == nil) {
+ __argValues[i].pointerVal = (void *)0;
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].pointerVal);;
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].pointerVal);;
- } else if (typeSymbol == @symbol(floatPointer)) {
- thisType = __get_ffi_type_pointer();
- if (__isBytes(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
- } else if (__isExternalAddressLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
- } else if (__isExternalBytesLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
- } else if (__isFloats(arg)) {
- char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
- int nInstBytes;
- OBJ cls;
+ } else if (typeSymbol == @symbol(floatPointer)) {
+ thisType = __get_ffi_type_pointer();
+ if (__isBytes(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+ } else if (__isExternalAddressLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+ } else if (__isExternalBytesLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+ } else if (__isFloats(arg)) {
+ char *p = (char *)(__FloatArrayInstPtr(arg)->f_element);
+ int nInstBytes;
+ OBJ cls;
- if (async == true) goto badArgForAsyncCall;
- cls = __qClass(arg);
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- p = p + nInstBytes;
- __argValues[i].pointerVal = p;
- } else {
- if (arg == nil) {
- __argValues[i].pointerVal = (void *)0;
- } else {
+ if (async == true) goto badArgForAsyncCall;
+ cls = __qClass(arg);
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ p = p + nInstBytes;
+ __argValues[i].pointerVal = p;
+ } else {
+ if (arg == nil) {
+ __argValues[i].pointerVal = (void *)0;
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].pointerVal);;
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].pointerVal);;
- } else if (typeSymbol == @symbol(doublePointer)) {
- thisType = __get_ffi_type_pointer();
- if (__isBytes(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
- } else if (__isExternalAddressLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
- } else if (__isExternalBytesLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
- } else if (__isDoubles(arg)) {
- char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
- int nInstBytes;
- OBJ cls;
+ } else if (typeSymbol == @symbol(doublePointer)) {
+ thisType = __get_ffi_type_pointer();
+ if (__isBytes(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+ } else if (__isExternalAddressLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+ } else if (__isExternalBytesLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+ } else if (__isDoubles(arg)) {
+ char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element);
+ int nInstBytes;
+ OBJ cls;
- if (async == true) goto badArgForAsyncCall;
- cls = __qClass(arg);
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- p = p + nInstBytes;
+ if (async == true) goto badArgForAsyncCall;
+ cls = __qClass(arg);
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ p = p + nInstBytes;
# ifdef __NEED_DOUBLE_ALIGN
- if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
- int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
+ if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) {
+ int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1));
- p += delta;
- }
+ p += delta;
+ }
# endif
- __argValues[i].pointerVal = p;
- } else {
- if (arg == nil) {
- __argValues[i].pointerVal = (void *)0;
- } else {
+ __argValues[i].pointerVal = p;
+ } else {
+ if (arg == nil) {
+ __argValues[i].pointerVal = (void *)0;
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].pointerVal);;
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].pointerVal);;
- } else if (typeSymbol == @symbol(pointer)) {
+ } else if (typeSymbol == @symbol(pointer)) {
commonPointerTypeArg: ;
- thisType = __get_ffi_type_pointer();
- if (arg == nil) {
- __argValues[i].pointerVal = NULL;
- } else if (__isExternalAddressLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
- } else if (__isExternalBytesLike(arg)) {
- __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
- } else if (__isByteArrayLike(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
- } else if (__isWordArray(arg) || __isSignedWordArray(arg)
- || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
- } else if (__isFloatArray(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
- } else if (__isDoubleArray(arg)) {
- if (async == true) goto badArgForAsyncCall;
- __argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
- } else if (__isStringLike(arg)) {
- if (async == true) {
+ thisType = __get_ffi_type_pointer();
+ if (arg == nil) {
+ __argValues[i].pointerVal = NULL;
+ } else if (__isExternalAddressLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalAddressVal(arg));
+ } else if (__isExternalBytesLike(arg)) {
+ __argValues[i].pointerVal = (void *)(__externalBytesVal(arg));
+ } else if (__isByteArrayLike(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__byteArrayVal(arg));
+ } else if (__isWordArray(arg) || __isSignedWordArray(arg)
+ || __isIntegerArray(arg) || __isSignedIntegerArray(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__integerArrayVal(arg));
+ } else if (__isFloatArray(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element);
+ } else if (__isDoubleArray(arg)) {
+ if (async == true) goto badArgForAsyncCall;
+ __argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element);
+ } else if (__isStringLike(arg)) {
+ if (async == true) {
badArgForAsyncCall: ;
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(BadArgForAsyncCall))
- }
- __argValues[i].pointerVal = (void *)(__stringVal(arg));
- } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
- char *p = (char *)(__byteArrayVal(arg));
- int nInstBytes;
- OBJ cls;
+ __FAIL__(@symbol(BadArgForAsyncCall))
+ }
+ __argValues[i].pointerVal = (void *)(__stringVal(arg));
+ } else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) {
+ char *p = (char *)(__byteArrayVal(arg));
+ int nInstBytes;
+ OBJ cls;
- if (async == true) goto badArgForAsyncCall;
- cls = __qClass(arg);
- nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- __argValues[i].pointerVal = p + nInstBytes;
- } else {
+ if (async == true) goto badArgForAsyncCall;
+ cls = __qClass(arg);
+ nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ __argValues[i].pointerVal = p + nInstBytes;
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- argValuePtr = &(__argValues[i].pointerVal);;
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ argValuePtr = &(__argValues[i].pointerVal);;
- } else if (typeSymbol == @symbol(bool)) {
- thisType = __get_ffi_type_uint();
+ } else if (typeSymbol == @symbol(bool)) {
+ thisType = __get_ffi_type_uint();
- if (arg == true) {
- __argValues[i].iVal = 1;
- } else if (arg == false) {
- __argValues[i].iVal = 0;
- } else if (__isSmallInteger(arg)) {
- __argValues[i].iVal = __intVal(arg);
- } else {
- __argValues[i].iVal = __unsignedLongIntVal(arg);
- if (__argValues[i].iVal == 0) {
+ if (arg == true) {
+ __argValues[i].iVal = 1;
+ } else if (arg == false) {
+ __argValues[i].iVal = 0;
+ } else if (__isSmallInteger(arg)) {
+ __argValues[i].iVal = __intVal(arg);
+ } else {
+ __argValues[i].iVal = __unsignedLongIntVal(arg);
+ if (__argValues[i].iVal == 0) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__);
- }
+ if (@global(Verbose) == true) {
+ printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__);
+ }
# endif
- __FAIL__(@symbol(InvalidArgument))
- }
- }
- argValuePtr = &(__argValues[i].iVal);
- } else {
- if (__isSymbol(typeSymbol)
- && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
- if (! __isBehaviorLike(argValueClass)) {
- __FAIL__(@symbol(NonBehaviorArgumentType))
- }
- if (! __qIsSubclassOfExternalAddress(argValueClass)) {
- __FAIL__(@symbol(NonExternalAddressArgumentType))
- }
- goto commonPointerTypeArg; /* sorry */
- } else {
- __FAIL__(@symbol(UnknownArgumentType))
- }
- }
+ __FAIL__(@symbol(InvalidArgument))
+ }
+ }
+ argValuePtr = &(__argValues[i].iVal);
+ } else {
+ if (__isSymbol(typeSymbol)
+ && ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) {
+ if (! __isBehaviorLike(argValueClass)) {
+ __FAIL__(@symbol(NonBehaviorArgumentType))
+ }
+ if (! __qIsSubclassOfExternalAddress(argValueClass)) {
+ __FAIL__(@symbol(NonExternalAddressArgumentType))
+ }
+ goto commonPointerTypeArg; /* sorry */
+ } else {
+ __FAIL__(@symbol(UnknownArgumentType))
+ }
+ }
- __argTypes[i] = thisType;
- __argValuePointers[i] = argValuePtr;
+ __argTypes[i] = thisType;
+ __argValuePointers[i] = argValuePtr;
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("arg%d: %"_lx_" type:%"_lx_"\n", i+1, (INT)(__argValues[i].iVal), (INT)thisType);
- }
+ if (@global(Verbose) == true) {
+ printf("arg%d: %"_lx_" type:%"_lx_"\n", i+1, (INT)(__argValues[i].iVal), (INT)thisType);
+ }
# endif
}
failureInfo = nil;
@@ -1708,66 +1712,66 @@
# ifdef CALLTYPE_FFI_STDCALL
if (callTypeNumber == @global(CALLTYPE_API)) {
- __callType = CALLTYPE_FFI_STDCALL;
+ __callType = CALLTYPE_FFI_STDCALL;
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("STDCALL\n");
- }
+ if (@global(Verbose) == true) {
+ printf("STDCALL\n");
+ }
# endif
}
# endif
# ifdef CALLTYPE_FFI_V8
if (callTypeNumber == @global(CALLTYPE_V8)) {
- __callType = CALLTYPE_FFI_V8;
+ __callType = CALLTYPE_FFI_V8;
}
# endif
# ifdef CALLTYPE_FFI_V9
if (callTypeNumber == @global(CALLTYPE_V9)) {
- __callType = CALLTYPE_FFI_V9;
+ __callType = CALLTYPE_FFI_V9;
}
# endif
# ifdef CALLTYPE_FFI_UNIX64
if (callTypeNumber == @global(CALLTYPE_UNIX64)) {
- __callType = CALLTYPE_FFI_UNIX64;
+ __callType = CALLTYPE_FFI_UNIX64;
}
# endif
if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) {
- __FAIL__(@symbol(FFIPrepareFailed))
+ __FAIL__(@symbol(FFIPrepareFailed))
}
if (async == true) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("async call 0x%"_lx_"\n", (INT)codeAddress);
- }
+ if (@global(Verbose) == true) {
+ printf("async call 0x%"_lx_"\n", (INT)codeAddress);
+ }
# endif
# ifdef WIN32
- __STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+ __STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
# else
- __BEGIN_INTERRUPTABLE__
- ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
- __END_INTERRUPTABLE__
+ __BEGIN_INTERRUPTABLE__
+ ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+ __END_INTERRUPTABLE__
# endif
} else {
- if (unlimitedStack == true) {
+ if (unlimitedStack == true) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress);
- }
+ if (@global(Verbose) == true) {
+ printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress);
+ }
# endif
- __UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis);
- } else {
+ __UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis);
+ } else {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("call 0x%"_lx_"\n", (INT)codeAddress);
- }
+ if (@global(Verbose) == true) {
+ printf("call 0x%"_lx_"\n", (INT)codeAddress);
+ }
# endif
- ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
- }
+ ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis);
+ }
}
# ifdef VERBOSE
if (@global(Verbose) == true) {
- printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal));
+ printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal));
}
# endif
@@ -1777,94 +1781,94 @@
|| (returnTypeSymbol == @symbol(sint16))
|| (returnTypeSymbol == @symbol(sint32))) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return int: %x\n", __returnValue.iVal);
- }
+ if (@global(Verbose) == true) {
+ printf("return int: %x\n", __returnValue.iVal);
+ }
# endif
- RETURN ( __MKINT(__returnValue.iVal) );
+ RETURN ( __MKINT(__returnValue.iVal) );
}
if ((returnTypeSymbol == @symbol(uint))
|| (returnTypeSymbol == @symbol(uint8))
|| (returnTypeSymbol == @symbol(uint16))
|| (returnTypeSymbol == @symbol(uint32))) {
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return uint: %x\n", __returnValue.iVal);
- }
+ if (@global(Verbose) == true) {
+ printf("return uint: %x\n", __returnValue.iVal);
+ }
# endif
- RETURN ( __MKUINT(__returnValue.iVal) );
+ RETURN ( __MKUINT(__returnValue.iVal) );
}
if (returnTypeSymbol == @symbol(bool)) {
- RETURN ( __returnValue.iVal ? true : false );
+ RETURN ( __returnValue.iVal ? true : false );
}
if (returnTypeSymbol == @symbol(float)) {
- RETURN ( __MKFLOAT(__returnValue.fVal ));
+ RETURN ( __MKFLOAT(__returnValue.fVal ));
}
if (returnTypeSymbol == @symbol(double)) {
- RETURN ( __MKFLOAT(__returnValue.dVal ));
+ RETURN ( __MKFLOAT(__returnValue.dVal ));
}
if (returnTypeSymbol == @symbol(void)) {
- RETURN ( nil );
+ RETURN ( nil );
}
if (returnTypeSymbol == @symbol(char)) {
- RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
+ RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) );
}
if (returnTypeSymbol == @symbol(wchar)) {
- RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
+ RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) );
}
if (returnTypeSymbol == @symbol(sint64)) {
# if (__POINTER_SIZE__ == 8)
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
- }
+ if (@global(Verbose) == true) {
+ printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal));
+ }
# endif
- RETURN ( __MKINT(__returnValue.longLongVal) );
+ RETURN ( __MKINT(__returnValue.longLongVal) );
# else
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
- }
+ if (@global(Verbose) == true) {
+ printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
+ }
# endif
- RETURN ( __MKINT64(&__returnValue.longLongVal) );
+ RETURN ( __MKINT64(&__returnValue.longLongVal) );
# endif
}
if (returnTypeSymbol == @symbol(uint64)) {
# if (__POINTER_SIZE__ == 8)
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
- }
+ if (@global(Verbose) == true) {
+ printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal));
+ }
# endif
- RETURN ( __MKUINT(__returnValue.longLongVal) );
+ RETURN ( __MKUINT(__returnValue.longLongVal) );
# else
# ifdef VERBOSE
- if (@global(Verbose) == true) {
- printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
- }
+ if (@global(Verbose) == true) {
+ printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal));
+ }
# endif
- RETURN ( __MKUINT64(&__returnValue.longLongVal) );
+ RETURN ( __MKUINT64(&__returnValue.longLongVal) );
# endif
}
# ifdef VERBOSE
if (@global(Verbose) == true) {
- printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal));
+ printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal));
}
# endif
if (returnTypeSymbol == @symbol(handle)) {
- returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
+ returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal);
} else if (returnTypeSymbol == @symbol(pointer)) {
- returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
+ returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
} else if (returnTypeSymbol == @symbol(bytePointer)) {
- returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
+ returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal);
} else if (returnTypeSymbol == @symbol(charPointer)) {
- returnValue = __MKSTRING(__returnValue.pointerVal);
+ returnValue = __MKSTRING(__returnValue.pointerVal);
} else if (returnTypeSymbol == @symbol(wcharPointer)) {
- returnValue = __MKU16STRING(__returnValue.pointerVal);
+ returnValue = __MKU16STRING(__returnValue.pointerVal);
} else {
- __FAIL__(@symbol(UnknownReturnType2))
+ __FAIL__(@symbol(UnknownReturnType2))
}
#else /* no FFI support */
failureCode = @symbol(FFINotSupported);
@@ -1872,49 +1876,49 @@
getOutOfHere: ;
%}.
failureCode notNil ifTrue:[
- (failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
- oldReturnType := returnType.
- oldArgumentTypes := argumentTypes.
- self adjustTypes.
- ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
- thisContext restart
- ].
- ].
- (failureCode == #BadArgForAsyncCall) ifTrue:[
- ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
- ].
- (failureCode == #FFINotSupported) ifTrue:[
- self primitiveFailed:'FFI support missing in this build'.
- ].
+ (failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[
+ oldReturnType := returnType.
+ oldArgumentTypes := argumentTypes.
+ self adjustTypes.
+ ((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[
+ thisContext restart
+ ].
+ ].
+ (failureCode == #BadArgForAsyncCall) ifTrue:[
+ ^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil
+ ].
+ (failureCode == #FFINotSupported) ifTrue:[
+ self primitiveFailed:'FFI support missing in this build'.
+ ].
- self primitiveFailed. "see failureCode and failureInfo for details"
- ^ nil
+ self primitiveFailed. "see failureCode and failureInfo for details"
+ ^ nil
].
returnType isSymbol ifTrue:[
- returnValueClass notNil ifTrue:[
- self isConstReturnValue ifTrue:[
- returnValue changeClassTo:returnValueClass.
- ^ returnValue
- ].
- ^ returnValueClass fromExternalAddress:returnValue.
- ].
+ returnValueClass notNil ifTrue:[
+ self isConstReturnValue ifTrue:[
+ returnValue changeClassTo:returnValueClass.
+ ^ returnValue
+ ].
+ ^ returnValueClass fromExternalAddress:returnValue.
+ ].
] ifFalse:[
- returnType isCPointer ifTrue:[
- returnType baseType isCStruct ifTrue:[
- stClass := Smalltalk classNamed:returnType baseType name.
- stClass notNil ifTrue:[
- self isConstReturnValue ifTrue:[
- returnValue changeClassTo:returnValueClass.
- ^ returnValue
- ].
- ^ stClass fromExternalAddress:returnValue.
- ].
- ].
- returnType baseType isCChar ifTrue:[
- ^ returnValue stringAt:1
- ].
- ].
+ returnType isCPointer ifTrue:[
+ returnType baseType isCStruct ifTrue:[
+ stClass := Smalltalk classNamed:returnType baseType name.
+ stClass notNil ifTrue:[
+ self isConstReturnValue ifTrue:[
+ returnValue changeClassTo:returnValueClass.
+ ^ returnValue
+ ].
+ ^ stClass fromExternalAddress:returnValue.
+ ].
+ ].
+ returnType baseType isCChar ifTrue:[
+ ^ returnValue stringAt:1
+ ].
+ ].
].
^ returnValue