[squeak-dev] FFI: FFI-Kernel-mt.138.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 6 17:24:07 UTC 2021

Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:

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

Name: FFI-Kernel-mt.138
Author: mt
Time: 6 May 2021, 7:24:07.692981 pm
UUID: 9ca79170-aa43-3a48-bed3-ece1a118acc2
Ancestors: FFI-Kernel-mt.137

Adds a way to transparently access #byteSize for instances of structs, unions, external data.

Well, I am not happy with adding #byteSize to ExternalStructure because it removes one possible name for domain-specific structs. The actual issue is that -- in ExternalData -- we have no "container type" for containers with unknown sizes. While we do use pointer types (e.g. "byte*") at the moment, their byteSize (i.e. the word size, 8 for 64-bit) is not what we are looking for. Those "containers" have an unknown byteSize regarding their contents. Note that even an empty array type (e.g. byte[0]) would not work because ne would need to encode "unknown" and not "empty". Just like whether the "size" instVar in ExternalData is "nil" or "0". It has a different meaning.

Anyway, this solution is good enough at the moment.

=============== Diff against FFI-Kernel-mt.137 ===============

Item was added:
+ ----- Method: ExternalData>>byteSize (in category 'accessing') -----
+ byteSize
+ 	"Answer how many bytes the receiver manages."
+ 	self sizeCheck.
+ 	^ handle isExternalAddress
+ 		ifTrue: [self size * self contentType byteSize]
+ 		ifFalse: [ "ByteArray" handle size]!

Item was changed:
  ----- Method: ExternalData>>externalType (in category 'accessing - types') -----
+ 	^ self containerType!
- 	^ type!

Item was added:
+ ----- Method: ExternalStructure>>byteSize (in category 'accessing') -----
+ byteSize
+ 	"Answer the number of bytes managed by the receiver."
+ 	^ self externalType byteSize!

More information about the Squeak-dev mailing list