FFI: FFI-Pools-mt.24.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-Pools-mt.24.mcz

commits-2
Marcel Taeumel uploaded a new version of FFI-Pools to project FFI:
http://source.squeak.org/FFI/FFI-Pools-mt.24.mcz

==================== Summary ====================

Name: FFI-Pools-mt.24
Author: mt
Time: 12 June 2020, 7:45:06.896226 pm
UUID: 2ab6b122-4784-e946-9e91-938ca2b01957
Ancestors: FFI-Pools-mt.23

Complements FI-Kernel-mt.105

=============== Diff against FFI-Pools-mt.23 ===============

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 typeNamed: aVariableTypeName)
- externalType := (ExternalType atomicTypeNamed: aVariableTypeName)
  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.!