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

Marcel Taeumel marcel.taeumel at hpi.de
Tue May 4 08:59:33 UTC 2021


Am 04.05.2021 10:57:32 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Marcel Taeumel uploaded a new version of FFI-Tools to project FFI:
http://source.squeak.org/FFI/FFI-Tools-mt.23.mcz

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

Name: FFI-Tools-mt.23
Author: mt
Time: 4 May 2021, 10:57:22.658881 am
UUID: 1c015fd1-e56d-a84a-b4c8-5987e99cbcbd
Ancestors: FFI-Tools-mt.22

In object explorers, change the repersentation of compiledSpec to better reflect its intentions. I suppose. :-)

Note that compiledSpec is a WordArray. I changed the appearance of the words in the array to distinguish atomic type, type flags, byte size, and start/end of embedded structs.

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

Item was added:
+ ObjectExplorerWrapper subclass: #CompiledSpecWrapper
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: 'FFIConstants'
+ category: 'FFI-Tools'!

Item was added:
+ ----- Method: CompiledSpecWrapper>>contents (in category 'accessing') -----
+ contents
+
+ ^ self object isInteger ifTrue: [#()] ifFalse: [ "WordArray"
+ Array streamContents: [:s |
+ self object withIndexDo: [:word :index |
+ s nextPut: (self class
+ with: word
+ name: index printString
+ model: self model)]]]!

Item was added:
+ ----- Method: CompiledSpecWrapper>>objectString (in category 'accessing') -----
+ objectString
+
+ ^ self object isInteger
+ ifFalse: [self printWordArray]
+ ifTrue: [self printWordArrayElement]!

Item was added:
+ ----- Method: CompiledSpecWrapper>>print:base:group:length: (in category 'printing') -----
+ print: integer base: base group: group length: length
+
+ ^ String streamContents: [:stream |
+ | label |
+ label := integer printStringBase: base.
+ label := label padded: #left to: length with: $0.
+ (1 to: label size by: group)
+ do: [:index |
+ 1 to: group do: [:gIndex |
+ stream nextPut: (label at: index + gIndex - 1)]]
+ separatedBy: [stream space]]!

Item was added:
+ ----- Method: CompiledSpecWrapper>>printWordArray (in category 'printing') -----
+ printWordArray
+
+ ^ String streamContents: [:stream |
+ stream nextPutAll: '16r ['.
+ self object
+ do: [:word | stream nextPutAll: (self print: word base: 16 group: 2 length: 8)]
+ separatedBy: [stream nextPutAll: ' | '].
+ stream nextPut: $] ]!

Item was added:
+ ----- Method: CompiledSpecWrapper>>printWordArrayElement (in category 'printing') -----
+ printWordArrayElement
+
+ ^ String streamContents: [:stream |
+
+ | atomicType externalType byteSize isStructStart isStructEnd isHeader |
+ atomicType := (self object bitAnd: FFIAtomicTypeMask) >> FFIAtomicTypeShift.
+ externalType := (self object bitAnd: 16rFF0000) >> (FFIAtomicTypeShift - 8).
+ byteSize := (self object bitAnd: FFIStructSizeMask).
+
+ isHeader := self itemName = '1'.
+ isStructStart := isHeader not and: [(self object anyMask: FFIFlagStructure) and: [byteSize ~= 0]].
+ isStructEnd := (self object anyMask: FFIFlagStructure) and: [byteSize = 0].
+
+ stream
+ nextPutAll: (atomicType asString padded: #left to: 2 with: Character space);
+ nextPutAll: ' | ';
+ nextPutAll: (self print: externalType base: 2 group: 4 length: 8);
+ nextPutAll: ' | ';
+ nextPutAll: (self print: byteSize base: 16 group: 2 length: 4);
+ nextPutAll: ' (';
+ nextPutAll: byteSize asString;
+ nextPutAll: ' bytes)'.
+ isHeader ifTrue: [stream nextPutAll: ' --- HEADER'].
+ isStructStart ifTrue: [stream nextPutAll: ' --- STRUCT START'].
+ isStructEnd ifTrue: [stream nextPutAll: ' --- STRUCT END']].!

Item was added:
+ ----- Method: ExternalType>>explorerContents (in category '*FFI-Tools') -----
+ explorerContents
+
+ | basicExplorerFields |
+ basicExplorerFields := super explorerContents.
+ basicExplorerFields do: [:explorerField |
+ explorerField itemName = 'compiledSpec' ifTrue: [
+ explorerField changeClassTo: CompiledSpecWrapper]].
+ ^ basicExplorerFields!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210504/e055de62/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 69103 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210504/e055de62/attachment-0001.png>


More information about the Squeak-dev mailing list