Marcel Taeumel uploaded a new version of FFI-Pools to project FFI:
http://source.squeak.org/FFI/FFI-Pools-mt.21.mcz==================== Summary ====================
Name: FFI-Pools-mt.21
Author: mt
Time: 6 June 2020, 2:13:55.081722 pm
UUID: 60c8c90c-9c2d-e04d-955b-c89392ba186c
Ancestors: FFI-Pools-mt.20
Complements FFI-Kernel-mt.97
=============== Diff against FFI-Pools-mt.20 ===============
Item was changed:
----- Method: ExternalPoolDefinition>>ffiVariable:type:convertTo: (in category 'pragmas') -----
ffiVariable: aVariableName type: aVariableTypeName convertTo: aClassName
| externalType targetClassName targetClass |
"0) Skip variables with nil type."
aVariableTypeName ifNil: [
^ self variablesAndTypesAt: aVariableName put: nil].
"1) Look up external type from type name."
+ targetClassName := aClassName.
+ externalType := (ExternalType atomicTypeNamed: aVariableTypeName)
- externalType := (ExternalType atomicTypeNamed: (aVariableTypeName findTokens: '*') first withBlanksTrimmed)
- ifNotNil: [:atomicType |
- targetClassName := aClassName.
- aVariableTypeName last = $*
- ifTrue: [atomicType asPointerType]
- ifFalse: [atomicType]]
ifNil: [ "Backwards compatiblility only. Try to not write class names as <... type: ...>."
targetClassName := aVariableTypeName.
self externalTypeForClassName: aVariableTypeName].
"2) Look up class in current environment."
targetClass := (self environment classNamed: targetClassName) ifNil: [
ExternalPoolError signal:
'Cannot convert to ', aClassName, ' from C type; ',
'no matching Smalltalk class found'].
"3) Try to specialize conversion class."
(externalType = ExternalType float or: [externalType = ExternalType double])
ifTrue: [(Float includesBehavior: targetClass) ifTrue: [targetClass := Float]].
(externalType = ExternalType char asPointerType)
ifTrue: [(String includesBehavior: targetClass) ifTrue: [targetClass := String]].
"4) Store the resulting type spec for pool read-writers to use."
self
variablesAndTypesAt: aVariableName
put: externalType -> targetClass.!