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

Marcel Taeumel marcel.taeumel at hpi.de
Thu May 6 18:00:07 UTC 2021


Am 06.05.2021 19:57:59 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.28.mcz

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

Name: FFI-Tools-mt.28
Author: mt
Time: 6 May 2021, 7:57:49.985981 pm
UUID: baed18b3-7684-634c-b285-691d551be27c
Ancestors: FFI-Tools-mt.27

Make the label for handles accessed via byte-array read-writer more readable by summarizing skipped bytes to a number instead of dots after a certain threshold, which is 16 bytes at the moment.

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

Item was changed:
----- Method: ExternalObjectHandleWrapper>>objectString (in category 'accessing') -----
objectString

+ | label handle skipLimit |
- | label handle |
label := super objectString.
handle := self getHandle.
+ skipLimit := 16.

handle isExternalAddress ifTrue: [^ label].
handle isInternalMemory ifTrue: [
^ (thisContext objectClass: handle) == ByteArrayReadWriter
ifFalse: [label]
+ ifTrue: [ | begin end tokens |
+ label :=(thisContext object: handle instVarAt: 3) "byteArray" printString.
- ifTrue: [ | begin end |
- label :=(thisContext object: handle instVarAt: 3) printString.
label := label copyFrom: 3 to: (label size - 1).
+ begin := (thisContext object: handle instVarAt: 1) "byteOffset" + 1.
+ end := begin - 1 + (thisContext object: handle instVarAt: 2) "byteSize".
- begin := (thisContext object: handle instVarAt: 1) + 1.
- end := begin + (thisContext object: handle instVarAt: 2) - 1.
String streamContents: [:stream |
stream nextPutAll: '#[ '.
+ tokens := label findTokens: ' ' "#[0 0 0 0 0]".
+ begin > skipLimit ifTrue: [
+ stream nextPutAll: '. . ', (begin - 1) asString, ' bytes . . '.
+ tokens := tokens allButFirst: begin - 1.
+ end := end - begin + 1. begin := 1].
+ (1 to: end) do: [:index | | token |
+ token := tokens at: index.
+ index >= begin
- (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].
+ (tokens size - end + 1) > skipLimit ifTrue: [
+ stream nextPutAll: '. . ', (tokens size - end) asString, ' bytes . . '.
+ tokens := tokens allButLast: tokens size - end.
+ end := tokens size].
+ (tokens size - end) timesRepeat: [
+ "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!


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


More information about the Squeak-dev mailing list