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

commits at source.squeak.org commits at source.squeak.org
Sun May 16 05:59:11 UTC 2021


Marcel Taeumel uploaded a new version of FFI-Kernel to project FFI:
http://source.squeak.org/FFI/FFI-Kernel-mt.152.mcz

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

Name: FFI-Kernel-mt.152
Author: mt
Time: 16 May 2021, 7:59:09.18058 am
UUID: 45ab85b9-b754-6c41-91ae-029f790e1e23
Ancestors: FFI-Kernel-mt.151

Replaces the misnomer #asArray in ExternalStructure with a class-side #with: on ExternalData -- which fits the expected protocol for array creation.

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

Item was added:
+ ----- Method: ExternalData class>>with: (in category 'instance creation') -----
+ with: externalStructure
+ 	"Put externalStructure into an array. Note that pointer types need to be elevated as pointer type of the array type. The content type MUST be a non-pointer type because the handle will decide between internal memory or external address."
+ 
+ 	| contentType arrayType |
+ 	contentType := externalStructure externalType asNonPointerType.
+ 
+ 	contentType isAtomic ifTrue: [
+ 		^ (contentType allocate: 1)
+ 			at: 1 put: externalStructure getHandle;
+ 			yourself].
+ 
+ 	arrayType := contentType asArrayType: 1.
+ 	
+ 	^ ExternalData
+ 		fromHandle: externalStructure getHandle
+ 		type: arrayType!

Item was removed:
- ----- Method: ExternalStructure>>asArray (in category 'converting') -----
- asArray
- 	"Convert the receiver into an array. Note that pointer types need to be elevated as pointer type of the array type. The content type MUST be a non-pointer type because the handle will decide between internal memory or external address."
- 
- 	| contentType arrayType |
- 	contentType := self externalType asNonPointerType.
- 
- 	contentType isAtomic ifTrue: [
- 		^ (contentType allocate: 1)
- 			at: 1 put: handle;
- 			yourself].
- 
- 	arrayType := contentType asArrayType: 1.
- 	self externalType isPointerType
- 		ifTrue: [arrayType := arrayType asPointerType].
- 	
- 	^ ExternalData
- 		fromHandle: handle
- 		type: arrayType!

Item was changed:
  ----- Method: ExternalStructure>>ffiEqual: (in category 'comparing') -----
  ffiEqual: other
  	"We can compare bytes if the types are compatible."
  	
  	(self ffiIdentical: other) ifTrue: [^ true].
  	self externalType asNonPointerType = other externalType asNonPointerType ifFalse: [^ false].
+ 	^ (ExternalData with: self) ffiEqual: (ExternalData with: other)!
- 	^ self asArray ffiEqual: other asArray!

Item was changed:
  ----- Method: ExternalStructure>>ffiEqualityHash (in category 'comparing') -----
  ffiEqualityHash
  	
  	^ self ffiIdentityHash
+ 		bitXor: (ExternalData with: self) ffiEqualityHash!
- 		bitXor: self asArray ffiEqualityHash!

Item was changed:
  ----- Method: ExternalStructure>>postCopy (in category 'copying') -----
  postCopy
  	"Copy external memory into object memory, shallowCopy otherwise."
  
  	self externalType isPointerType
+ 		ifTrue: [handle := (ExternalData with: self) postCopy getHandle]
- 		ifTrue: [handle := self asArray postCopy getHandle]
  		ifFalse: [handle := handle copy. "Materializes byte-array read-writer section if any"].!



More information about the Squeak-dev mailing list