#REFACTORING
authorClaus Gittinger <cg@exept.de>
Sat, 13 Feb 2016 21:05:21 +0100
changeset 19211 ce962456161b
parent 19210 b2b806e94d69
child 19212 06790833587e
#REFACTORING class: Stream added:19 methods comment/format in: #nextTwoBytesPut: changed:14 methods category of:18 methods reorganized. The nextIntXX and nextPutIntXX methods are now the standard way of doing I/O (with explicit sizes in the name, instead of implizit knowledge about what a word, long, longlong etc is)
Stream.st
--- a/Stream.st	Sat Feb 13 12:24:19 2016 +0100
+++ b/Stream.st	Sat Feb 13 21:05:21 2016 +0100
@@ -223,6 +223,58 @@
     self nextPutAll: someObject asString.
 ! !
 
+!Stream methodsFor:'Compatibility-ST80'!
+
+nextLongPut:aNumber
+    <resource: #obsolete>
+
+    "for ST-80 compatibility:
+     Write the argument, aNumber as a long (four bytes). 
+     The most significant byte is sent first."
+
+    ^ self nextPutLong:aNumber MSB:true
+
+    "Modified: 10.1.1996 / 19:38:54 / cg"
+!
+
+nextPutWord:aNumber
+    <resource: #obsolete>
+
+    "write the argument, aNumber as a signed short (two bytes);
+     write msb-first for compatibility with other smalltalks.
+     The receiver must support writing of binary bytes.
+     I dont know if it should be named nextPutWord: or nextWordPut:;
+     one of them will vanish ..."
+
+    ^ self nextPutInt16:aNumber MSB:true
+!
+
+nextTwoBytesPut: anInteger
+    <resource: #obsolete>
+    "Write anInteger as the next two bytes of the
+     receiver stream."
+
+    self obsoleteMethodWarning:'use #nextPutShort:MSB:'.
+
+    self
+        nextPutByte: (anInteger bitAnd: 255);
+        nextPutByte: ((anInteger bitShift: -8) bitAnd: 255)
+
+    "Created: / 21-06-2006 / 19:42:10 / fm"
+!
+
+nextWordPut:aNumber
+    <resource: #obsolete>
+
+    "for ST-80 compatibility:
+     Write the argument, aNumber as a short (two bytes). 
+     The most significant byte is sent first."
+
+    ^ self nextPutShort:aNumber MSB:true
+
+    "Modified: 10.1.1996 / 19:39:19 / cg"
+! !
+
 !Stream methodsFor:'accessing'!
 
 contents
@@ -957,59 +1009,6 @@
     "Created: 22.4.1997 / 10:42:26 / cg"
 !
 
-nextHyperMSB:msbFlag
-    "return a signed hyper (8 bytes) from the stream.
-     The receiver must support reading of binary bytes.
-
-     The msbFlag argument controls if the integer is to be read with
-     most-significant-byte-first (true) or least-first (false).
-     This interface is provided to allow talking to external programs,
-     where its known that the byte order is some definite one.
-     If you dont care (i.e. talk to other smalltalks) or you can control the
-     order, please use the corresponding xxxNet methods, which use a standard
-     network byte order."
-
-    |uval|
-
-    uval := self nextUnsignedHyperMSB:msbFlag.
-    "change from unsigned 0..FF..FF to signed -80..00..7FF..FF"
-
-    uval >= 16r8000000000000000 ifTrue:[
-      ^ uval - 16r10000000000000000 
-    ].
-    ^ uval
-
-    "
-     |bytes s|
-
-     bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF].
-     s := bytes readStream.
-     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
-     s reset.
-     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
-
-     bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00].
-     s := bytes readStream.
-     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
-     s reset.
-     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
-
-     bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0].
-     s := bytes readStream.
-     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
-     s reset.
-     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
-
-     bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10].
-     s := bytes readStream.
-     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
-     s reset.
-     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
-    "
-
-    "Modified: / 14.1.1998 / 15:40:41 / cg"
-!
-
 nextIEEEDouble
     "read an 8-byte IEEE double precision float number"
 
@@ -1034,7 +1033,52 @@
     ^ ShortFloat readBinaryIEEESingleFrom:self MSB:msbFirst
 !
 
-nextLongMSB:msbFlag
+nextInt16MSB:msbFlag
+    "return a signed short (2 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where it's known that the byte order is some definite one.
+     If you don't care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |b1 b2 uval "{ Class: SmallInteger }"|
+
+    b1 := self nextByte.
+    b2 := self nextByte.
+
+    msbFlag ifTrue:[
+        "most significant first"
+        uval := b1 bitShift:8.
+        uval := uval bitOr:b2.
+    ] ifFalse:[
+        "least significant first"
+        uval := b2 bitShift:8.
+        uval := uval bitOr:b1.
+    ].
+    "change from unsigned 0..FFFF to signed -8000..7FFF"
+    uval >= 16r8000 ifTrue:[
+        ^ uval - 16r10000 
+    ].
+    ^ uval
+
+    "Modified: 11.7.1996 / 10:07:04 / cg"
+!
+
+nextInt16Net
+    "return a signed short (2 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes.
+     Network byte order is MSB per definition"
+
+    ^ self nextInt16MSB:true
+
+    "Created: 10.1.1996 / 19:49:41 / cg"
+!
+
+nextInt32MSB:msbFlag
     "return a signed long (4 bytes) from the stream.
      The receiver must support reading of binary bytes.
 
@@ -1076,86 +1120,101 @@
 
      bytes := #[16rFF 16rFF 16rFF 16rFF].
      s := bytes readStream.
-     Transcript showCR:(s nextLongMSB:true).
+     Transcript showCR:(s nextInt32MSB:true).
      s reset.
-     Transcript showCR:(s nextLongMSB:false).
+     Transcript showCR:(s nextInt32MSB:false).
 
      bytes := #[16r12 16r34 16r56 16r78].
      s := bytes readStream.
-     Transcript showCR:(s nextLongMSB:true).
+     Transcript showCR:(s nextInt32MSB:true).
      s reset.
-     Transcript showCR:(s nextLongMSB:false).
+     Transcript showCR:(s nextInt32MSB:false).
 
      bytes := #[16r89 16rab 16rcd 16ref].
      s := bytes readStream.
-     Transcript showCR:(s nextLongMSB:true).
+     Transcript showCR:(s nextInt32MSB:true).
      s reset.
-     Transcript showCR:(s nextLongMSB:false).
+     Transcript showCR:(s nextInt32MSB:false).
     "
 
     "Modified: / 14.1.1998 / 15:40:41 / cg"
 !
 
-nextLongNet
+nextInt32Net
     "return a signed long (4 bytes) in network byte order from the stream.
      The receiver must support reading of binary bytes."
 
-    ^ self nextLongMSB:true
+    ^ self nextInt32MSB:true
 
     "Created: 10.1.1996 / 19:49:28 / cg"
 !
 
+nextInt64MSB:msbFlag
+    "return a signed hyper (8 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |uval|
+
+    uval := self nextUnsignedInt64MSB:msbFlag.
+    "change from unsigned 0..FF..FF to signed -80..00..7FF..FF"
+
+    uval >= 16r8000000000000000 ifTrue:[
+      ^ uval - 16r10000000000000000 
+    ].
+    ^ uval
+
+    "
+     |bytes s|
+
+     bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF].
+     s := bytes readStream.
+     Transcript showCR:(s nextInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextInt64MSB:false) hexPrintString.
+
+     bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00].
+     s := bytes readStream.
+     Transcript showCR:(s nextInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextInt64MSB:false) hexPrintString.
+
+     bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0].
+     s := bytes readStream.
+     Transcript showCR:(s nextInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextInt64MSB:false) hexPrintString.
+
+     bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10].
+     s := bytes readStream.
+     Transcript showCR:(s nextInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextInt64MSB:false) hexPrintString.
+    "
+
+    "Modified: / 14.1.1998 / 15:40:41 / cg"
+!
+
+nextInt64Net
+    "return a signed longlong (8 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes."
+
+    ^ self nextInt64MSB:true
+!
+
 nextNumber:numBytes 
     "Return the next n bytes as a positive Integer; bytes are taken msb-first."
 
     ^ self nextUnsigned:numBytes MSB:true
 !
 
-nextShortMSB:msbFlag
-    "return a signed short (2 bytes) from the stream.
-     The receiver must support reading of binary bytes.
-
-     The msbFlag argument controls if the integer is to be read with
-     most-significant-byte-first (true) or least-first (false).
-     This interface is provided to allow talking to external programs,
-     where it's known that the byte order is some definite one.
-     If you don't care (i.e. talk to other smalltalks) or you can control the
-     order, please use the corresponding xxxNet methods, which use a standard
-     network byte order."
-
-    |b1 b2 uval "{ Class: SmallInteger }"|
-
-    b1 := self nextByte.
-    b2 := self nextByte.
-
-    msbFlag ifTrue:[
-        "most significant first"
-        uval := b1 bitShift:8.
-        uval := uval bitOr:b2.
-    ] ifFalse:[
-        "least significant first"
-        uval := b2 bitShift:8.
-        uval := uval bitOr:b1.
-    ].
-    "change from unsigned 0..FFFF to signed -8000..7FFF"
-    uval >= 16r8000 ifTrue:[
-        ^ uval - 16r10000 
-    ].
-    ^ uval
-
-    "Modified: 11.7.1996 / 10:07:04 / cg"
-!
-
-nextShortNet
-    "return a signed short (2 bytes) in network byte order from the stream.
-     The receiver must support reading of binary bytes.
-     Network byte order is MSB per definition"
-
-    ^ self nextShortMSB:true
-
-    "Created: 10.1.1996 / 19:49:41 / cg"
-!
-
 nextSignedByte
     "return a signed byte (-128..127) from the stream.
      The receiver must support reading of binary bytes."
@@ -1245,25 +1304,7 @@
      order, please use the corresponding xxxNet methods, which use a standard
      network byte order."
 
-    |bytes uval t|
-
-    bytes := self nextBytes:8.
-    uval := 0.
-
-    msbFlag ifTrue:[
-        "most significant first"
-        1 to:8 do:[:i |
-            t := (uval bitShift:8).
-            uval := t bitOr:(bytes at:i).
-        ].
-    ] ifFalse:[
-        "least significant first"
-        8 to:1 by:-1 do:[:i |
-            t := (uval bitShift:8).
-            uval := t bitOr:(bytes at:i).
-        ].
-    ].
-    ^ uval
+    ^ self nextUnsignedInt64MSB:msbFlag
 
     "
      |bytes s|
@@ -1296,6 +1337,278 @@
     "Modified: / 14.1.1998 / 15:40:41 / cg"
 !
 
+nextUnsignedInt16MSB:msbFlag
+    "return an unsigned short (2 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |b1 b2|
+
+    b1 := self nextByte.
+    b2 := self nextByte.
+
+    msbFlag ifTrue:[
+        ^ (b1 bitShift:8) bitOr:b2
+    ].
+    ^ (b2 bitShift:8) bitOr:b1
+
+    "Modified: 11.7.1996 / 10:07:20 / cg"
+!
+
+nextUnsignedInt16Net
+    "return an unsigned short (2 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes.
+     Network byte order is MSB per definition"
+
+    ^ self nextUnsignedInt16MSB:true
+
+    "Created: 10.1.1996 / 19:50:02 / cg"
+!
+
+nextUnsignedInt32MSB:msbFlag
+    "return an unsigned long (4 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |b1 b2 b3 b4 val|
+
+    b1 := self nextByte.
+    b2 := self nextByte.
+    b3 := self nextByte.
+    b4 := self nextByte.
+
+    msbFlag ifTrue:[
+        val := b1.
+        val := (val bitShift:8) bitOr:b2.
+        val := (val bitShift:8) bitOr:b3.
+        val := (val * 256) + b4.
+        ^ val
+    ].
+    val := b4.
+    val := (val bitShift:8) bitOr:b3.
+    val := (val bitShift:8) bitOr:b2.
+    val := (val * 256) + b1.
+    ^ val
+
+    "Modified: 11.7.1996 / 10:07:13 / cg"
+!
+
+nextUnsignedInt32Net
+    "return an unsigned long (4 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes."
+
+    ^ self nextUnsignedInt32MSB:true
+
+    "Created: 10.1.1996 / 19:49:02 / cg"
+    "Modified: 10.1.1996 / 19:49:50 / cg"
+!
+
+nextUnsignedInt64MSB:msbFlag
+    "return an unsigned hyper (8 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |bytes uval t|
+
+    bytes := self nextBytes:8.
+    uval := 0.
+
+    msbFlag ifTrue:[
+        "most significant first"
+        1 to:8 do:[:i |
+            t := (uval bitShift:8).
+            uval := t bitOr:(bytes at:i).
+        ].
+    ] ifFalse:[
+        "least significant first"
+        8 to:1 by:-1 do:[:i |
+            t := (uval bitShift:8).
+            uval := t bitOr:(bytes at:i).
+        ].
+    ].
+    ^ uval
+
+    "
+     |bytes s|
+
+     bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF].
+     s := bytes readStream.
+     Transcript showCR:(s nextUnsignedInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString.
+
+     bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00].
+     s := bytes readStream.
+     Transcript showCR:(s nextUnsignedInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString.
+
+     bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0].
+     s := bytes readStream.
+     Transcript showCR:(s nextUnsignedInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString.
+
+     bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10].
+     s := bytes readStream.
+     Transcript showCR:(s nextUnsignedInt64MSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextUnsignedInt64MSB:false) hexPrintString.
+    "
+
+    "Modified: / 14.1.1998 / 15:40:41 / cg"
+!
+
+nextUnsignedInt64Net
+    "return an unsigned longlong (8 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes."
+
+    ^ self nextUnsignedInt64MSB:true
+! !
+
+!Stream methodsFor:'non homogenous reading - obsolete'!
+
+nextHyperMSB:msbFlag
+    "return a signed hyper (8 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextInt64MSB:msbFlag
+
+    "
+     |bytes s|
+
+     bytes := #[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF].
+     s := bytes readStream.
+     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
+
+     bytes := #[16r10 16r00 16r00 16r00 16r00 16r00 16r00 16r00].
+     s := bytes readStream.
+     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
+
+     bytes := #[16r12 16r34 16r56 16r78 16r9a 16rbc 16rde 16rf0].
+     s := bytes readStream.
+     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
+
+     bytes := #[16rFe 16rdc 16rba 16r98 16r76 16r54 16r32 16r10].
+     s := bytes readStream.
+     Transcript showCR:(s nextHyperMSB:true) hexPrintString.
+     s reset.
+     Transcript showCR:(s nextHyperMSB:false) hexPrintString.
+    "
+
+    "Modified: / 14.1.1998 / 15:40:41 / cg"
+!
+
+nextLongMSB:msbFlag
+    "return a signed long (4 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextInt32MSB:msbFlag
+
+    "
+     |bytes s|
+
+     bytes := #[16rFF 16rFF 16rFF 16rFF].
+     s := bytes readStream.
+     Transcript showCR:(s nextLongMSB:true).
+     s reset.
+     Transcript showCR:(s nextLongMSB:false).
+
+     bytes := #[16r12 16r34 16r56 16r78].
+     s := bytes readStream.
+     Transcript showCR:(s nextLongMSB:true).
+     s reset.
+     Transcript showCR:(s nextLongMSB:false).
+
+     bytes := #[16r89 16rab 16rcd 16ref].
+     s := bytes readStream.
+     Transcript showCR:(s nextLongMSB:true).
+     s reset.
+     Transcript showCR:(s nextLongMSB:false).
+    "
+
+    "Modified: / 14.1.1998 / 15:40:41 / cg"
+!
+
+nextLongNet
+    "return a signed long (4 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes."
+
+    ^ self nextInt32MSB:true
+
+    "Created: 10.1.1996 / 19:49:28 / cg"
+!
+
+nextShortMSB:msbFlag
+    "return a signed short (2 bytes) from the stream.
+     The receiver must support reading of binary bytes.
+
+     The msbFlag argument controls if the integer is to be read with
+     most-significant-byte-first (true) or least-first (false).
+     This interface is provided to allow talking to external programs,
+     where it's known that the byte order is some definite one.
+     If you don't care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextInt16MSB:msbFlag
+
+    "Modified: 11.7.1996 / 10:07:04 / cg"
+!
+
+nextShortNet
+    "return a signed short (2 bytes) in network byte order from the stream.
+     The receiver must support reading of binary bytes.
+     Network byte order is MSB per definition"
+
+    ^ self nextInt16MSB:true
+
+    "Created: 10.1.1996 / 19:49:41 / cg"
+!
+
 nextUnsignedLongMSB:msbFlag
     "return an unsigned long (4 bytes) from the stream.
      The receiver must support reading of binary bytes.
@@ -1378,16 +1691,6 @@
 
 !Stream methodsFor:'non homogenous writing'!
 
-nextLongPut:aNumber
-    "for ST-80 compatibility:
-     Write the argument, aNumber as a long (four bytes). 
-     The most significant byte is sent first."
-
-    ^ self nextPutLong:aNumber MSB:true
-
-    "Modified: 10.1.1996 / 19:38:54 / cg"
-!
-
 nextNumber:n put:v 
     "Append to the receiver the argument, v, which is a positive Integer,
      as the next n bytes. Bytes are written msb first. 
@@ -1564,71 +1867,6 @@
     "Created: 22.4.1997 / 10:44:18 / cg"
 !
 
-nextPutHyper:aNumber MSB:msbFlag
-    "Write the argument, aNumber as a hyper (8 bytes). 
-     If msbFlag is true, data is written most-significant byte first; 
-     otherwise least first. 
-     Returns the receiver on ok, nil on error.
-     The receiver must support writing of binary bytes.
-
-     This interface is provided to allow talking to external programs,
-     where its known that the byte order is some definite one.
-     If you dont care (i.e. talk to other smalltalks) or you can control the
-     order, please use the corresponding xxxNet methods, which use a standard
-     network byte order."
-
-    msbFlag ifTrue:[
-        1 to:8 do:[:i |
-            self nextPutByte:(aNumber digitByteAt:8+1-i)
-        ].
-    ] ifFalse:[
-        1 to:8 do:[:i |
-            self nextPutByte:(aNumber digitByteAt:i)
-        ].
-    ].
-
-    "
-     |s bytes|
-
-     s := #[] writeStream.
-     s nextPutHyper:16r123456789abcdef0 MSB:false.
-     bytes := s contents.
-     s := bytes readStream.
-     (s nextHyperMSB:false) hexPrintString.   
-    "
-    "
-     |s bytes|
-
-     s := #[] writeStream.
-     s nextPutHyper:16r123456789abcdef0 MSB:true.
-     bytes := s contents.
-     s := bytes readStream.
-     (s nextHyperMSB:true) hexPrintString.   
-.
-    "
-    "
-     |s bytes|
-
-     s := #[] writeStream.
-     s nextPutHyper:16r-8000000000000000 MSB:true.
-     bytes := s contents.
-     s := bytes readStream.
-     (s nextHyperMSB:true) hexPrintString.    
-    "
-    "
-     |s bytes|
-
-     s := #[] writeStream.
-     s nextPutHyper:16r-8000000000000000 MSB:false.
-     bytes := s contents.
-     s := bytes readStream.
-     (s nextHyperMSB:false) hexPrintString.   
-    "
-
-    "Modified: / 01-11-1997 / 18:30:52 / cg"
-    "Modified: / 22-06-2006 / 11:31:37 / fm"
-!
-
 nextPutIEEEDouble:aFloat
     "write an 8-byte IEEE double precision float number"
 
@@ -1653,7 +1891,66 @@
     ShortFloat storeBinaryIEEESingle:aFloat on:self MSB:msb.
 !
 
-nextPutLong:aNumber MSB:msbFlag
+nextPutInt16:anIntegerOrCharacter MSB:msbFlag
+    "Write the argument, anIntegerOrCharacter as a short (two bytes). 
+     If msbFlag is true, data is written most-significant byte first; 
+     otherwise least first. 
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you don't care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    |iNum "{ Class: SmallInteger }" hi lo b1 b2|
+
+    iNum := anIntegerOrCharacter asInteger.
+    lo := iNum digitByteAt:1.
+    hi := iNum digitByteAt:2.
+    msbFlag ifTrue:[
+        "high word first"
+        b1 := hi.
+        b2 := lo.
+    ] ifFalse:[
+        "low word first"
+        b1 := lo.
+        b2 := hi.
+    ].
+    self nextPutByte:b1.
+    self nextPutByte:b2.
+
+    "
+     |s|
+
+     s := #[] writeStream.
+     s nextPutInt16:16r1234 MSB:false.
+     s contents.  
+    "
+    "
+     |s|
+
+     s := #[] writeStream.
+     s nextPutInt16:16r1234 MSB:true.
+     s contents.
+    "
+
+    "Modified: / 22-06-2006 / 11:30:26 / fm"
+!
+
+nextPutInt16Net:aNumber
+    "Write the argument, aNumber as a short (two bytes) in the network byte order.
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+     Network byte order is MSB per definition"
+
+    ^ self nextPutInt16:aNumber MSB:true.
+
+    "Created: 10.1.1996 / 19:50:33 / cg"
+!
+
+nextPutInt32:aNumber MSB:msbFlag
     "Write the argument, aNumber as a long (four bytes). 
      If msbFlag is true, data is written most-significant byte first; 
      otherwise least first. 
@@ -1694,57 +1991,54 @@
      |s bytes|
 
      s := #[] writeStream.
-     s nextPutLong:16r12345678 MSB:false.
+     s nextPutInt32:16r12345678 MSB:false.
      bytes := s contents.
      s := bytes readStream.
-     (s nextLongMSB:false) hexPrintString.   
+     (s nextInt32MSB:false) hexPrintString.   
     "
     "
      |s bytes|
 
      s := #[] writeStream.
-     s nextPutLong:16r12345678 MSB:true.
+     s nextPutInt32:16r12345678 MSB:true.
      bytes := s contents.
      s := bytes readStream.
-     (s nextLongMSB:true) hexPrintString.   
+     (s nextInt32MSB:true) hexPrintString.   
 .
     "
     "
      |s bytes|
 
      s := #[] writeStream.
-     s nextPutLong:16r-80000000 MSB:true.
+     s nextPutInt32:16r-80000000 MSB:true.
      bytes := s contents.
      s := bytes readStream.
-     (s nextLongMSB:true) hexPrintString.   
+     (s nextInt32MSB:true) hexPrintString.   
     "
     "
      |s bytes|
 
      s := #[] writeStream.
-     s nextPutLong:16r-80000000 MSB:false.
+     s nextPutInt32:16r-80000000 MSB:false.
      bytes := s contents.
      s := bytes readStream.
-     (s nextLongMSB:false) hexPrintString.   
+     (s nextInt32MSB:false) hexPrintString.   
     "
 
     "Modified: / 01-11-1997 / 18:30:52 / cg"
     "Modified: / 22-06-2006 / 11:31:43 / fm"
 !
 
-nextPutLongNet:aNumber
+nextPutInt32Net:aNumber
     "Write the argument, aNumber as a long (four bytes) in the network byte order.
      Returns the receiver on ok, nil on error.
      The receiver must support writing of binary bytes."
 
-    ^ self nextPutLong:aNumber MSB:true
-
-    "Modified: 10.1.1996 / 19:47:10 / cg"
-    "Created: 10.1.1996 / 19:50:23 / cg"
+    ^ self nextPutInt32:aNumber MSB:true
 !
 
-nextPutShort:anIntegerOrCharacter MSB:msbFlag
-    "Write the argument, anIntegerOrCharacter as a short (two bytes). 
+nextPutInt64:aNumber MSB:msbFlag
+    "Write the argument, aNumber as a longlong (8 bytes). 
      If msbFlag is true, data is written most-significant byte first; 
      otherwise least first. 
      Returns the receiver on ok, nil on error.
@@ -1756,50 +2050,127 @@
      order, please use the corresponding xxxNet methods, which use a standard
      network byte order."
 
-    |iNum "{ Class: SmallInteger }" hi lo b1 b2|
-
-    iNum := anIntegerOrCharacter asInteger.
-    lo := iNum digitByteAt:1.
-    hi := iNum digitByteAt:2.
     msbFlag ifTrue:[
-        "high word first"
-        b1 := hi.
-        b2 := lo.
+        1 to:8 do:[:i |
+            self nextPutByte:(aNumber digitByteAt:8+1-i)
+        ].
     ] ifFalse:[
-        "low word first"
-        b1 := lo.
-        b2 := hi.
+        1 to:8 do:[:i |
+            self nextPutByte:(aNumber digitByteAt:i)
+        ].
     ].
-    self nextPutByte:b1.
-    self nextPutByte:b2.
 
     "
-     |s|
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r123456789abcdef0 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:false) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r123456789abcdef0 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:true) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r-8000000000000000 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:true) hexPrintString.    
+    "
+    "
+     |s bytes|
 
      s := #[] writeStream.
-     s nextPutShort:16r1234 MSB:false.
-     s contents.  
+     s nextPutUInt64:16r-8000000000000000 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:false) hexPrintString.   
     "
+
+    "Modified: / 01-11-1997 / 18:30:52 / cg"
+    "Modified: / 22-06-2006 / 11:31:37 / fm"
+!
+
+nextPutInt64Net:aNumber
+    "Write the argument, aNumber as a longlong (8 bytes) in the network byte order.
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes."
+
+    ^ self nextPutInt64:aNumber MSB:true
+!
+
+nextPutUInt64:aNumber MSB:msbFlag
+    "Write the argument, aNumber as a hyper (8 bytes). 
+     If msbFlag is true, data is written most-significant byte first; 
+     otherwise least first. 
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you don't care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    msbFlag ifTrue:[
+        1 to:8 do:[:i |
+            self nextPutByte:(aNumber digitByteAt:8+1-i)
+        ].
+    ] ifFalse:[
+        1 to:8 do:[:i |
+            self nextPutByte:(aNumber digitByteAt:i)
+        ].
+    ].
+
     "
-     |s|
+     |s bytes|
 
      s := #[] writeStream.
-     s nextPutShort:16r1234 MSB:true.
-     s contents.
+     s nextPutUInt64:16r123456789abcdef0 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:false) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r123456789abcdef0 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:true) hexPrintString.   
+    "
     "
-
-    "Modified: / 22-06-2006 / 11:30:26 / fm"
-!
-
-nextPutShortNet:aNumber
-    "Write the argument, aNumber as a short (two bytes) in the network byte order.
-     Returns the receiver on ok, nil on error.
-     The receiver must support writing of binary bytes.
-     Network byte order is MSB per definition"
-
-    ^ self nextPutShort:aNumber MSB:true.
-
-    "Created: 10.1.1996 / 19:50:33 / cg"
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r-8000000000000000 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:true) hexPrintString.    
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutUInt64:16r-8000000000000000 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextUInt64MSB:false) hexPrintString.   
+    "
+
+    "Modified: / 01-11-1997 / 18:30:52 / cg"
+    "Modified: / 22-06-2006 / 11:31:37 / fm"
 !
 
 nextPutUtf16:aCharacter
@@ -1900,40 +2271,177 @@
             asByteArray
             
     "
-!
-
-nextPutWord:aNumber
-    "write the argument, aNumber as a signed short (two bytes);
-     write msb-first for compatibility with other smalltalks.
+! !
+
+!Stream methodsFor:'non homogenous writing - obsolete'!
+
+nextPutHyper:aNumber MSB:msbFlag
+    "Write the argument, aNumber as a hyper (8 bytes). 
+     If msbFlag is true, data is written most-significant byte first; 
+     otherwise least first. 
+     Returns the receiver on ok, nil on error.
      The receiver must support writing of binary bytes.
-     I dont know if it should be named nextPutWord: or nextWordPut:;
-     one of them will vanish ..."
-
-    ^ self nextPutShort:aNumber MSB:true
+
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextPutInt64:aNumber MSB:msbFlag
+
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutHyper:16r123456789abcdef0 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextHyperMSB:false) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutHyper:16r123456789abcdef0 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextHyperMSB:true) hexPrintString.   
+.
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutHyper:16r-8000000000000000 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextHyperMSB:true) hexPrintString.    
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutHyper:16r-8000000000000000 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextHyperMSB:false) hexPrintString.   
+    "
+
+    "Modified: / 01-11-1997 / 18:30:52 / cg"
+    "Modified: / 22-06-2006 / 11:31:37 / fm"
 !
 
-nextTwoBytesPut: anInteger
-        <resource: #obsolete>
-        "Write anInteger as the next two bytes of the
-         receiver stream."
-
-    self obsoleteMethodWarning:'use #nextPutShort:MSB:'.
-
-    self
-        nextPutByte: (anInteger bitAnd: 255);
-        nextPutByte: ((anInteger bitShift: -8) bitAnd: 255)
-
-    "Created: / 21-06-2006 / 19:42:10 / fm"
+nextPutLong:aNumber MSB:msbFlag
+    "Write the argument, aNumber as a long (four bytes). 
+     If msbFlag is true, data is written most-significant byte first; 
+     otherwise least first. 
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you dont care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextPutInt32:aNumber MSB:msbFlag
+
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutLong:16r12345678 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextLongMSB:false) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutLong:16r12345678 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextLongMSB:true) hexPrintString.   
+.
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutLong:16r-80000000 MSB:true.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextLongMSB:true) hexPrintString.   
+    "
+    "
+     |s bytes|
+
+     s := #[] writeStream.
+     s nextPutLong:16r-80000000 MSB:false.
+     bytes := s contents.
+     s := bytes readStream.
+     (s nextLongMSB:false) hexPrintString.   
+    "
+
+    "Modified: / 01-11-1997 / 18:30:52 / cg"
+    "Modified: / 22-06-2006 / 11:31:43 / fm"
 !
 
-nextWordPut:aNumber
-    "for ST-80 compatibility:
-     Write the argument, aNumber as a short (two bytes). 
-     The most significant byte is sent first."
-
-    ^ self nextPutShort:aNumber MSB:true
-
-    "Modified: 10.1.1996 / 19:39:19 / cg"
+nextPutLongNet:aNumber
+    "Write the argument, aNumber as a long (four bytes) in the network byte order.
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes."
+
+    ^ self nextPutInt32:aNumber MSB:true
+
+    "Modified: 10.1.1996 / 19:47:10 / cg"
+    "Created: 10.1.1996 / 19:50:23 / cg"
+!
+
+nextPutShort:anIntegerOrCharacter MSB:msbFlag
+    "Write the argument, anIntegerOrCharacter as a short (two bytes). 
+     If msbFlag is true, data is written most-significant byte first; 
+     otherwise least first. 
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+
+     This interface is provided to allow talking to external programs,
+     where its known that the byte order is some definite one.
+     If you don't care (i.e. talk to other smalltalks) or you can control the
+     order, please use the corresponding xxxNet methods, which use a standard
+     network byte order."
+
+    ^ self nextPutInt16:anIntegerOrCharacter MSB:true
+
+    "
+     |s|
+
+     s := #[] writeStream.
+     s nextPutShort:16r1234 MSB:false.
+     s contents.  
+    "
+    "
+     |s|
+
+     s := #[] writeStream.
+     s nextPutShort:16r1234 MSB:true.
+     s contents.
+    "
+
+    "Modified: / 22-06-2006 / 11:30:26 / fm"
+!
+
+nextPutShortNet:aNumber
+    "Write the argument, aNumber as a short (two bytes) in the network byte order.
+     Returns the receiver on ok, nil on error.
+     The receiver must support writing of binary bytes.
+     Network byte order is MSB per definition"
+
+    ^ self nextPutInt16:aNumber MSB:true.
+
+    "Created: 10.1.1996 / 19:50:33 / cg"
 ! !
 
 !Stream methodsFor:'open / close'!