Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.178.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.178
Author: mt
Time: 27 May 2021, 2:29:05.913609 pm
UUID: ddf66c8a-450b-1641-a21a-987c508b1281
Ancestors: FFI-Kernel-mt.177
I missed the #allocateExternal case. Sorry, I forgot to run the tests before committing. My bad. :-(
=============== Diff against FFI-Kernel-mt.177 ===============
Item was changed:
----- Method: ExternalArrayType>>allocateExternal (in category 'external data') -----
allocateExternal
+ | data |
+ data := self contentType allocateExternal: self size.
+ ^ self isTypeAlias
+ ifTrue: [referentClass fromHandle: data getHandle]
+ ifFalse: [data]!
- ^ self contentType allocateExternal: self size!
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.177.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.177
Author: mt
Time: 27 May 2021, 2:26:09.621609 pm
UUID: 4cb498da-9e06-9343-943b-bcb208915b9c
Ancestors: FFI-Kernel-mt.176
Adds #pointer alias to quickly get a pointer type.
Adds type lookup for various type representations such as string, symbol, or struct class.
=============== Diff against FFI-Kernel-mt.176 ===============
Item was added:
+ ----- Method: ExternalType class>>lookupType: (in category 'instance lookup') -----
+ lookupType: structClassOrTypeNameOrType
+ "Answers a type from the given spec, which can be a name, a struct class, or an actual type. Approximate being a struct class via #isBehavior."
+
+ ^ structClassOrTypeNameOrType isString
+ ifTrue: [self typeNamed: structClassOrTypeNameOrType]
+ ifFalse: [structClassOrTypeNameOrType isBehavior
+ ifTrue: [structClassOrTypeNameOrType externalType]
+ ifFalse: [structClassOrTypeNameOrType]]!
Item was added:
+ ----- Method: ExternalType class>>pointer (in category 'type constants - extra') -----
+ pointer
+ "Answers a generic pointer type, that is, void*"
+
+ ^ ExternalType void asPointerType!
Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.176.mcz
==================== Summary ====================
Name: FFI-Kernel-mt.176
Author: mt
Time: 27 May 2021, 2:23:46.798609 pm
UUID: c7798b80-05bc-ba49-a177-790da21a663a
Ancestors: FFI-Kernel-mt.175
Fixes #allocate for alias-to-array types.
Fixes field access for alias-to-array types.
Adds #pointer alias to quickly get a pointer type.
Adds #type:at:(put:) as convenient way to fill a byte array with a mix of typed contents.
=============== Diff against FFI-Kernel-mt.175 ===============
Item was changed:
----- Method: ByteArray>>pointerAt: (in category '*FFI-Kernel-examples') -----
pointerAt: byteOffset
"For documentation and convenient exploration only. Type-safe access to byte arrays or external addresses SHOULD happen via external objects that have a type set such as instances of ExternalStructure and ExternalData."
+ ^ ExternalType pointer handle: self at: byteOffset!
- ^ ExternalType void asPointerType handle: self at: byteOffset!
Item was changed:
----- Method: ByteArray>>pointerAt:put: (in category '*FFI-Kernel-examples') -----
pointerAt: byteOffset put: value
"For documentation and convenient exploration only. Type-safe access to byte arrays or external addresses SHOULD happen via external objects that have a type set such as instances of ExternalStructure and ExternalData."
+ ^ ExternalType pointer handle: self at: byteOffset put: value!
- ^ ExternalType void asPointerType handle: self at: byteOffset put: value!
Item was added:
+ ----- Method: ByteArray>>type:at: (in category '*FFI-Kernel') -----
+ type: spec at: byteOffset
+ "For convenience, when the receiver needs to filled with a mix of typed contents. See FFICallback for an example."
+
+ ^ (ExternalType lookupType: spec) handle: self at: byteOffset!
Item was added:
+ ----- Method: ByteArray>>type:at:put: (in category '*FFI-Kernel') -----
+ type: spec at: byteOffset put: value
+ "For convenience, when the receiver needs to filled with a mix of typed contents. See FFICallback for an example."
+
+ ^ (ExternalType lookupType: spec) handle: self at: byteOffset put: value!
Item was changed:
----- Method: ExternalArrayType>>allocate (in category 'external data') -----
allocate
+ | data |
+ data := self contentType allocate: self size.
+ ^ self isTypeAlias
+ ifTrue: [referentClass fromHandle: data getHandle]
+ ifFalse: [data]!
- ^ self contentType allocate: self size!
Item was added:
+ ----- Method: ExternalTypeAlias>>at: (in category 'proxy') -----
+ at: index
+ "Compatibility for alias-to-array types."
+
+ ^ self value at: index!
Item was added:
+ ----- Method: ExternalTypeAlias>>at:put: (in category 'proxy') -----
+ at: index put: object
+ "Compatibility for alias-to-array types."
+
+ ^ self value at: index put: object!