FFI: FFI-Tools-mt.28.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FFI: FFI-Tools-mt.28.mcz

commits-2
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!


Reply | Threaded
Open this post in threaded view
|

Re: FFI: FFI-Tools-mt.28.mcz

marcel.taeumel

Am 06.05.2021 19:57:59 schrieb [hidden email] <[hidden email]>:

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!