UninterpretedBytes.st
author Claus Gittinger <cg@exept.de>
Wed, 03 Mar 1999 16:11:12 +0100
changeset 4019 c9284ca27a4a
parent 3936 dd8cd28d4a9b
child 4275 9fc4a735a1d3
permissions -rw-r--r--
tuned some doubleWordAt methods; eliminated duplicate code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
300
fe1f742a9224 *** empty log message ***
claus
parents: 95
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    13
ArrayedCollection subclass:#UninterpretedBytes
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    14
	instanceVariableNames:''
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
    15
	classVariableNames:'IsBigEndian'
1266
cef9b3cd49df commentary
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
    16
	poolDictionaries:''
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    17
	category:'Collections-Abstract'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    18
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    20
!UninterpretedBytes primitiveDefinitions!
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    21
%{
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    22
/*
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    23
 * Notice: I am abstract, and my subclasses may be anything.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    24
 * Therefore, the code must always handle the fallback case
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    25
 * where the receiver is neither an ExternalBytes nor a ByteArray.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    26
 * (which are, however, the most common)
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    27
 *
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    28
 * macro to fetch my byte address and size-in-bytes;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    29
 * convenient for inline-C code.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    30
 * (yes, C is bad ...)
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    31
 */
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    32
#define __fetchBytePointerAndSize__(o, pPtr, pSize) \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    33
    {\
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    34
      if (__isNonNilObject(o)) { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    35
        if (__qClass(o) == ByteArray) { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    36
	  *(pPtr) = (char *)__ByteArrayInstPtr(o)->ba_element; \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    37
	  *(pSize) = __byteArraySize(o); \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    38
	} else if (__qClass(o) == ExternalBytes) { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    39
	  OBJ __sz__ = __externalBytesSize(o); \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    40
	  if (__isSmallInteger(__sz__)) { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    41
	    *(pSize) = __intVal(__sz__); \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    42
	    *(pPtr) = (char *)(__externalBytesAddress(o)); \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    43
	  } else { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    44
	    *(pPtr) = (char *)0; \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    45
	  } \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    46
	} else { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    47
	    *(pPtr) = (char *)0; \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    48
	} \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    49
      } else { \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    50
	*(pPtr) = (char *)0; \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    51
      } \
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    52
    }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    53
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    54
%}
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    55
! !
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    56
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    57
!UninterpretedBytes class methodsFor:'documentation'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    58
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    59
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    60
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    61
 COPYRIGHT (c) 1993 by Claus Gittinger
300
fe1f742a9224 *** empty log message ***
claus
parents: 95
diff changeset
    62
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    63
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    64
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    65
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    66
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    67
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    68
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    69
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    70
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    71
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    72
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    73
documentation
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    74
"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    75
    UninterpretedBytes provides the common protocol for byte-storage 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    76
    containers; concrete subclasses are 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    77
	ByteArray (which store the bytes within the
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    78
    		   Smalltalk object memory) 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    79
    and 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    80
	ExternalBytes (which store the bytes in the malloc-heap).
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    81
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    82
    UninterpretedBytes itself is abstract, so no instances of it can be created.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    83
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    84
    [See also:]
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
    85
        ByteArray String ExternalBytes
1294
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    86
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    87
    [author:]
e26bbb61f6b2 documentation
Claus Gittinger <cg@exept.de>
parents: 1266
diff changeset
    88
        Claus Gittinger
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    89
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    90
    [Notice:]
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    91
	Notice the confusion due to multiple methods with the same
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    92
        functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:').
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    93
        The reason is that at the time this class was written,
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    94
        ST80 sid not offer protocol to specify the byteOrder, and
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    95
        ST/X provided methods ending in 'MSB:' for this.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    96
        In the meanwhile, VW added protocol ending in 'bigEndian:',
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    97
	which has been added here for compatibility.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
    98
	(certainly a point, where an ansi-standard will help)
68
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
    99
"
59faa75185ba *** empty log message ***
claus
parents: 63
diff changeset
   100
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   101
3363
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   102
!UninterpretedBytes class methodsFor:'instance creation'!
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   103
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   104
from:aCollection
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   105
    ^ ByteArray from:aCollection
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   106
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   107
    "Created: / 3.4.1998 / 13:29:50 / cg"
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   108
    "Modified: / 3.4.1998 / 13:30:12 / cg"
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   109
! !
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
   110
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   111
!UninterpretedBytes class methodsFor:'queries'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   112
a27a279701f8 Initial revision
claus
parents:
diff changeset
   113
isBigEndian
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   114
    "return true, if words/shorts store the most-significant
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   115
     byte first (MSB), false if least-sign.-first (LSB). 
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   116
     I.e. false for vax, intel; true for m68k, sun.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   117
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   118
     Notice: UninterpretedBytes isBigEndian
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   119
             this is inlined both by stc and the jit compiler"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   120
a27a279701f8 Initial revision
claus
parents:
diff changeset
   121
%{  /* NOCONTEXT */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   122
3936
dd8cd28d4a9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
   123
#ifdef __MSBFIRST
dd8cd28d4a9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
   124
    RETURN (true);
dd8cd28d4a9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
   125
#else
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   126
    /*
a27a279701f8 Initial revision
claus
parents:
diff changeset
   127
     * I dont like ifdefs - you always forget some ...
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   128
     * therefore we look into a structure at run-time.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   129
     * (also, there are CPUs around [mips], where the byteorder
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   130
     *  is programmable, and which come in different flavours)
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   131
     *
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   132
     * NOTICE: 
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   133
     *    both the JIT and stc may inline this to a 
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   134
     *    constant for systems where this is known.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   135
     */
a27a279701f8 Initial revision
claus
parents:
diff changeset
   136
    union {
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   137
        unsigned int   u_l;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   138
        char           u_c[sizeof(int)];
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   139
    } u;
a27a279701f8 Initial revision
claus
parents:
diff changeset
   140
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
    u.u_l = 0x87654321;
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   142
    if (u.u_c[0] == 0x21) RETURN (false);
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
   143
    RETURN (true);
3936
dd8cd28d4a9b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3459
diff changeset
   144
#endif
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   145
%}
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   146
    "
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   147
     UninterpretedBytes isBigEndian
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   148
    "
3209
eff7ad7f0825 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3207
diff changeset
   149
!
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   150
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   151
isBuiltInClass
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   152
    "return true if this class is known by the run-time-system.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   153
     Here, true is returned, since UninterpretedBytes is the superclass of
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   154
     some builtIn classes (ByteArray & ExternalBytes)"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   155
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   156
    ^ self == UninterpretedBytes
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   157
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   158
    "Modified: / 23.4.1996 / 15:56:25 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   159
    "Modified: / 5.3.1998 / 14:56:22 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   160
! !
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   161
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   162
!UninterpretedBytes methodsFor:'accessing-bytes'!
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   163
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   164
byteAt:index
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   165
    "return the byte at index. 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   166
     For ByteArray, this is the same as basicAt:; 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   167
     however, for strings or symbols, this returns a numeric byteValue
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   168
     instead of a character."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   169
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   170
    ^ self subclassResponsibility
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   171
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   172
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   173
byteAt:index put:value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   174
    "set the byte at index. For ByteArray, this is the same as basicAt:put:.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   175
     However, for Strings, this expects a byteValue to be stored."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   176
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   177
    ^ self subclassResponsibility
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   178
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   179
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   180
signedByteAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   181
    "return the byte at index as a signed 8 bit value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   182
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   183
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   184
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   185
    ^ (self at:index) signExtendedByteValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   186
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   187
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   188
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   189
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   190
     b at:1 put:16rFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   191
     b at:2 put:16r7F.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   192
     b signedByteAt:1  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   193
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   194
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   195
    "Modified: 1.7.1996 / 21:13:53 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   196
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   197
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   198
signedByteAt:index put:aSignedByteValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   199
    "return the byte at index as a signed 8 bit value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   200
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   201
     Return the signedByteValue argument.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   202
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   203
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   204
    |b "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   205
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   206
    aSignedByteValue >= 0 ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   207
	b := aSignedByteValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   208
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   209
	b := 16r100 + aSignedByteValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   210
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   211
    self at:index put:b.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   212
    ^ aSignedByteValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   213
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   214
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   215
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   216
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   217
     b signedByteAt:1 put:-1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   218
     b at:1   
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   219
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   220
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   221
    "Modified: 1.7.1996 / 21:12:37 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   222
! !
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   223
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   224
!UninterpretedBytes methodsFor:'accessing-floats & doubles'!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   225
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   226
doubleAt:index
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   227
    "return the 8-bytes starting at index as a Float.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   228
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   229
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   230
     Notice also, that the bytes are expected to be in this machines
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   231
     float representation - if the bytearray originated from another
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   232
     machine, some conversion is usually needed."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   233
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   234
    |newFloat|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   235
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   236
%{
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   237
    /*
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   238
     * handle the most common cases fast ...
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   239
     */
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   240
    if (__isSmallInteger(index)) {
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   241
	char *cp;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   242
	int sz;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   243
	
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   244
	__fetchBytePointerAndSize__(self, &cp, &sz);
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   245
        if (cp) {
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   246
	    unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   247
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   248
	    if ((idx+(sizeof(double)-1)) < sz) {
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   249
		cp += idx;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   250
		/*
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   251
		 * aligned
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   252
		 */
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   253
		if (((INT)cp & (sizeof(double)-1)) == 0) {
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   254
		    double dVal = ((double *)cp)[0];
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   255
		    OBJ f;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   256
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   257
		    __qMKFLOAT(f, dVal);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   258
                    RETURN (f);
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   259
		}
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   260
	    }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   261
	}
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   262
    }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   263
%}.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   264
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   265
    newFloat := Float basicNew.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   266
    1 to:8 do:[:destIndex|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   267
	newFloat basicAt:destIndex put:(self at:index - 1 + destIndex)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   268
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   269
    ^ newFloat.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   270
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   271
    "
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   272
     |b|
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   273
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   274
     b := ByteArray new:20.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   275
     b doubleAt:1 put:(Float pi).
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   276
     Transcript showCR:b.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   277
     Transcript showCR:(b doubleAt:1)
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   278
    "
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   279
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   280
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   281
doubleAt:index MSB:msb
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   282
    "return the 8-bytes starting at index as a Float.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   283
     The index is a smalltalk index (i.e. 1-based).
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   284
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   285
     Notice also, that the bytes are expected to be in this machines
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   286
     float representation - if the bytearray originated from another
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   287
     machine, some conversion is usually needed."
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   288
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   289
    |newFloat|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   290
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   291
    msb == UninterpretedBytes isBigEndian ifTrue:[
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   292
        ^ self doubleAt:index.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   293
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   294
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   295
    newFloat := Float basicNew.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   296
    1 to:8 do:[:destIndex|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   297
        newFloat basicAt:(9-destIndex) put:(self at:index - 1 + destIndex)
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   298
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   299
    ^ newFloat.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   300
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   301
    "Created: / 15.5.1998 / 17:21:45 / cg"
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   302
!
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   303
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   304
doubleAt:index put:aFloat
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   305
    "store the value of the argument, aFloat into the receiver
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   306
     starting at index.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   307
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   308
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   309
     Notice also, that the bytes are expected to be in this machines
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   310
     float representation - if the bytearray originated from another
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   311
     machine, some conversion is usually needed."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   312
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   313
    |flt|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   314
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   315
    flt := aFloat asFloat.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   316
%{
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   317
    /*
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   318
     * handle the most common cases fast ...
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   319
     */
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   320
    if (__isSmallInteger(index) && __isFloat(flt)) {
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   321
        char *cp;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   322
        int sz;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   323
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   324
        __fetchBytePointerAndSize__(self, &cp, &sz);
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   325
        if (cp) {
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   326
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   327
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   328
            if ((idx+(sizeof(double)-1)) < sz) {
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   329
                cp += idx;
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   330
                /*
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   331
                 * aligned
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   332
                 */
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   333
                if (((INT)cp & (sizeof(double)-1)) == 0) {
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   334
                    ((double *)cp)[0] = __floatVal(flt);
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   335
                    RETURN (aFloat);
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   336
                }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   337
            }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   338
        }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   339
    }
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   340
%}.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   341
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   342
    1 to:8 do:[:srcIndex|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   343
        self at:index - 1 + srcIndex put:(flt basicAt:srcIndex)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   344
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   345
    ^ aFloat
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   346
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   347
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   348
doubleAt:index put:aFloat MSB:msb
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   349
    "store the value of the argument, aFloat into the receiver
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   350
     starting at index.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   351
     The index is a smalltalk index (i.e. 1-based).
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   352
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   353
     Notice also, that the bytes are expected to be in this machines
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   354
     float representation - if the bytearray originated from another
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   355
     machine, some conversion is usually needed."
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   356
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   357
    |flt|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   358
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   359
    msb == UninterpretedBytes isBigEndian ifTrue:[
3447
Claus Gittinger <cg@exept.de>
parents: 3446
diff changeset
   360
        ^ self doubleAt:index put:aFloat.
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   361
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   362
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   363
    flt := aFloat asFloat.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   364
    1 to:8 do:[:srcIndex|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   365
        self at:index - 1 + srcIndex put:(flt basicAt:(9-srcIndex))
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   366
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   367
    ^ aFloat
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   368
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   369
    "Created: / 15.5.1998 / 17:22:27 / cg"
3447
Claus Gittinger <cg@exept.de>
parents: 3446
diff changeset
   370
    "Modified: / 15.5.1998 / 17:26:29 / cg"
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   371
!
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   372
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   373
floatAt:index
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   374
    "return the 4-bytes starting at index as a ShortFloat.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   375
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   376
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80;
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   377
     therefore this method reads a 4-byte float from the byteArray and returns
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   378
     a float object which keeps an 8-byte double internally.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   379
     Notice also, that the bytes are expected to be in this machines
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   380
     float representation and order - if the bytearray originated from another
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   381
     machine, some conversion is usually needed."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   382
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   383
    |newFloat|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   384
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   385
%{
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   386
    /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   387
     * handle the most common cases fast ...
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   388
     */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   389
    if (__isSmallInteger(index)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   390
        char *cp;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   391
        int sz;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   392
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   393
        __fetchBytePointerAndSize__(self, &cp, &sz);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   394
        if (cp) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   395
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   396
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   397
            if ((idx+(sizeof(float)-1)) < sz) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   398
                cp += idx;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   399
                /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   400
                 * aligned
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   401
                 */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   402
                if (((INT)cp & (sizeof(float)-1)) == 0) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   403
                    float fVal = ((float *)cp)[0];
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   404
		    OBJ f;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   405
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   406
		    __qMKSFLOAT(f, fVal);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   407
                    RETURN (f);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   408
                }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   409
            }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   410
        }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   411
    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   412
%}.
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   413
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   414
    newFloat := ShortFloat basicNew.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   415
    1 to:4 do:[:destIndex|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   416
        newFloat basicAt:destIndex put:(self at:index - 1 + destIndex)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   417
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   418
    ^ newFloat.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   419
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   420
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   421
floatAt:index MSB:msb
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   422
    "return the 4-bytes starting at index as a ShortFloat.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   423
     The index is a smalltalk index (i.e. 1-based).
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   424
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80;
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   425
     therefore this method reads a 4-byte float from the byteArray and returns
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   426
     a float object which keeps an 8-byte double internally.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   427
     Notice also, that the bytes are expected to be in this machines
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   428
     float representation and order - if the bytearray originated from another
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   429
     machine, some conversion is usually needed."
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   430
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   431
    |newFloat|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   432
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   433
    msb == UninterpretedBytes isBigEndian ifTrue:[
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   434
        ^ self floatAt:index
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   435
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   436
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   437
    newFloat := ShortFloat basicNew.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   438
    1 to:4 do:[:destIndex|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   439
        newFloat basicAt:(5-destIndex) put:(self at:index - 1 + destIndex)
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   440
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   441
    ^ newFloat.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   442
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   443
    "Modified: / 15.5.1998 / 17:20:19 / cg"
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   444
    "Created: / 15.5.1998 / 17:20:35 / cg"
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   445
!
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   446
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   447
floatAt:index put:aFloat
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   448
    "store the 4 bytes of value of the argument, aFloat into the receiver
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   449
     starting at index.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   450
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   451
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   452
     Notice also, that the bytes are expected to be in this machines
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   453
     float representation - if the bytearray originated from another
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   454
     machine, some conversion is usually needed."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   455
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   456
    |sflt|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   457
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   458
    sflt := aFloat asShortFloat.
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   459
%{
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   460
    /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   461
     * handle the most common cases fast ...
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   462
     */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   463
    if (__isSmallInteger(index) && __isShortFloat(sflt)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   464
        char *cp;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   465
        int sz;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   466
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   467
        __fetchBytePointerAndSize__(self, &cp, &sz);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   468
        if (cp) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   469
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   470
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   471
            if ((idx+(sizeof(float)-1)) < sz) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   472
                cp += idx;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   473
                /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   474
                 * aligned
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   475
                 */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   476
                if (((INT)cp & (sizeof(float)-1)) == 0) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   477
                    ((float *)cp)[0] = __shortFloatVal(sflt);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   478
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   479
                    RETURN (aFloat);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   480
                }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   481
            }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   482
        }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   483
    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   484
%}.
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
   485
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   486
    1 to:4 do:[:srcIndex|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   487
        self at:index - 1 + srcIndex put:(sflt basicAt:srcIndex)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   488
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   489
    ^ aFloat
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   490
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   491
3446
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   492
floatAt:index put:aFloat MSB:msb
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   493
    "store the 4 bytes of value of the argument, aFloat into the receiver
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   494
     starting at index.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   495
     The index is a smalltalk index (i.e. 1-based).
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   496
     Notice, that (currently) ST/X Floats are what Doubles are in ST-80.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   497
     Notice also, that the bytes are expected to be in this machines
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   498
     float representation - if the bytearray originated from another
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   499
     machine, some conversion is usually needed."
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   500
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   501
    |sflt|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   502
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   503
    msb == UninterpretedBytes isBigEndian ifTrue:[
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   504
        ^ self floatAt:index put:aFloat
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   505
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   506
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   507
    sflt := aFloat asShortFloat.
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   508
    1 to:4 do:[:srcIndex|
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   509
        self at:index - 1 + srcIndex put:(sflt basicAt:(5-srcIndex))
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   510
    ].
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   511
    ^ aFloat
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   512
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   513
    "Created: / 15.5.1998 / 17:20:41 / cg"
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   514
!
1a8c314b5d7d added #floatAt:MSB: , #floatAt:put:MSB: , #doubleAt:MSB: and #doubleAt:put:MSB:
Claus Gittinger <cg@exept.de>
parents: 3444
diff changeset
   515
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   516
ieeeDoubleAt:index
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   517
    "retrieve the 8 bytes starting at index as a float.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   518
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   519
     The 8 bytes are assumed to be in IEEE floating point single precision
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   520
     number format."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   521
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   522
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   523
     currently, we assume that the machines native number format is already
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   524
     IEEE format - we need some more code here whenever ST/X is ported
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   525
     to an IBM 370 or old VAX etc.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   526
     To date, all supported systems use IEEE float numbers, so there should be
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   527
     no problem.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   528
    "
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   529
    self isIEEEFormat ifFalse:[self error:'unsupported operation'].
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   530
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   531
    ^ self doubleAt:index
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   532
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   533
    "Created: / 5.3.1998 / 10:50:03 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   534
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   535
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   536
ieeeDoubleAt:index put:aFloat
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   537
    "store the value of the argument, aFloat into the receiver
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   538
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   539
     starting at index. Storage is in IEEE floating point double precision format.
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   540
     (i.e. 8 bytes are stored)."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   541
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   542
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   543
     currently, we assume that the machines native number format is already
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   544
     IEEE format - we need some more code here whenever ST/X is ported
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   545
     to an IBM 370 or old VAX etc.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   546
     To date, all supported systems use IEEE float numbers, so there should be
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   547
     no problem.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   548
    "
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   549
    self isIEEEFormat ifFalse:[self error:'unsupported operation'].
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   550
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   551
    ^ self doubleAt:index put:aFloat
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   552
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   553
    "Created: / 5.3.1998 / 10:50:26 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   554
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   555
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   556
ieeeFloatAt:index
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   557
    "retrieve the 4 bytes starting at index as a float.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   558
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   559
     The 4 bytes are assumed to be in IEEE floating point single precision
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   560
     number format."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   561
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   562
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   563
     currently, we assume that the machines native number format is already
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   564
     IEEE format - we need some more code here whenever ST/X is ported
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   565
     to an IBM 370 or old VAX etc.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   566
     To date, all supported systems use IEEE float numbers, so there should be
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   567
     no problem.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   568
    "
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   569
    self isIEEEFormat ifFalse:[self error:'unsupported operation'].
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   570
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   571
    ^ self floatAt:index
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   572
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   573
    "Created: / 5.3.1998 / 10:50:45 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   574
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   575
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   576
ieeeFloatAt:index put:aFloat
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   577
    "store the value of the argument, aFloat into the receiver
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   578
     starting at index, which is a smalltalk index (i.e. 1-based). 
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   579
     Storage is in IEEE floating point single precision format.
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   580
     (i.e. 4 bytes are stored). Since ST/X floats are really doubles, the low-
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   581
     order 4 bytes of the precision is lost."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   582
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   583
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   584
     currently, we assume that the machines native number format is already
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   585
     IEEE format - we need some more code here whenever ST/X is ported
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   586
     to an IBM 370 or old VAX etc.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   587
     To date, all supported systems use IEEE float numbers, so there should be
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   588
     no problem.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   589
    "
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   590
    self isIEEEFormat ifFalse:[self error:'unsupported operation'].
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
   591
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
   592
    ^ self floatAt:index put:aFloat
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   593
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
   594
    "Created: / 5.3.1998 / 10:51:11 / stefan"
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   595
! !
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   596
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   597
!UninterpretedBytes methodsFor:'accessing-longlongs'!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   598
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   599
longLongAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   600
    "return the 8-bytes starting at index as a signed Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   601
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   602
     The value is retrieved in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   603
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   604
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   605
    |w|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   606
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   607
    w := self unsignedLongLongAt:index bigEndian:(UninterpretedBytes isBigEndian).
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   608
    (w > (16r7FFFFFFFFFFFFFFF)) ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   609
        ^ w - (16r10000000000000000)
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   610
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   611
    ^ w
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   612
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   613
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   614
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   615
     b := ByteArray new:4.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   616
     b unsignedLongLongAt:1 put:16rFFFFFFFFFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   617
     (b longLongAt:1)    
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   618
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   619
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   620
    "Modified: / 1.7.1996 / 21:11:28 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   621
    "Created: / 5.3.1998 / 14:40:05 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   622
    "Modified: / 5.3.1998 / 14:58:32 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   623
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   624
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   625
longLongAt:index bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   626
    "return the 8-bytes starting at index as a signed Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   627
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   628
     The value is retrieved in the given byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   629
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   630
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   631
    |w|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   632
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   633
    w := self unsignedLongLongAt:index bigEndian:msb.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   634
    (w > (16r7FFFFFFFFFFFFFFF)) ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   635
        ^ w - (16r10000000000000000)
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   636
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   637
    ^ w
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   638
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   639
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   640
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   641
     b := ByteArray new:4.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   642
     b unsignedLongLongAt:1 put:16rFFFFFFFFFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   643
     (b longLongAt:1 msb:true)    
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   644
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   645
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   646
    "Modified: / 5.3.1998 / 12:06:28 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   647
    "Created: / 5.3.1998 / 14:40:54 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   648
    "Modified: / 9.5.1998 / 01:10:59 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   649
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   650
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   651
longLongAt:byteIndex put:anInteger
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   652
    "store a signed longLong (64bit) integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   653
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   654
     Same as #signedQuadWordAt:put: - for ST80 compatibility."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   655
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   656
    ^ self signedQuadWordAt:byteIndex put:anInteger
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   657
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   658
    "Modified: / 3.4.1998 / 13:33:14 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   659
    "Created: / 3.4.1998 / 13:34:22 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   660
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   661
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   662
longLongAt:byteIndex put:anInteger bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   663
    "store a signed longLong (64bit) integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   664
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   665
     Same as #signedQuadWordAt:put: - for ST80 compatibility."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   666
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   667
    |v|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   668
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   669
    v := anInteger.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   670
    anInteger < 0 ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   671
        v := v + 16r10000000000000000
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   672
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   673
    ^ self unsignedLongLongAt:byteIndex put:v bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   674
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   675
    "Created: / 9.5.1998 / 01:10:24 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   676
    "Modified: / 9.5.1998 / 01:13:34 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   677
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   678
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   679
quadWordAt:index MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   680
    "return the 8-bytes starting at index as an (unsigned) Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   681
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   682
     Depending on msb, the value is retrieved MSB or LSB-first."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   683
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   684
    |l 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   685
     bIdx  "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   686
     delta "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   687
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   688
    l := LargeInteger basicNew numberOfDigits:8.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   689
    msb ifTrue:[
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   690
        bIdx := index + 7.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   691
        delta := -1
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   692
    ] ifFalse:[
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   693
        bIdx := index.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   694
        delta := 1
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   695
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   696
    1 to:8 do:[:i |
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   697
        l digitAt:i put:(self basicAt:bIdx).
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   698
        bIdx := bIdx + delta
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   699
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   700
    ^ l compressed
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   701
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   702
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   703
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   704
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   705
     b := ByteArray withAll:#(1 2 3 4 5 6 7 8).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   706
     (b quadWordAt:1 MSB:false) printStringRadix:16  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   707
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   708
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   709
    "Modified: 5.11.1996 / 14:06:21 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   710
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   711
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   712
quadWordAt:index put:anInteger MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   713
    "set the 8-bytes starting at index from the (unsigned) Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   714
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   715
     The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   716
     Depending on msb, the value is stored MSB-first or LSB-first."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   717
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   718
    |bIdx  "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   719
     delta "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   720
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   721
    ((anInteger < 0) or:[anInteger > 16rFFFFFFFFFFFFFFFF]) ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   722
	^ self elementBoundsError
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   723
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   724
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   725
    msb ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   726
	bIdx := index + 7.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   727
	delta := -1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   728
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   729
	bIdx := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   730
	delta := 1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   731
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   732
    1 to:8 do:[:i |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   733
	self basicAt:bIdx put:(anInteger digitAt:i).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   734
	bIdx := bIdx + delta.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   735
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   736
    ^ anInteger
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   737
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   738
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   739
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   740
     b := ByteArray new:8.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   741
     b quadWordAtIndex:1 put:16r0807060504030201 MSB:false.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   742
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   743
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   744
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   745
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   746
unsignedLongLongAt:index bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   747
    "return the 8-bytes starting at index as an (unsigned) Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   748
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   749
     Depending on msb, the value is retrieved MSB or LSB-first."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   750
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   751
    |l 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   752
     bIdx  "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   753
     delta "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   754
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   755
    l := LargeInteger basicNew numberOfDigits:8.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   756
    msb ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   757
        bIdx := index + 7.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   758
        delta := -1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   759
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   760
        bIdx := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   761
        delta := 1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   762
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   763
    1 to:8 do:[:i |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   764
        l digitAt:i put:(self basicAt:bIdx).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   765
        bIdx := bIdx + delta
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   766
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   767
    ^ l compressed
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   768
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   769
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   770
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   771
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   772
     b := ByteArray withAll:#(1 2 3 4 5 6 7 8).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   773
     (b unsignedLongLongAt:1 bigEndian:false) printStringRadix:16  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   774
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   775
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   776
    "Modified: / 5.11.1996 / 14:06:21 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   777
    "Modified: / 5.3.1998 / 14:04:44 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   778
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   779
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   780
unsignedLongLongAt:index put:anInteger
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   781
    "set the 8-bytes starting at index from the (unsigned) Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   782
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   783
     The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   784
     The value is stored in natural byte order."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   785
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   786
    ^ self unsignedLongLongAt:index put:anInteger bigEndian:(UninterpretedBytes isBigEndian)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   787
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   788
    "Created: / 5.3.1998 / 14:44:00 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   789
    "Modified: / 5.3.1998 / 15:02:32 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   790
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   791
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   792
unsignedLongLongAt:index put:anInteger bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   793
    "set the 8-bytes starting at index from the (unsigned) Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   794
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   795
     The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   796
     Depending on msb, the value is stored MSB-first or LSB-first."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   797
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   798
    |bIdx  "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   799
     delta "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   800
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   801
    ((anInteger < 0) or:[anInteger > 16rFFFFFFFFFFFFFFFF]) ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   802
        ^ self elementBoundsError
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   803
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   804
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   805
    msb ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   806
        bIdx := index + 7.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   807
        delta := -1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   808
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   809
        bIdx := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   810
        delta := 1
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   811
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   812
    1 to:8 do:[:i |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   813
        self basicAt:bIdx put:(anInteger digitAt:i).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   814
        bIdx := bIdx + delta.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   815
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   816
    ^ anInteger
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   817
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   818
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   819
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   820
     b := ByteArray new:8.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   821
     b unsignedLongLongAt:1 put:16r0807060504030201 bigEndian:false.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   822
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   823
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   824
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   825
    "Created: / 5.3.1998 / 14:06:02 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   826
! !
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   827
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   828
!UninterpretedBytes methodsFor:'accessing-longs'!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   829
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   830
doubleWordAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   831
    "return the 4-bytes starting at index as an (unsigned) Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   832
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   833
     The value is retrieved in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   834
     Subclasses may redefine this for better performance.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   835
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   836
     OBSOLETE: please use longAt: / unsignedLongAt:"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   837
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   838
%{
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   839
    /*
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   840
     * handle the most common cases fast ...
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   841
     */
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   842
    if (__isSmallInteger(index)) {
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   843
        char *cp;
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   844
        int sz;
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   845
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   846
        __fetchBytePointerAndSize__(self, &cp, &sz);
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   847
        if (cp) {
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   848
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   849
            int iVal;
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   850
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   851
            if ((idx+(sizeof(int)-1)) < sz) {
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   852
                cp += idx;
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   853
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   854
#if defined(i386) || defined(UNALIGNED_FETCH_OK)
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   855
                /* aligned or not - we dont care
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   856
                 * (i386 can fetch unaligned)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   857
                 */
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   858
                iVal = ((int *)cp)[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   859
#else
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   860
                if (((INT)cp & (sizeof(int)-1)) == 0) {
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   861
                    /*
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   862
                     * aligned
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   863
                     */
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   864
                    iVal = ((int *)cp)[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   865
                } else {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   866
                    union {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   867
                        char c[4];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   868
                        int  i;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   869
                    } u;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   870
                    u.c[0] = cp[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   871
                    u.c[1] = cp[1];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   872
                    u.c[2] = cp[2];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   873
                    u.c[3] = cp[3];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   874
                    iVal = u.i;
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   875
                }
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   876
#endif
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   877
                if ((iVal >= 0) && (iVal <= _MAX_INT)) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   878
                    RETURN ( __MKSMALLINT(iVal) );
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   879
                }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   880
                RETURN ( __MKULARGEINT(iVal) );
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   881
            }
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   882
        }
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   883
    }
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   884
%}.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   885
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   886
    ^ self doubleWordAt:index MSB:(UninterpretedBytes isBigEndian)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   887
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   888
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   889
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   890
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   891
     b := ByteArray withAll:#(1 2 3 4).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   892
     (b doubleWordAt:1) printStringRadix:16   
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   893
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   894
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   895
    "Modified: / 5.3.1998 / 14:57:35 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   896
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   897
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   898
doubleWordAt:index MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   899
    "return the 4-bytes starting at index as an (unsigned) Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   900
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   901
     The value is retrieved MSB-first, if the msb-arg is true;
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   902
     LSB-first otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   903
     Subclasses may redefine this for better performance."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   904
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   905
    |val 
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   906
     ival "{ Class: SmallInteger }"
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   907
     t    "{ Class: SmallInteger }"
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   908
     i    "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   909
     b1   "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   910
     b2   "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   911
     b3   "{ Class: SmallInteger }"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   912
     b4   "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   913
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   914
%{
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   915
    /*
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   916
     * handle the most common cases fast ...
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   917
     */
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   918
    if (__isSmallInteger(index)) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   919
        unsigned char *cp;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   920
        int sz;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   921
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   922
        __fetchBytePointerAndSize__(self, &cp, &sz);
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   923
        if (cp) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   924
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   925
            int iVal;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   926
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   927
            if ((idx+(sizeof(int)-1)) < sz) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   928
                cp += idx;
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   929
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   930
                if (msb == true) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   931
#ifdef __MSBFIRST
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   932
                    if (((INT)cp & (sizeof(int)-1))== 0) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   933
                        /*
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   934
                         * aligned
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   935
                         */
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   936
                        iVal = ((int *)cp)[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   937
                    } else
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   938
#endif
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   939
                    {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   940
                        iVal = cp[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   941
                        iVal = (iVal << 8) | cp[1];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   942
                        iVal = (iVal << 8) | cp[2];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   943
                        iVal = (iVal << 8) | cp[3];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   944
                    }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   945
                } else {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   946
#ifdef i386
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   947
                    /*
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   948
                     * aligned or not - we dont care
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   949
                     * (i386 can fetch unaligned)
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   950
                     */
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   951
                    iVal = ((int *)cp)[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   952
#else
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   953
# ifdef __LSBFIRST
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   954
                    if (((INT)cp & (sizeof(int)-1))== 0) {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   955
                        /*
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   956
                         * aligned
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   957
                         */
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   958
                        iVal = ((int *)cp)[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   959
                    } else
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   960
# endif
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   961
                    {
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   962
                        iVal = cp[3];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   963
                        iVal = (iVal << 8) | cp[2];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   964
                        iVal = (iVal << 8) | cp[1];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   965
                        iVal = (iVal << 8) | cp[0];
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   966
                    }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   967
#endif
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   968
                }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   969
                RETURN (__MKUINT(iVal));
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   970
            }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   971
        }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   972
    }
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   973
%}.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   974
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   975
    "/ fallBack code - non ByteArray-like receiver
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   976
    "/ or funny index
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   977
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   978
    i := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   979
    b1 := self at:i.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   980
    b2 := self at:(i+1).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   981
    b3 := self at:(i+2).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   982
    b4 := self at:(i+3).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   983
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   984
    msb ifFalse:[
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   985
        t := b4. b4 := b1. b1 := t.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   986
        t := b3. b3 := b2. b2 := t.
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   987
    ].
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   988
    ival := b1.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   989
    ival := (ival bitShift:8) + b2.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   990
    ival := (ival bitShift:8) + b3.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   991
    val := (ival bitShift:8) + b4.
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   992
    ^ val
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   993
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   994
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   995
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   996
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
   997
     b := ByteArray withAll:#(1 2 3 4).
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   998
     (b doubleWordAt:1 MSB:true) printStringRadix:16.       
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
   999
     (b doubleWordAt:1 MSB:false) printStringRadix:16        
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1000
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1001
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1002
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1003
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1004
doubleWordAt:index put:value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1005
    "set the 4-bytes starting at index from the (unsigned) Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1006
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1007
     The value should be in the range 0 to 16rFFFFFFFF
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1008
     (for negative values, the stored value is not defined).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1009
     The value is stored in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1010
     Subclasses may redefine this for better performance."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1011
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1012
    ^ self doubleWordAt:index put:value MSB:(UninterpretedBytes isBigEndian)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1013
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1014
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1015
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1016
     b := ByteArray new:4.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1017
     b doubleWordAt:1 put:16r04030201.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1018
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1019
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1020
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1021
    "Modified: / 5.3.1998 / 14:57:48 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1022
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1023
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1024
doubleWordAt:index put:aNumber MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1025
    "set the 4-bytes starting at index from the (unsigned) Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1026
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1027
     The value must be in the range 0 to 16rFFFFFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1028
     The value is stored MSB-first if msb is true; LSB-first otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1029
     Subclasses may redefine this for better performance."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1030
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1031
    |i "{ Class: SmallInteger }" |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1032
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1033
    ((aNumber < 0) or:[aNumber > 16rFFFFFFFF]) ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1034
        ^ self elementBoundsError
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1035
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1036
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1037
    i := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1038
    msb ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1039
        self at:i     put:(aNumber digitAt:4).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1040
        self at:(i+1) put:(aNumber digitAt:3).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1041
        self at:(i+2) put:(aNumber digitAt:2).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1042
        self at:(i+3) put:(aNumber digitAt:1).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1043
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1044
        self at:i     put:(aNumber digitAt:1).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1045
        self at:(i+1) put:(aNumber digitAt:2).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1046
        self at:(i+2) put:(aNumber digitAt:3).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1047
        self at:(i+3) put:(aNumber digitAt:4).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1048
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1049
    ^ aNumber
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1050
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1051
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1052
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1053
     b := ByteArray new:8.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1054
     b doubleWordAt:1 put:16r04030201 MSB:true.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1055
     b doubleWordAt:5 put:16r04030201 MSB:false.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1056
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1057
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1058
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1059
    "Modified: / 21.1.1998 / 17:43:34 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1060
    "Modified: / 5.3.1998 / 11:42:17 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1061
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1062
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1063
doubleWordAtDoubleWordIndex:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1064
    "return the unsigned long at index, anInteger. 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1065
     Fetching in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1066
     Indices are 1-based and scaled as appropriate to allow
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1067
     accessing the memory as an array of doubleWord entries.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1068
     (i.e. indices are 1, 2, ...)"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1069
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1070
    ^ self doubleWordAtDoubleWordIndex:index MSB:(UninterpretedBytes isBigEndian)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1071
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1072
    "Created: / 21.1.1998 / 17:43:53 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1073
    "Modified: / 5.3.1998 / 14:58:06 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1074
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1075
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1076
doubleWordAtDoubleWordIndex:index MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1077
    "return the unsigned long at index, anInteger. 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1078
     Fetching is MSB if msb is true, LSB otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1079
     Indices are 1-based and scaled as appropriate to allow
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1080
     accessing the memory as an array of doubleWord entries.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1081
     (i.e. indices are 1, 2, ...)"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1082
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1083
    ^ self doubleWordAt:(index - 1 * 4 + 1) MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1084
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1085
    "Created: / 21.1.1998 / 17:44:07 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1086
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1087
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1088
doubleWordAtDoubleWordIndex:index put:value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1089
    "set the long at index, anInteger. 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1090
     Storing in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1091
     Indices are 1-based and scaled as appropriate to allow
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1092
     accessing the memory as an array of doubleWord entries.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1093
     (i.e. indices are 1, 2, ...)"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1094
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1095
    ^ self doubleWordAtDoubleWordIndex:index put:value MSB:(UninterpretedBytes isBigEndian)
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1096
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1097
    "Created: / 21.1.1998 / 17:44:13 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1098
    "Modified: / 5.3.1998 / 14:58:19 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1099
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1100
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1101
doubleWordAtDoubleWordIndex:index put:value MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1102
    "set the long at index, anInteger. 
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1103
     Storing is MSB if msb is true, LSB otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1104
     Indices are 1-based and scaled as appropriate to allow
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1105
     accessing the memory as an array of doubleWord entries.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1106
     (i.e. indices are 1, 2, ...)"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1107
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1108
    ^ self doubleWordAt:(index - 1 * 4 + 1) put:value MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1109
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1110
    "Created: / 21.1.1998 / 17:44:19 / cg"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1111
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1112
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1113
longAt:index
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1114
    "return the 4-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1115
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1116
     The value is retrieved in the machines natural byte order.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1117
     This may be worth a primitive."
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1118
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1119
    |w|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1120
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1121
%{
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1122
    /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1123
     * handle the most common cases fast ...
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1124
     */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1125
    if (__isSmallInteger(index)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1126
        char *cp;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1127
        int sz;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1128
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1129
        __fetchBytePointerAndSize__(self, &cp, &sz);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1130
        if (cp) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1131
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1132
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1133
            if ((idx+(sizeof(float)-1)) < sz) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1134
                cp += idx;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1135
                /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1136
                 * aligned
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1137
                 */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1138
                if (((INT)cp & (sizeof(float)-1)) == 0) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1139
                    INT iVal = ((int *)cp)[0];
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1140
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1141
                    RETURN (__MKINT(iVal));
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1142
                }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1143
            }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1144
        }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1145
    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1146
%}.
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1147
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1148
    w := self unsignedLongAt:index.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1149
    (w > (16r7FFFFFFF)) ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1150
        ^ w - (16r100000000)
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1151
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1152
    ^ w
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1153
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1154
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1155
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1156
     b := ByteArray new:4.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1157
     b unsignedLongAt:1 put:16rFFFFFFFF.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1158
     (b longAt:1)    
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1159
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1160
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1161
    "Modified: / 1.7.1996 / 21:11:28 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1162
    "Modified: / 5.3.1998 / 12:06:28 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1163
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1164
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1165
longAt:index bigEndian:msb
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1166
    "return the 4-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1167
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1168
     Depending on msb, the value is retrieved MSB-first or LSB-first.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1169
     This may be worth a primitive."
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1170
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1171
    |w|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1172
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1173
    w := self unsignedLongAt:index bigEndian:msb.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1174
    (w > (16r7FFFFFFF)) ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1175
        ^ w - (16r100000000)
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1176
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1177
    ^ w
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1178
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1179
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1180
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1181
     b := ByteArray new:4.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1182
     b unsignedLongAt:1 put:16rFFFFFFFF.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1183
     (b longAt:1)    
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1184
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1185
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1186
    "Modified: / 1.7.1996 / 21:11:33 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1187
    "Created: / 5.3.1998 / 14:02:03 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1188
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1189
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1190
longAt:index put:value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1191
    "set the 4-bytes starting at index from the signed Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1192
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1193
     The value is stored in the machines natural byte order.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1194
     This may be worth a primitive.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1195
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1196
     This is the ST80 version of #signedDoubleWordAt:put:"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1197
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1198
    |v|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1199
3434
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1200
%{
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1201
    /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1202
     * handle the most common cases fast ...
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1203
     */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1204
    if (__isSmallInteger(index)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1205
        char *cp;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1206
        int sz;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1207
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1208
        __fetchBytePointerAndSize__(self, &cp, &sz);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1209
        if (cp) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1210
            unsigned INT idx = ((unsigned INT)__intVal(index)) - 1;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1211
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1212
            if ((idx+(sizeof(float)-1)) < sz) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1213
                cp += idx;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1214
                /*
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1215
                 * aligned
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1216
                 */
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1217
                if (((INT)cp & (sizeof(float)-1)) == 0) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1218
		    int __v;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1219
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1220
    		    if (__isSmallInteger(value)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1221
                        ((int *)cp)[0] = __intVal(value);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1222
                        RETURN (value);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1223
		    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1224
		    if (__v = __signedLongIntVal(value)) {
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1225
			((int *)cp)[0] = __v;
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1226
			RETURN (value);
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1227
		    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1228
                }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1229
            }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1230
        }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1231
    }
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1232
%}.
d04ff3256ebb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3433
diff changeset
  1233
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1234
    value >= 0 ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1235
        v := value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1236
    ] ifFalse:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1237
        v := value + 16r100000000
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1238
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1239
    self unsignedLongAt:index put:v.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1240
    ^ value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1241
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1242
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1243
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1244
     b := ByteArray new:4.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1245
     b longAt:1 put:-1.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1246
     (b unsignedLongAt:1) printStringRadix:16   
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1247
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1248
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1249
    "Modified: / 1.7.1996 / 21:11:39 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1250
    "Created: / 5.3.1998 / 10:57:18 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1251
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1252
3444
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1253
longAt:byteIndex put:anInteger bigEndian:msb
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1254
    "store a signed long (32bit) integer.
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1255
     The index is a smalltalk index (i.e. 1-based).
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1256
     Same as #signedQuadWordAt:put: - for ST80 compatibility."
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1257
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1258
    |v|
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1259
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1260
    v := anInteger.
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1261
    anInteger < 0 ifTrue:[
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1262
        v := v + 16r100000000
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1263
    ].
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1264
    ^ self unsignedLongAt:byteIndex put:v bigEndian:msb
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1265
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1266
    "Created: / 9.5.1998 / 01:10:24 / cg"
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1267
    "Modified: / 9.5.1998 / 01:13:34 / cg"
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1268
!
09f811ddbb51 added #longAt:put:bigEndian:
ca
parents: 3439
diff changeset
  1269
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1270
signedDoubleWordAt:index
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1271
    "return the 4-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1272
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1273
     The value is retrieved in the machines natural byte order.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1274
     This may be worth a primitive."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1275
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1276
    |w|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1277
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1278
    w := self doubleWordAt:index.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1279
    (w > (16r7FFFFFFF)) ifTrue:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1280
	^ w - (16r100000000)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1281
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1282
    ^ w
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1283
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1284
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1285
     |b|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1286
     b := ByteArray new:4.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1287
     b doubleWordAt:1 put:16rFFFFFFFF.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1288
     (b signedDoubleWordAt:1)    
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1289
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1290
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1291
    "Modified: 1.7.1996 / 21:11:28 / cg"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1292
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1293
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1294
signedDoubleWordAt:index MSB:msb
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1295
    "return the 4-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1296
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1297
     Depending on msb, the value is retrieved MSB-first or LSB-first.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1298
     This may be worth a primitive."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1299
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1300
    |w|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1301
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1302
    w := self doubleWordAt:index MSB:msb.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1303
    (w > (16r7FFFFFFF)) ifTrue:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1304
	^ w - (16r100000000)
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1305
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1306
    ^ w
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1307
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1308
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1309
     |b|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1310
     b := ByteArray new:4.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1311
     b doubleWordAt:1 put:16rFFFFFFFF.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1312
     (b signedDoubleWordAt:1)    
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1313
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1314
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1315
    "Modified: 1.7.1996 / 21:11:33 / cg"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1316
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1317
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1318
signedDoubleWordAt:index put:value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1319
    "set the 4-bytes starting at index from the signed Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1320
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1321
     The value is stored in the machines natural byte order.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1322
     This may be worth a primitive."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1323
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1324
    |v|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1325
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1326
    value >= 0 ifTrue:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1327
	v := value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1328
    ] ifFalse:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1329
	v := value + 16r100000000
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1330
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1331
    self doubleWordAt:index put:v.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1332
    ^ value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1333
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1334
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1335
     |b|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1336
     b := ByteArray new:4.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1337
     b signedDoubleWordAt:1 put:-1.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1338
     (b doubleWordAt:1) printStringRadix:16   
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1339
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1340
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1341
    "Modified: 1.7.1996 / 21:11:39 / cg"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1342
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1343
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1344
signedDoubleWordAt:index put:value MSB:msb
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1345
    "set the 4-bytes starting at index from the signed Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1346
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1347
     Depending on msb, the value is stored MSB-first or LSB-first.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1348
     This may be worth a primitive."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1349
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1350
    |v|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1351
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1352
    value >= 0 ifTrue:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1353
	v := value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1354
    ] ifFalse:[
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1355
	v := value + 16r100000000
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1356
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1357
    self doubleWordAt:index put:v MSB:msb.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1358
    ^ value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1359
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1360
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1361
     |b|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1362
     b := ByteArray new:4.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1363
     b signedDoubleWordAt:1 put:-1.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1364
     (b doubleWordAt:1) printStringRadix:16   
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1365
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1366
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1367
    "Modified: 1.7.1996 / 21:11:46 / cg"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1368
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1369
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1370
unsignedLongAt:index
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1371
    "return the 4-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1372
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1373
     The value is retrieved in the machines natural byte order.
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1374
     Subclasses may redefine this for better performance.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1375
     Same as doubleWordAt: for protocol completeness"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1376
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1377
    ^ self doubleWordAt:index
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1378
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1379
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1380
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1381
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1382
     b := ByteArray withAll:#(1 2 3 4).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1383
     (b unsignedLongAt:1) printStringRadix:16   
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1384
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1385
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1386
    "Created: / 5.3.1998 / 11:56:53 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1387
    "Modified: / 5.3.1998 / 14:58:48 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1388
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1389
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1390
unsignedLongAt:index bigEndian:msb
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1391
    "return the 4-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1392
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1393
     The value is retrieved MSB-first, if the msb-arg is true;
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1394
     LSB-first otherwise.
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1395
     Subclasses may redefine this for better performance.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1396
     Same as doubleWordAt:MSB: for protocol completeness"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1397
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1398
    ^ self doubleWordAt:index MSB:msb
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1399
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1400
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1401
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1402
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1403
     b := ByteArray withAll:#(1 2 3 4).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1404
     (b unsignedLongAt:1 bigEndian:true) printStringRadix:16.   
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1405
     (b unsignedLongAt:1 bigEndian:false) printStringRadix:16   
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1406
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1407
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1408
    "Modified: / 21.1.1998 / 17:42:30 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1409
    "Created: / 5.3.1998 / 11:46:05 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1410
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1411
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1412
unsignedLongAt:index put:value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1413
    "set the 4-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1414
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1415
     The value should be in the range 0 to 16rFFFFFFFF
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1416
     (for negative values, the stored value is not defined).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1417
     The value is stored in the machines natural byte order.
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1418
     Subclasses may redefine this for better performance.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1419
     Same as doubleWordAt:put: for protocol completeness"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1420
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1421
    ^ self doubleWordAt:index put:value
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1422
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1423
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1424
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1425
     b := ByteArray new:4.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1426
     b unsignedLongAt:1 put:16r04030201.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1427
     b inspect
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1428
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1429
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1430
    "Created: / 5.3.1998 / 11:57:44 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1431
    "Modified: / 5.3.1998 / 14:58:59 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1432
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1433
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1434
unsignedLongAt:index put:aNumber bigEndian:msb
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1435
    "set the 4-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1436
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1437
     The value must be in the range 0 to 16rFFFFFFFF.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1438
     The value is stored MSB-first if msb is true; LSB-first otherwise.
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1439
     Subclasses may redefine this for better performance.
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1440
     Same as doubleWordAt:put:MSB: for protocol completeness"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1441
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1442
    ^ self doubleWordAt:index put:aNumber MSB:msb
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1443
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1444
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1445
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1446
     b := ByteArray new:8.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1447
     b unsignedLongAt:1 put:16r04030201 bigEndian:true.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1448
     (b unsignedLongAt:1 bigEndian:false) printStringRadix:16
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1449
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1450
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1451
    "Modified: / 21.1.1998 / 17:43:34 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1452
    "Created: / 5.3.1998 / 11:43:53 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1453
    "Modified: / 5.3.1998 / 11:47:30 / stefan"
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1454
! !
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1455
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1456
!UninterpretedBytes methodsFor:'accessing-shorts'!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1457
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1458
shortAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1459
    "return the 2-bytes starting at index as a signed Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1460
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1461
     The value is retrieved in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1462
     This may be worth a primitive.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1463
     This is the ST80 equivalent of #signedWordAt:"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1464
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1465
    ^ (self unsignedShortAt:index) signExtendedShortValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1466
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1467
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1468
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1469
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1470
     b unsignedShortAt:1 put:16rFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1471
     b shortAt:1  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1472
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1473
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1474
    "Modified: / 1.7.1996 / 21:14:38 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1475
    "Created: / 5.3.1998 / 10:59:57 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1476
    "Modified: / 5.3.1998 / 23:39:38 / stefan"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1477
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1478
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1479
shortAt:index bigEndian:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1480
    "return the 2-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1481
     The index is a smalltalk index (i.e. 1-based).
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1482
     The value is retrieved MSB-first, if the msb-arg is true;
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1483
     LSB-first otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1484
     This is the ST80 equivalent of #signedWordAt:"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1485
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1486
    ^ (self unsignedShortAt:index bigEndian:msb) signExtendedShortValue
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1487
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1488
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1489
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1490
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1491
     b unsignedShortAt:1 put:16rFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1492
     b shortAt:1  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1493
    "
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1494
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1495
    "Modified: / 1.7.1996 / 21:14:38 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1496
    "Created: / 5.3.1998 / 23:41:21 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1497
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1498
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1499
shortAt:index put:value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1500
    "set the 2-bytes starting at index from the signed Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1501
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1502
     The stored value must be in the range -32768 .. +32676.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1503
     The value is stored in the machines natural byteorder.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1504
     This may be worth a primitive.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1505
     This is the ST80 equivalent of #signedWordAt:put:"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1506
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1507
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1508
    |v|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1509
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1510
    value >= 0 ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1511
        v := value
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1512
    ] ifFalse:[
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1513
        v := 16r10000 + value
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1514
    ].
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1515
    self unsignedShortAt:index put:v.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1516
    ^ value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1517
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1518
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1519
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1520
     b := ByteArray new:6.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1521
     b shortAt:1 put:-1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1522
     b shortAt:3 put:-2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1523
     b shortAt:5 put:0.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1524
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1525
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1526
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1527
    "Modified: / 1.7.1996 / 21:12:07 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1528
    "Created: / 5.3.1998 / 11:02:05 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1529
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1530
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1531
signedWordAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1532
    "return the 2-bytes starting at index as a signed Integer.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1533
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1534
     The value is retrieved in the machines natural byte order.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1535
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1536
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1537
    ^ (self wordAt:index) signExtendedShortValue
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1538
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1539
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1540
     |b|
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1541
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1542
     b wordAt:1 put:16rFFFF.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1543
     b signedWordAt:1  
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1544
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1545
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1546
    "Modified: 1.7.1996 / 21:14:38 / cg"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1547
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1548
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1549
signedWordAt:index MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1550
    "return the 2-bytes starting at index as a signed Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1551
     The index is a smalltalk index (i.e. 1-based).
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1552
     The value is retrieved MSB-first if the msb-arg is true,
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1553
     LSB-first otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1554
     This may be worth a primitive."
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1555
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1556
    ^ (self wordAt:index MSB:msb) signExtendedShortValue
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1557
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1558
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1559
     |b|
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1560
     b := ByteArray new:2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1561
     b wordAt:1 put:16r0080.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1562
     b signedWordAt:1 MSB:true.  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1563
     b signedWordAt:1 MSB:false.  
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1564
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1565
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1566
    "Modified: 1.7.1996 / 21:15:57 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1567
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1568
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1569
signedWordAt:index put:value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1570
    "set the 2-bytes starting at index from the signed Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1571
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1572
     The stored value must be in the range -32768 .. +32676.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1573
     The value is stored in the machines natural byteorder.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1574
     This may be worth a primitive.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1575
     This is the ST80 equivalent of #signedWordAt:put:"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1576
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1577
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1578
    |v|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1579
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1580
    value >= 0 ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1581
        v := value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1582
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1583
        v := 16r10000 + value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1584
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1585
    self unsignedShortAt:index put:v.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1586
    ^ value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1587
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1588
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1589
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1590
     b := ByteArray new:6.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1591
     b shortAt:1 put:-1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1592
     b shortAt:3 put:-2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1593
     b shortAt:5 put:0.
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1594
     b inspect
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1595
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1596
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1597
    "Modified: / 1.7.1996 / 21:12:07 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1598
    "Modified: / 5.3.1998 / 11:01:30 / stefan"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1599
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1600
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1601
signedWordAt:index put:value MSB:msb
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1602
    "set the 2-bytes starting at index from the signed Integer value.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1603
     The index is a smalltalk index (i.e. 1-based).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1604
     The stored value must be in the range -32768 .. +32676.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1605
     The value is stored MSB-first, if the msb-arg is true;
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1606
     LSB-first otherwise.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1607
     This may be worth a primitive."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1608
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1609
    |v|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1610
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1611
    value >= 0 ifTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1612
	v := value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1613
    ] ifFalse:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1614
	v := 16r10000 + value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1615
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1616
    self wordAt:index put:v MSB:msb.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1617
    ^ value
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1618
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1619
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1620
     |b|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1621
     b := ByteArray new:4.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1622
     b signedWordAt:1 put:-1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1623
     b signedWordAt:3 put:-2.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1624
     b inspect
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1625
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1626
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1627
    "Modified: 1.7.1996 / 21:12:13 / cg"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1628
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1629
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1630
unsignedShortAt:index
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1631
    "return the 2-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1632
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1633
     The value is retrieved in the machines natural byte order
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1634
     Subclasses may redefine this for better performance.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1635
     This is the ST80 equivalent of #wordAt:"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1636
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1637
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1638
    ^ self unsignedShortAt:index bigEndian:(UninterpretedBytes isBigEndian)
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1639
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1640
    "Created: / 5.3.1998 / 11:38:25 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1641
    "Modified: / 5.3.1998 / 14:59:25 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1642
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1643
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1644
unsignedShortAt:index bigEndian:msb
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1645
    "return the 2-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1646
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1647
     The value is retrieved MSB-first (high 8 bits at lower index) if msb is true;
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1648
     LSB-first (i.e. low 8-bits at lower byte index) if its false)"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1649
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1650
    |b1 "{ Class: SmallInteger }" 
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1651
     b2 "{ Class: SmallInteger }"|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1652
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1653
    b1 := self at:index.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1654
    b2 := self at:(index + 1).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1655
    msb ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1656
        ^ (b1 bitShift:8) + b2
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1657
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1658
    ^ (b2 bitShift:8) + b1
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1659
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1660
    "Modified: / 21.1.1998 / 17:46:07 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1661
    "Created: / 5.3.1998 / 11:49:29 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1662
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1663
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1664
unsignedShortAt:index put:value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1665
    "set the 2-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1666
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1667
     The stored value must be in the range 0 .. 16rFFFF. 
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1668
     The value is stored in the machines natural byteorder."
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1669
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1670
    ^ self unsignedShortAt:index put:value bigEndian:(UninterpretedBytes isBigEndian)
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1671
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1672
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1673
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1674
     b := ByteArray new:4.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1675
     b unsignedShortAt:1 put:16r0102.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1676
     b unsignedShortAt:3 put:16r0304.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1677
     b inspect  
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1678
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1679
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1680
    "Created: / 5.3.1998 / 11:54:52 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1681
    "Modified: / 5.3.1998 / 14:59:38 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1682
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1683
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1684
unsignedShortAt:index put:value bigEndian:msb
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1685
    "set the 2-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1686
     The index is a smalltalk index (i.e. 1-based).
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1687
     The stored value must be in the range 0 .. 16rFFFF. 
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1688
     The value is stored LSB-first (i.e. the low 8bits are stored at the
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1689
     lower index) if msb is false, MSB-first otherwise"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1690
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1691
    |b1 b2
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1692
     iVal "{ Class: SmallInteger }"|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1693
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1694
    iVal := value.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1695
    ((iVal < 0) or:[iVal > 16rFFFF]) ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1696
        ^ self elementBoundsError
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1697
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1698
    msb ifTrue:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1699
        b1 := ((iVal bitShift:-8) bitAnd:16rFF).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1700
        b2 := (iVal bitAnd:16rFF).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1701
    ] ifFalse:[
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1702
        b1 := (iVal bitAnd:16rFF).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1703
        b2 := ((iVal bitShift:-8) bitAnd:16rFF).
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1704
    ].
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1705
    self at:index   put:b1.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1706
    self at:index+1 put:b2.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1707
    ^ value
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1708
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1709
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1710
     |b|
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1711
     b := ByteArray new:8.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1712
     b unsignedShortAt:1 put:16r0102 bigEndian:false.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1713
     b unsignedShortAt:3 put:16r0304 bigEndian:false.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1714
     b unsignedShortAt:5 put:16r0102 bigEndian:true.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1715
     b unsignedShortAt:7 put:16r0304 bigEndian:true.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1716
     b inspect  
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1717
    "
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1718
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1719
    "Modified: / 21.1.1998 / 17:48:15 / cg"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1720
    "Modified: / 5.3.1998 / 11:52:28 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1721
!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1722
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1723
wordAt:index
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1724
    "return the 2-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1725
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1726
     The value is retrieved in the machines natural byte order
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1727
     Subclasses may redefine this for better performance."
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1728
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1729
    ^ self wordAt:index MSB:(UninterpretedBytes isBigEndian)
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1730
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1731
    "Modified: / 5.3.1998 / 14:59:51 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1732
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1733
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1734
wordAt:index MSB:msb
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1735
    "return the 2-bytes starting at index as an (unsigned) Integer.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1736
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1737
     The value is retrieved MSB (high 8 bits at lower index) if msb is true;
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1738
     LSB-first (i.e. low 8-bits at lower byte index) if its false.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1739
     Question: should it be retrieve signed values ? (see ByteArray>>signedWordAt:)"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1740
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1741
    |b1 "{ Class: SmallInteger }" 
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1742
     b2 "{ Class: SmallInteger }"|
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1743
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1744
    b1 := self at:index.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1745
    b2 := self at:(index + 1).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1746
    msb ifTrue:[
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1747
        ^ (b1 bitShift:8) + b2
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1748
    ].
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1749
    ^ (b2 bitShift:8) + b1
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1750
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1751
    "Modified: / 21.1.1998 / 17:46:07 / cg"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1752
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1753
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1754
wordAt:index put:value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1755
    "set the 2-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1756
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1757
     The stored value must be in the range 0 .. 16rFFFF. 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1758
     The value is stored in the machines natural byteorder.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1759
     Question: should it accept signed values ? (see ByteArray>>signedWordAt:put:)"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1760
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1761
    ^ self wordAt:index put:value MSB:(UninterpretedBytes isBigEndian)
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1762
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1763
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1764
     |b|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1765
     b := ByteArray new:4.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1766
     b wordAt:1 put:16r0102.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1767
     b wordAt:3 put:16r0304.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1768
     b inspect  
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1769
    "
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1770
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1771
    "Modified: / 5.3.1998 / 15:00:03 / stefan"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1772
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1773
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1774
wordAt:index put:value MSB:msb
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1775
    "set the 2-bytes starting at index from the (unsigned) Integer value.
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1776
     The index is a smalltalk index (i.e. 1-based).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1777
     The stored value must be in the range 0 .. 16rFFFF. 
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1778
     The value is stored LSB-first (i.e. the low 8bits are stored at the
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1779
     lower index) if msb is false, MSB-first otherwise.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1780
     Question: should it accept signed values ? (see ByteArray>>signedWordAt:put:)"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1781
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1782
    |b1 b2
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1783
     iVal "{ Class: SmallInteger }"|
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1784
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1785
    iVal := value.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1786
    ((iVal < 0) or:[iVal > 16rFFFF]) ifTrue:[
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1787
        ^ self elementBoundsError
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1788
    ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1789
    msb ifTrue:[
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1790
        b1 := ((iVal bitShift:-8) bitAnd:16rFF).
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1791
        b2 := (iVal bitAnd:16rFF).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1792
    ] ifFalse:[
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1793
        b1 := (iVal bitAnd:16rFF).
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1794
        b2 := ((iVal bitShift:-8) bitAnd:16rFF).
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1795
    ].
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1796
    self at:index   put:b1.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1797
    self at:index+1 put:b2.
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1798
    ^ value
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1799
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1800
    "
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1801
     b := ByteArray new:8.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1802
     b wordAt:1 put:16r0102 MSB:false.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1803
     b wordAt:3 put:16r0304 MSB:false.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1804
     b wordAt:5 put:16r0102 MSB:true.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1805
     b wordAt:7 put:16r0304 MSB:true.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1806
     b inspect  
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1807
    "
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1808
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1809
    "Modified: / 21.1.1998 / 17:48:15 / cg"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1810
!
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1811
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1812
wordAtWordIndex:index
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1813
    "return the unsigned short at index, anInteger. 
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1814
     Fetching in the machines natural byte order.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1815
     Indices are 1-based and scaled as appropriate to allow
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1816
     accessing the memory as an array of word entries.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1817
     (i.e. indices are 1, 2, ...)"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1818
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1819
    ^ self wordAtWordIndex:index MSB:(UninterpretedBytes isBigEndian)
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1820
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1821
    "Created: / 21.1.1998 / 17:48:26 / cg"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1822
    "Modified: / 5.3.1998 / 15:00:16 / stefan"
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1823
!
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1824
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1825
wordAtWordIndex:index MSB:msb
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1826
    "return the unsigned short at index, anInteger. 
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1827
     Fetching is MSB if msb is true, LSB otherwise.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1828
     Indices are 1-based and scaled as appropriate to allow
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1829
     accessing the memory as an array of word entries.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1830
     (i.e. indices are 1, 2, ...)"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1831
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1832
    ^ self wordAt:(index - 1 * 2 + 1) MSB:msb
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1833
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1834
    "Created: / 21.1.1998 / 17:48:30 / cg"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1835
!
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1836
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1837
wordAtWordIndex:index put:value
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1838
    "set the short at index, anInteger. 
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1839
     Storing in the machines natural byte order.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1840
     Indices are 1-based and scaled as appropriate to allow
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1841
     accessing the memory as an array of word entries.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1842
     (i.e. indices are 1, 2, ...)"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1843
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1844
    ^ self wordAtWordIndex:index put:value MSB:(UninterpretedBytes isBigEndian)
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1845
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1846
    "Created: / 21.1.1998 / 17:48:34 / cg"
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1847
    "Modified: / 5.3.1998 / 15:00:27 / stefan"
3212
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1848
!
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1849
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1850
wordAtWordIndex:index put:value MSB:msb
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1851
    "set the short at index, anInteger. 
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1852
     Storing is MSB if msb is true, LSB otherwise.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1853
     Indices are 1-based and scaled as appropriate to allow
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1854
     accessing the memory as an array of word entries.
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1855
     (i.e. indices are 1, 2, ...)"
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1856
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1857
    ^ self wordAt:(index - 1 * 2 + 1) put:value MSB:msb
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1858
b8cc18f8691b moved some of ExtBytes protocol to here.
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
  1859
    "Created: / 21.1.1998 / 17:48:38 / cg"
3459
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1860
! !
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1861
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1862
!UninterpretedBytes methodsFor:'accessing-strings'!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1863
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1864
stringAt:index
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1865
    "return a string starting at index up to the 0-byte.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1866
     The index is a smalltalk index (i.e. 1-based)."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1867
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1868
    |stream i "{ Class: SmallInteger }" c|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1869
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1870
    stream := WriteStream on:''.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1871
    i := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1872
    [(c := self basicAt:i) ~~ 0] whileTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1873
        stream nextPut:(Character value:c).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1874
        i := i + 1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1875
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1876
    ^ stream contents
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1877
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1878
    "Created: / 21.1.1998 / 17:44:50 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1879
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1880
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1881
stringAt:index put:aString
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1882
    "copy aString to the externalBytes, starting at index up to
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1883
     (and including) the 0-byte.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1884
     The index is a smalltalk index (i.e. 1-based)."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1885
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1886
    |i "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1887
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1888
    i := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1889
    aString do:[:aChar |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1890
        self basicAt:i put:aChar asciiValue.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1891
        i := i + 1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1892
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1893
    self basicAt:i put:0.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1894
    ^ aString
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1895
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1896
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1897
     |bytes|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1898
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1899
     bytes := ExternalBytes new:10.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1900
     bytes stringAt:1 put:'hello'.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1901
     1 to:bytes size do:[:i |
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1902
        Transcript showCR:(bytes at:i)
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1903
     ]
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1904
    "
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1905
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1906
    "Created: / 21.1.1998 / 17:45:02 / cg"
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1907
!
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1908
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1909
stringAt:index size:maxSize
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1910
    "return a string starting at index up to maxSize, or a 0-byte.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1911
     The index is a smalltalk index (i.e. 1-based)."
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1912
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1913
    |stream c i "{ Class: SmallInteger }"|
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1914
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1915
    stream := WriteStream on:(String new:maxSize).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1916
    i := index.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1917
    [(i <= maxSize)
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1918
     and:[(c := self basicAt:i) ~~ 0]] whileTrue:[
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1919
        stream nextPut:(Character value:c).
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1920
        i := i + 1.
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1921
    ].
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1922
    ^ stream contents
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1923
6cb151c3950c category changes
Claus Gittinger <cg@exept.de>
parents: 3447
diff changeset
  1924
    "Modified: / 21.1.1998 / 17:45:23 / cg"
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1925
!
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1926
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1927
zeroByteStringAt:index maximumSize:count
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1928
    "extract a zeroByte-delimited string, given initial index and
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1929
     maximum number of characters (bytes).
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1930
     The index is a smalltalk index (i.e. 1-based)."
3207
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1931
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1932
    |bytes idx|
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1933
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1934
    bytes := self copyFrom:index to:(index + count - 1).
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1935
    idx := bytes indexOf:0.
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1936
    idx ~~ 0 ifTrue:[ bytes := bytes copyTo:idx-1 ].
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1937
    ^ bytes asString
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1938
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1939
    "Created: 9.9.1996 / 15:28:34 / cg"
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1940
! !
a6e3c98e2a8e merged common protocol of ByteArray and ExternalBytes into this class.
Claus Gittinger <cg@exept.de>
parents: 1294
diff changeset
  1941
3363
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1942
!UninterpretedBytes methodsFor:'misc'!
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1943
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1944
swapLongAt:byteIndex 
3433
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1945
    "swap the byteOrder of a long.
a94725308432 added comments;
Claus Gittinger <cg@exept.de>
parents: 3410
diff changeset
  1946
     The index is a smalltalk index (i.e. 1-based)."
3363
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1947
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1948
    |t|
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1949
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1950
    t := self byteAt:byteIndex.
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1951
    self byteAt:byteIndex put:(self byteAt:(byteIndex + 3)).
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1952
    self byteAt:(byteIndex + 3) put:t.
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1953
    t := self byteAt:(byteIndex + 1).
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1954
    self byteAt:(byteIndex + 1) put:(self byteAt:(byteIndex + 2)).
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1955
    self byteAt:(byteIndex + 2) put:t
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1956
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1957
    "Created: / 3.4.1998 / 13:37:01 / cg"
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1958
! !
3bb61f364fe3 added #from: and #swapLongAt: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 3323
diff changeset
  1959
3323
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1960
!UninterpretedBytes methodsFor:'queries'!
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1961
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1962
sizeInBytes
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1963
    "return the number of 8-bit bytes in the receiver.
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1964
     This is needed since subclasse may redefine #size (TwoByteString)"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1965
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1966
    ^ super size
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1967
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1968
    "Created: / 5.3.1998 / 10:41:13 / stefan"
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1969
! !
f890c96b2f2a Add ST80 compatibility stuff
Stefan Vogel <sv@exept.de>
parents: 3284
diff changeset
  1970
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1971
!UninterpretedBytes class methodsFor:'documentation'!
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1972
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1973
version
4019
c9284ca27a4a tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents: 3936
diff changeset
  1974
    ^ '$Header: /cvs/stx/stx/libbasic/UninterpretedBytes.st,v 1.32 1999-03-03 15:10:51 cg Exp $'
695
20ec350f92ca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1975
! !