Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.147.mcz==================== Summary ====================
Name: FFI-Kernel-mt.147
Author: mt
Time: 15 May 2021, 3:24:49.792642 pm
UUID: 8ece59e5-a84c-8046-9d5e-4c26b0332926
Ancestors: FFI-Kernel-mt.146
Fixes automatic conversion of atomic pointer types to array types.
Adds special treatment for 'ExternalType string' to make this work:
data setType: ExternalType string) fromCString.
data setContentType: ExternalType string) fromCString.
...the latter being the recommended form. Note that string lists are still possible:
data setType: (ExternalType string asArrayType: nil).
ExternalData fromHandle: h type: (ExternalType string asArrayType: nil).
...the latter being the generated form for struct fields (i.e. 'string[5]').
=============== Diff against FFI-Kernel-mt.146 ===============
Item was changed:
----- Method: ExternalData>>setContentType: (in category 'initialize-release') -----
setContentType: externalType
+ externalType = ExternalType string ifTrue: [
+ ^ self setContentType: externalType asNonPointerType].
+
self setType: (externalType asArrayType: self size).!
Item was changed:
----- Method: ExternalData>>setType: (in category 'private') -----
setType: externalType
"Private. Set the type used to derive content and container types. If you want to change the content type later, use #setContentType:."
externalType isVoid ifTrue: [
^ self setType: externalType asPointerType].
+ externalType = ExternalType string ifTrue: [
+ ^ self setType: externalType asNonPointerType].
externalType asNonPointerType isArrayType
ifTrue: [type := externalType]
ifFalse: [type := (externalType asArrayType: nil)].
handle isExternalAddress
ifTrue: [type := type asPointerType]
ifFalse: [type := type asNonPointerType].!
Item was changed:
----- Method: ExternalData>>typeCheck (in category 'private') -----
typeCheck
"Check type. If you happen to have a regular pointer type here, convert it into array type of unknown size. This can happen for result values of FFI calls if the signature did not specify, e.g., 'int[]' but 'int*'."
type asNonPointerType isArrayType
+ ifFalse: [self setType: type "int*" asNonPointerType "int ... to become int[], not int*[]"].!
- ifFalse: [self setType: type].!