Add more compatibility methods to `UninterpretedBytes` jv
authorJan Vrany <jan.vrany@labware.com>
Thu, 13 May 2021 11:26:34 +0100
branchjv
changeset 25414 dffa84757e23
parent 25413 565bf29e3a20
child 25415 4ea1fe7c363f
Add more compatibility methods to `UninterpretedBytes`
UninterpretedBytes.st
--- a/UninterpretedBytes.st	Wed May 05 10:40:40 2021 +0100
+++ b/UninterpretedBytes.st	Thu May 13 11:26:34 2021 +0100
@@ -3,6 +3,7 @@
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
  COPYRIGHT (c) 2018 Jan Vrany
+ COPYRIGHT (c) 2021 LabWare
               All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -70,6 +71,7 @@
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
  COPYRIGHT (c) 2018 Jan Vrany
+ COPYRIGHT (c) 2021 LabWare
               All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -1298,6 +1300,28 @@
     "Modified: 1.7.1996 / 21:12:13 / cg"
 !
 
+unsignedByteAt:index
+    "return the 1 byte at index as an (unsigned) Integer.
+     The index is a smalltalk index (i.e. 1-based)."
+
+    ^ self at:index
+
+    "
+     |b|
+
+     b := ByteArray withAll:#(255 2 3 4).
+     (b unsignedByteAt:1) printStringRadix:16
+    "
+
+    "Created: / 13-05-2021 / 11:19:13 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+unsignedByteAt:index put: value
+    ^ self at:index put: value
+
+    "Created: / 13-05-2021 / 11:20:00 / Jan Vrany <jan.vrany@labware.com>"
+!
+
 unsignedLongAt:index
     "return the 4-bytes starting at index as an (unsigned) Integer.
      The index is a smalltalk index (i.e. 1-based).
@@ -1384,6 +1408,25 @@
     "Modified: / 5.3.1998 / 11:47:30 / stefan"
 !
 
+unsignedLongLongAt:index
+    "return the 8-bytes starting at index as an (unsigned) Integer.
+     The index is a smalltalk index (i.e. 1-based).
+     The value is retrieved in the machine's natural byte order.
+     Subclasses may redefine this for better performance.
+     Same as doubleWordAt: for protocol completeness"
+
+    ^ self unsignedInt64At:index MSB:self isBigEndian
+
+    "
+     |b|
+
+     b := ByteArray withAll:#(1 2 3 4 5 6 7 8).
+     (b unsignedLongLongAt:1) printStringRadix:16
+    "
+
+    "Created: / 13-05-2021 / 11:15:34 / Jan Vrany <jan.vrany@labware.com>"
+!
+
 unsignedLongLongAt:index bigEndian:msb
     "return the 8-bytes starting at index as an (unsigned) Integer.
      The index is a smalltalk index (i.e. 1-based).
@@ -5057,6 +5100,11 @@
 
 version_CVS
     ^ '$Header$'
+!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
 ! !