[squeak-dev] FFI: FFI-Tools-mt.24.mcz

commits at source.squeak.org commits at source.squeak.org
Tue May 4 14:43:43 UTC 2021


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

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

Name: FFI-Tools-mt.24
Author: mt
Time: 4 May 2021, 4:43:42.172881 pm
UUID: 411d91ef-c5dc-3643-b69f-8c9620d93201
Ancestors: FFI-Tools-mt.23

Make use of the byte-array writer to conveniently explore composite structures along with proper support for do-it. Both of which is fine for heap objects but challenging for handles that are byte arrays.

=============== Diff against FFI-Tools-mt.23 ===============

Item was changed:
  ----- Method: ExternalObjectHandleWrapper>>objectString (in category 'accessing') -----
  objectString
  
+ 	| label handle |
+ 	label := super objectString.
+ 	handle := self getHandle.
- 	self getHandle class == ExternalAddress ifTrue: [^ super objectString].
- 	self getHandle class == ByteArray ifTrue: [^ super objectString].
  
+ 	handle isExternalAddress ifTrue: [^ label].
+ 	handle isInternalMemory ifTrue: [
+ 		^ (thisContext objectClass: handle) == ByteArrayReadWriter
+ 			ifFalse: [label]
+ 			ifTrue: [ | begin end |
+ 				label :=(thisContext object: handle instVarAt: 3) printString.
+ 				label := label copyFrom: 3 to: (label size - 1).
+ 				begin := (thisContext object: handle instVarAt: 1) + 1.
+ 				end := begin + (thisContext object: handle instVarAt: 2) - 1.
+ 				String streamContents: [:stream |
+ 					stream nextPutAll: '#[ '.
+ 					(label findTokens: ' ' "#[0 0 0 0 0]") withIndexDo: [:token :index |
+ 						(index between: begin and: end)
+ 							ifTrue: [stream nextPutAll: token]
+ 							ifFalse: ["Skip byte info" stream nextPut: $.].
+ 						stream space].
+ 					stream nextPutAll: ']'.
+ 			]]].
+ 
  	"Type aliases to atomic types store primitive Smalltalk objects in their handle. Indicate that role of actually being a handle for the FFI plugin with a small prefix."
+ 	^ '-> ', label!
- 	^ '-> ', super objectString!

Item was added:
+ ----- Method: ExternalStructure>>explore (in category '*FFI-Tools') -----
+ explore
+ 	"Sneak in a reader so that do-its will work better from the obeject explorer."
+ 	
+ 	self reader perform: #explore withArguments: #() inSuperclass: ExternalObject.!



More information about the Squeak-dev mailing list