--- a/ExternalLibraryFunction.st Tue Dec 05 11:31:16 2006 +0100
+++ b/ExternalLibraryFunction.st Tue Dec 05 11:42:02 2006 +0100
@@ -9,7 +9,6 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
"{ Package: 'stx:libbasic' }"
ExternalFunction subclass:#ExternalLibraryFunction
@@ -415,6 +414,13 @@
!ExternalLibraryFunction methodsFor:'private'!
+adjustTypes
+ argumentTypes notNil ifTrue:[
+ argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType].
+ ].
+ returnType := self ffiTypeSymbolForType:returnType.
+!
+
linkToModule
"link this function to the external module.
I.e. retrieve the module handle and the code pointer."
@@ -458,22 +464,15 @@
self linkToModule.
self adjustTypes.
].
-!
-
-adjustTypes
- argumentTypes notNil ifTrue:[
- argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType].
- ].
- returnType := self ffiTypeSymbolForType:returnType.
! !
!ExternalLibraryFunction methodsFor:'private-accessing'!
ffiTypeSymbolForType:aType
"map type to one of the ffi-supported ones:
- sint8, sint16, sint32, sint64
- uint8, uint16, uint32, uint64
- bool void handle
+ sint8, sint16, sint32, sint64
+ uint8, uint16, uint32, uint64
+ bool void handle
"
|t|
@@ -499,20 +498,20 @@
aType == #int64 ifTrue:[^ #sint64 ].
aType == #voidPointer ifTrue:[^ #pointer ].
- aType == #short ifTrue:[^ #int16 ].
- aType == #long ifTrue:[^ #int32 ]. "/ TODO - care for 64bit machines
- aType == #int ifTrue:[^ #int32 ]. "/ TODO - care for 64bit machines
+ aType == #short ifTrue:[^ #sint16 ].
+ aType == #long ifTrue:[^ #long ].
+ aType == #int ifTrue:[^ #int ].
aType == #ushort ifTrue:[^ #uint16 ].
aType == #unsignedShort ifTrue:[^ #uint16 ].
- aType == #ulong ifTrue:[^ #uint32 ]. "/ TODO - care for 64bit machines
- aType == #unsignedLong ifTrue:[^ #uint32 ]. "/ TODO - care for 64bit machines
+ aType == #ulong ifTrue:[^ #ulong ].
+ aType == #unsignedLong ifTrue:[^ #ulong ].
aType == #uchar ifTrue:[^ #uint8 ].
aType == #unsignedChar ifTrue:[^ #uint8 ].
aType == #byte ifTrue:[^ #uint8 ].
aType == #dword ifTrue:[^ #uint32 ].
- aType == #sdword ifTrue:[^ #int32 ].
+ aType == #sdword ifTrue:[^ #sint32 ].
aType == #word ifTrue:[^ #uint16 ].
- aType == #sword ifTrue:[^ #int16 ].
+ aType == #sword ifTrue:[^ #sint16 ].
aType == #handle ifTrue:[^ #pointer ].
aType == #lpstr ifTrue:[^ #charPointer ].
aType == #hresult ifTrue:[^ #uint32 ].
@@ -524,10 +523,10 @@
aType == #structOut ifTrue:[^ #pointer ].
(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
@@ -1195,7 +1194,7 @@
!ExternalLibraryFunction class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.45 2006-10-04 09:10:37 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalLibraryFunction.st,v 1.46 2006-12-05 10:42:02 fm Exp $'
! !
ExternalLibraryFunction initialize!