Eliot Miranda uploaded a new version of FFI-Kernel to project FFI: http://source.squeak.org/FFI/FFI-Kernel-eem.184.mcz
==================== Summary ====================
Name: FFI-Kernel-eem.184 Author: eem Time: 26 July 2021, 6:36:07.613943 pm UUID: 4cfd2228-15ae-475b-b152-805e77401509 Ancestors: FFI-Kernel-eem.183
Make ExternalType class>>#initializeAtomicTypes cope with old images in which all the AtomicTypes are still instances of ExternalType, not ExternalAtomicType.
Add robustness to cleanupUnusedTypes, and to ExternalType>isTypeAlias (to get the package to load in older images).
Provide readFieldAt:/writeFieldAt: for ExternalUnknownType so that packages can load.
=============== Diff against FFI-Kernel-eem.183 ===============
Item was changed: ----- Method: ExternalType class>>cleanupUnusedTypes (in category 'housekeeping') ----- cleanupUnusedTypes "In the lookup table for struct types and array types, remove keys to types no longer present.. ExternalType cleanupUnusedTypes " Smalltalk garbageCollect. StructTypes keys do: [:key | (StructTypes at: key) ifNil: [ StructTypes removeKey: key]]. ArrayTypes keys do: [:contentTypeName | | sizes | sizes := ArrayTypes at: contentTypeName. + [sizes keys do: [:size | - sizes keys do: [:size | (sizes at: size) ifNil: [sizes removeKey: size]]. + sizes ifEmpty: [ + ArrayTypes removeKey: contentTypeName]] + on: Error + do: [:ex| Transcript print: ex; cr; flush]]! - sizes ifEmpty: [ - ArrayTypes removeKey: contentTypeName]].!
Item was changed: ----- Method: ExternalType class>>initializeAtomicTypes (in category 'class initialization') ----- initializeAtomicTypes "ExternalType initialize" | atomicType byteSize type typeName byteAlignment | self flag: #ffiLongVsInt. "For a discussion about long vs. int see http://forum.world.st/Re-squeak-dev-64-bit-FFI-was-porting-Croquet-to-Squeak...." + AtomicTypes do: + [:anAtomicType| + (anAtomicType class ~~ ExternalAtomicType + and: [anAtomicType class == ExternalType]) ifTrue: + [ExternalAtomicType adoptInstance: anAtomicType]]. - #( "name atomic id byte size byte alignment" ('void' 0 0 0) "No non-pointer support in calls. Duh. ;-)" ('bool' 1 1 1) "No pointer support in calls." ('byte' 2 1 1) ('sbyte' 3 1 1) ('ushort' 4 2 2) ('short' 5 2 2) "!!!!!!" ('ulong' 6 4 "!!!!!!" 4) "!!!!!!" ('long' 7 4 "!!!!!!" 4) ('ulonglong' 8 8 8) "v.i." ('longlong' 9 8 8) "v.i." ('char' 10 1 1) ('schar' 11 1 1) ('float' 12 4 4) ('double' 13 8 8) "v.i." "TODO: ('longdouble' 14 10 16? 4?)" ) do:[:typeSpec| | compiled | typeName := typeSpec first. atomicType := typeSpec second. byteSize := typeSpec third. byteAlignment := typeSpec fourth. "0) On 32-bits Windows and MacOS, double and long long have an alignment of 8. But on 32-bit Linux, their alignment is 4. But not on a 32-bit Raspberry Pi OS." (FFIPlatformDescription current wordSize = 4 and: [FFIPlatformDescription current isUnix and: [FFIPlatformDescription current isARM not]]) ifTrue: [ (#('double' 'longlong' 'ulonglong') includes: typeName) ifTrue: [ byteAlignment := 4]]. "1) Regular type" type := (AtomicTypes at: typeName). compiled := WordArray with: ((byteSize bitOr: FFIFlagAtomic) bitOr: (atomicType bitShift: FFIAtomicTypeShift)). compiled ~= type compiledSpec "Preserve the identity of #compiledSpec." ifTrue: [type compiledSpec: compiled]. type byteAlignment: byteAlignment. "2) Pointer type" type := type asPointerType. compiled := WordArray with: ((self pointerSpec bitOr: FFIFlagAtomic) bitOr: (atomicType bitShift: FFIAtomicTypeShift)). compiled ~= type compiledSpec "Preserve the identity of #compiledSpec." ifTrue: [type compiledSpec: compiled]. type byteAlignment: self pointerAlignment. ].!
Item was changed: ----- Method: ExternalType>>isTypeAlias (in category 'testing') ----- isTypeAlias + ^true ifTrue: [false] ifFalse: [self subclassResponsibility]! - self subclassResponsibility.!
Item was added: + ----- Method: ExternalUnknownType>>readFieldAt: (in category 'external structure') ----- + readFieldAt: anInteger + ^'self error: ''cannot read field at ', anInteger printString, '; field has unknown type'''!
Item was added: + ----- Method: ExternalUnknownType>>writeFieldAt:with: (in category 'external structure') ----- + writeFieldAt: anInteger with: aString + ^'self error: ''cannot read field at ', anInteger printString, ' with name ', aString, '; field has unknown type'''!
packages@lists.squeakfoundation.org