Eliot Miranda uploaded a new version of FFI-Kernel to project FFI: http://source.squeak.org/FFI/FFI-Kernel-eem.183.mcz
==================== Summary ====================
Name: FFI-Kernel-eem.183 Author: eem Time: 26 July 2021, 4:37:11.825452 pm UUID: ca6c0ead-738a-4ab2-a658-b4fd904c9b51 Ancestors: FFI-Kernel-eem.182
Update the FFIAtomicReadWriteSend machinery to use the new accessors. Contains the post script method:
"Reinitialize FFIAtomicReadWriteSend to use the new accessors" ExternalType initializeDefaultTypes
=============== Diff against FFI-Kernel-eem.182 ===============
Item was changed: ----- Method: ExternalType class>>typeNamed: (in category 'instance lookup') ----- typeNamed: typeName "Supports pointer-type lookup for both atomic and structure types. Examples: 'long', 'long*', 'long *' or 'MyStruct', 'MyStruct*', 'MyStruct *', 'IntPtr', '*IntPtr' " | isPointerType isNonPointerType isArrayType actualTypeName type | - isArrayType := false. isNonPointerType := false. actualTypeName := typeName copyWithoutAll: ' '.
(isPointerType := actualTypeName last == $*) "e.g. MyStruct*" ifTrue: [actualTypeName := actualTypeName allButLast]. actualTypeName last == $) "e.g. (char[])* -- pointer type for array type" ifTrue: [actualTypeName := (actualTypeName copyFrom: 2 to: actualTypeName size - 1)]. (isNonPointerType := actualTypeName first == $*) "e.g. *DoublePtr" ifTrue: [actualTypeName := actualTypeName allButFirst].
(isArrayType := actualTypeName last == $]) ifTrue: [ type := self arrayTypeNamed: actualTypeName ] ifFalse: [ (Symbol lookup: actualTypeName) ifNotNil: [:sym | actualTypeName := sym]. type := (self atomicTypeNamed: actualTypeName) ifNil: [self structTypeNamed: actualTypeName]].
+ ^ type ifNotNil: + [isPointerType - ^ type ifNotNil: [ - isPointerType ifTrue: [type asPointerType "e.g. int* MyStruct* "] ifFalse: [isNonPointerType ifTrue: [type asNonPointerType "e.g. *IntPtr *MyStructPtr "] ifFalse: [type "e.g. int IntPtr MyStruct MyStructPtr "]]]!
Item was changed: ----- Method: FloatReadWriteSend class>>fromType: (in category 'instance creation') ----- fromType: type
+ ^(self lookupSelectorsFor: type) collect: + [:selector| | arguments | + arguments := selector numArgs caseOf: { + [1] -> "e.g. doubleAt:" [#(nil)]. "byteOffset" + [2] -> "e.g. floatAt:put:" [#(nil nil)]. "byteOffset aFloat" }. + (self receiver: nil "handle" selector: selector arguments: arguments) + byteSize: type byteSize; + yourself]! - | selectors | - selectors := self lookupSelectorsFor: type. - ^ { - - (self - receiver: nil "handle" selector: selectors first - arguments: (Array - with: nil "byteOffset")) - byteSize: type byteSize; - yourself. - - (self - receiver: nil "handle" selector: selectors second - arguments: (Array - with: nil "byteOffset" - with: nil "aFloat")) - byteSize: type byteSize; - yourself - - }!
Item was changed: ----- Method: IntegerReadWriteSend class>>fromType: (in category 'instance creation') ----- fromType: type "Overwritten to account for byteSize and isSigned." + + ^(self lookupSelectorsFor: type) collect: + [:selector| | arguments | + arguments := selector numArgs caseOf: { + [1] -> "e.g. int32At:" [#(nil)]. "byteOffset" + [2] -> "e.g. int8At:put:" [#(nil nil)]. "byteOffset integerValue" + [3] -> "e.g. integerAt:size:signed:" [{nil. "byteOffset" type byteSize. type isSigned}]. + [4] -> "e.g. integerAt:put:size:signed:" [{nil. "byteOffset" nil. "integerValue" type byteSize. type isSigned}] }. + (self receiver: nil "handle" selector: selector arguments: arguments) + byteSize: type byteSize; + yourself]! - - | selectors | - selectors := self lookupSelectorsFor: type. - ^ { - - (self - receiver: nil "handle" selector: selectors first - arguments: (Array - with: nil "byteOffset" - with: type byteSize - with: type isSigned)) - byteSize: type byteSize; - yourself. - - (self - receiver: nil "handle" selector: selectors second - arguments: (Array - with: nil "byteOffset" - with: nil "integerValue" - with: type byteSize - with: type isSigned)) - byteSize: type byteSize; - yourself. - }!
Item was changed: + (PackageInfo named: 'FFI-Kernel') postscript: '"Reinitialize FFIAtomicReadWriteSend to use the new accessors" + ExternalType initializeDefaultTypes'! - (PackageInfo named: 'FFI-Kernel') postscript: 'Smalltalk removeFromStartUpList: ExternalAddress. - Smalltalk removeFromStartUpList: ExternalObject. - - "Introduce FFIAtomicReadWriteSend. All types need to be reset and all fields need to be re-defined." - ExternalType resetAllTypes.'!
packages@lists.squeakfoundation.org