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-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
300 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
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 | 14 |
instanceVariableNames:'' |
3323 | 15 |
classVariableNames:'IsBigEndian' |
1266 | 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 | 18 |
! |
19 |
||
3433 | 20 |
!UninterpretedBytes primitiveDefinitions! |
21 |
%{ |
|
22 |
/* |
|
23 |
* Notice: I am abstract, and my subclasses may be anything. |
|
24 |
* Therefore, the code must always handle the fallback case |
|
25 |
* where the receiver is neither an ExternalBytes nor a ByteArray. |
|
26 |
* (which are, however, the most common) |
|
27 |
* |
|
28 |
* macro to fetch my byte address and size-in-bytes; |
|
29 |
* convenient for inline-C code. |
|
30 |
* (yes, C is bad ...) |
|
31 |
*/ |
|
32 |
#define __fetchBytePointerAndSize__(o, pPtr, pSize) \ |
|
33 |
{\ |
|
34 |
if (__isNonNilObject(o)) { \ |
|
35 |
if (__qClass(o) == ByteArray) { \ |
|
36 |
*(pPtr) = (char *)__ByteArrayInstPtr(o)->ba_element; \ |
|
37 |
*(pSize) = __byteArraySize(o); \ |
|
38 |
} else if (__qClass(o) == ExternalBytes) { \ |
|
39 |
OBJ __sz__ = __externalBytesSize(o); \ |
|
40 |
if (__isSmallInteger(__sz__)) { \ |
|
41 |
*(pSize) = __intVal(__sz__); \ |
|
42 |
*(pPtr) = (char *)(__externalBytesAddress(o)); \ |
|
43 |
} else { \ |
|
44 |
*(pPtr) = (char *)0; \ |
|
45 |
} \ |
|
46 |
} else { \ |
|
47 |
*(pPtr) = (char *)0; \ |
|
48 |
} \ |
|
49 |
} else { \ |
|
50 |
*(pPtr) = (char *)0; \ |
|
51 |
} \ |
|
52 |
} |
|
53 |
||
54 |
%} |
|
55 |
! ! |
|
56 |
||
68 | 57 |
!UninterpretedBytes class methodsFor:'documentation'! |
1 | 58 |
|
88 | 59 |
copyright |
60 |
" |
|
61 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
300 | 62 |
All Rights Reserved |
88 | 63 |
|
64 |
This software is furnished under a license and may be used |
|
65 |
only in accordance with the terms of that license and with the |
|
66 |
inclusion of the above copyright notice. This software may not |
|
67 |
be provided or otherwise made available to, or used by, any |
|
68 |
other person. No title to or ownership of the software is |
|
69 |
hereby transferred. |
|
70 |
" |
|
71 |
! |
|
72 |
||
68 | 73 |
documentation |
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 | 86 |
|
87 |
[author:] |
|
88 |
Claus Gittinger |
|
3433 | 89 |
|
90 |
[Notice:] |
|
91 |
Notice the confusion due to multiple methods with the same |
|
92 |
functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:'). |
|
93 |
The reason is that at the time this class was written, |
|
94 |
ST80 sid not offer protocol to specify the byteOrder, and |
|
95 |
ST/X provided methods ending in 'MSB:' for this. |
|
96 |
In the meanwhile, VW added protocol ending in 'bigEndian:', |
|
97 |
which has been added here for compatibility. |
|
98 |
(certainly a point, where an ansi-standard will help) |
|
68 | 99 |
" |
100 |
! ! |
|
1 | 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 | 111 |
!UninterpretedBytes class methodsFor:'queries'! |
112 |
||
113 |
isBigEndian |
|
77 | 114 |
"return true, if words/shorts store the most-significant |
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 | 120 |
|
121 |
%{ /* NOCONTEXT */ |
|
122 |
||
3936 | 123 |
#ifdef __MSBFIRST |
124 |
RETURN (true); |
|
125 |
#else |
|
1 | 126 |
/* |
127 |
* I dont like ifdefs - you always forget some ... |
|
3433 | 128 |
* therefore we look into a structure at run-time. |
129 |
* (also, there are CPUs around [mips], where the byteorder |
|
130 |
* is programmable, and which come in different flavours) |
|
131 |
* |
|
132 |
* NOTICE: |
|
133 |
* both the JIT and stc may inline this to a |
|
134 |
* constant for systems where this is known. |
|
1 | 135 |
*/ |
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 | 139 |
} u; |
140 |
||
141 |
u.u_l = 0x87654321; |
|
77 | 142 |
if (u.u_c[0] == 0x21) RETURN (false); |
143 |
RETURN (true); |
|
3936 | 144 |
#endif |
1 | 145 |
%} |
3433 | 146 |
" |
147 |
UninterpretedBytes isBigEndian |
|
148 |
" |
|
3209 | 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 | 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 | 158 |
"Modified: / 23.4.1996 / 15:56:25 / cg" |
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 | 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 | 180 |
signedByteAt:index |
181 |
"return the byte at index as a signed 8 bit value. |
|
182 |
The index is a smalltalk index (i.e. 1-based). |
|
183 |
This may be worth a primitive." |
|
184 |
||
185 |
^ (self at:index) signExtendedByteValue |
|
186 |
||
187 |
" |
|
188 |
|b| |
|
189 |
b := ByteArray new:2. |
|
190 |
b at:1 put:16rFF. |
|
191 |
b at:2 put:16r7F. |
|
192 |
b signedByteAt:1 |
|
193 |
" |
|
194 |
||
195 |
"Modified: 1.7.1996 / 21:13:53 / cg" |
|
196 |
! |
|
197 |
||
198 |
signedByteAt:index put:aSignedByteValue |
|
199 |
"return the byte at index as a signed 8 bit value. |
|
200 |
The index is a smalltalk index (i.e. 1-based). |
|
201 |
Return the signedByteValue argument. |
|
202 |
This may be worth a primitive." |
|
203 |
||
204 |
|b "{ Class: SmallInteger }"| |
|
205 |
||
206 |
aSignedByteValue >= 0 ifTrue:[ |
|
207 |
b := aSignedByteValue |
|
208 |
] ifFalse:[ |
|
209 |
b := 16r100 + aSignedByteValue |
|
210 |
]. |
|
211 |
self at:index put:b. |
|
212 |
^ aSignedByteValue |
|
213 |
||
214 |
" |
|
215 |
|b| |
|
216 |
b := ByteArray new:2. |
|
217 |
b signedByteAt:1 put:-1. |
|
218 |
b at:1 |
|
219 |
" |
|
220 |
||
221 |
"Modified: 1.7.1996 / 21:12:37 / cg" |
|
222 |
! ! |
|
223 |
||
224 |
!UninterpretedBytes methodsFor:'accessing-floats & doubles'! |
|
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 | 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 | 236 |
%{ |
237 |
/* |
|
238 |
* handle the most common cases fast ... |
|
239 |
*/ |
|
240 |
if (__isSmallInteger(index)) { |
|
241 |
char *cp; |
|
242 |
int sz; |
|
243 |
||
244 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
245 |
if (cp) { |
|
246 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
247 |
||
3434 | 248 |
if ((idx+(sizeof(double)-1)) < sz) { |
3433 | 249 |
cp += idx; |
250 |
/* |
|
251 |
* aligned |
|
252 |
*/ |
|
3434 | 253 |
if (((INT)cp & (sizeof(double)-1)) == 0) { |
3433 | 254 |
double dVal = ((double *)cp)[0]; |
3434 | 255 |
OBJ f; |
256 |
||
257 |
__qMKFLOAT(f, dVal); |
|
258 |
RETURN (f); |
|
3433 | 259 |
} |
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
%}. |
|
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 | 270 |
|
271 |
" |
|
272 |
|b| |
|
273 |
||
274 |
b := ByteArray new:20. |
|
275 |
b doubleAt:1 put:(Float pi). |
|
276 |
Transcript showCR:b. |
|
277 |
Transcript showCR:(b doubleAt:1) |
|
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 | 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 | 316 |
%{ |
317 |
/* |
|
318 |
* handle the most common cases fast ... |
|
319 |
*/ |
|
320 |
if (__isSmallInteger(index) && __isFloat(flt)) { |
|
321 |
char *cp; |
|
322 |
int sz; |
|
323 |
||
324 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
325 |
if (cp) { |
|
326 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
327 |
||
3434 | 328 |
if ((idx+(sizeof(double)-1)) < sz) { |
3433 | 329 |
cp += idx; |
330 |
/* |
|
331 |
* aligned |
|
332 |
*/ |
|
3434 | 333 |
if (((INT)cp & (sizeof(double)-1)) == 0) { |
3433 | 334 |
((double *)cp)[0] = __floatVal(flt); |
335 |
RETURN (aFloat); |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
%}. |
|
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 | 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 | 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 | 374 |
"return the 4-bytes starting at index as a ShortFloat. |
3433 | 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 | 385 |
%{ |
386 |
/* |
|
387 |
* handle the most common cases fast ... |
|
388 |
*/ |
|
389 |
if (__isSmallInteger(index)) { |
|
390 |
char *cp; |
|
391 |
int sz; |
|
392 |
||
393 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
394 |
if (cp) { |
|
395 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
396 |
||
397 |
if ((idx+(sizeof(float)-1)) < sz) { |
|
398 |
cp += idx; |
|
399 |
/* |
|
400 |
* aligned |
|
401 |
*/ |
|
402 |
if (((INT)cp & (sizeof(float)-1)) == 0) { |
|
403 |
float fVal = ((float *)cp)[0]; |
|
404 |
OBJ f; |
|
405 |
||
406 |
__qMKSFLOAT(f, fVal); |
|
407 |
RETURN (f); |
|
408 |
} |
|
409 |
} |
|
410 |
} |
|
411 |
} |
|
412 |
%}. |
|
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 | 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 | 459 |
%{ |
460 |
/* |
|
461 |
* handle the most common cases fast ... |
|
462 |
*/ |
|
463 |
if (__isSmallInteger(index) && __isShortFloat(sflt)) { |
|
464 |
char *cp; |
|
465 |
int sz; |
|
466 |
||
467 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
468 |
if (cp) { |
|
469 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
470 |
||
471 |
if ((idx+(sizeof(float)-1)) < sz) { |
|
472 |
cp += idx; |
|
473 |
/* |
|
474 |
* aligned |
|
475 |
*/ |
|
476 |
if (((INT)cp & (sizeof(float)-1)) == 0) { |
|
477 |
((float *)cp)[0] = __shortFloatVal(sflt); |
|
478 |
||
479 |
RETURN (aFloat); |
|
480 |
} |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
%}. |
|
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 | 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 | 518 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 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 | 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 | 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 | 529 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
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 | 532 |
|
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 | 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 | 538 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 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 | 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 | 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 | 549 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
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 | 552 |
|
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 | 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 | 558 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 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 | 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 | 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 | 569 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
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 | 572 |
|
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 | 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 | 578 |
starting at index, which is a smalltalk index (i.e. 1-based). |
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 | 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 | 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 | 590 |
self isIEEEFormat ifFalse:[self error:'unsupported operation']. |
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 | 593 |
|
594 |
"Created: / 5.3.1998 / 10:51:11 / stefan" |
|
3459 | 595 |
! ! |
596 |
||
597 |
!UninterpretedBytes methodsFor:'accessing-longlongs'! |
|
598 |
||
599 |
longLongAt:index |
|
600 |
"return the 8-bytes starting at index as a signed Integer. |
|
601 |
The index is a smalltalk index (i.e. 1-based). |
|
602 |
The value is retrieved in the machines natural byte order. |
|
603 |
This may be worth a primitive." |
|
604 |
||
605 |
|w| |
|
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 | 608 |
(w > (16r7FFFFFFFFFFFFFFF)) ifTrue:[ |
609 |
^ w - (16r10000000000000000) |
|
610 |
]. |
|
611 |
^ w |
|
612 |
||
613 |
" |
|
614 |
|b| |
|
615 |
b := ByteArray new:4. |
|
616 |
b unsignedLongLongAt:1 put:16rFFFFFFFFFFFFFFFF. |
|
617 |
(b longLongAt:1) |
|
618 |
" |
|
619 |
||
620 |
"Modified: / 1.7.1996 / 21:11:28 / cg" |
|
621 |
"Created: / 5.3.1998 / 14:40:05 / stefan" |
|
622 |
"Modified: / 5.3.1998 / 14:58:32 / stefan" |
|
623 |
! |
|
624 |
||
625 |
longLongAt:index bigEndian:msb |
|
626 |
"return the 8-bytes starting at index as a signed Integer. |
|
627 |
The index is a smalltalk index (i.e. 1-based). |
|
628 |
The value is retrieved in the given byte order. |
|
629 |
This may be worth a primitive." |
|
630 |
||
631 |
|w| |
|
632 |
||
633 |
w := self unsignedLongLongAt:index bigEndian:msb. |
|
634 |
(w > (16r7FFFFFFFFFFFFFFF)) ifTrue:[ |
|
635 |
^ w - (16r10000000000000000) |
|
636 |
]. |
|
637 |
^ w |
|
638 |
||
639 |
" |
|
640 |
|b| |
|
641 |
b := ByteArray new:4. |
|
642 |
b unsignedLongLongAt:1 put:16rFFFFFFFFFFFFFFFF. |
|
643 |
(b longLongAt:1 msb:true) |
|
644 |
" |
|
645 |
||
646 |
"Modified: / 5.3.1998 / 12:06:28 / stefan" |
|
647 |
"Created: / 5.3.1998 / 14:40:54 / stefan" |
|
648 |
"Modified: / 9.5.1998 / 01:10:59 / cg" |
|
649 |
! |
|
650 |
||
651 |
longLongAt:byteIndex put:anInteger |
|
652 |
"store a signed longLong (64bit) integer. |
|
653 |
The index is a smalltalk index (i.e. 1-based). |
|
654 |
Same as #signedQuadWordAt:put: - for ST80 compatibility." |
|
655 |
||
656 |
^ self signedQuadWordAt:byteIndex put:anInteger |
|
657 |
||
658 |
"Modified: / 3.4.1998 / 13:33:14 / cg" |
|
659 |
"Created: / 3.4.1998 / 13:34:22 / cg" |
|
660 |
! |
|
661 |
||
662 |
longLongAt:byteIndex put:anInteger bigEndian:msb |
|
663 |
"store a signed longLong (64bit) integer. |
|
664 |
The index is a smalltalk index (i.e. 1-based). |
|
665 |
Same as #signedQuadWordAt:put: - for ST80 compatibility." |
|
666 |
||
667 |
|v| |
|
668 |
||
669 |
v := anInteger. |
|
670 |
anInteger < 0 ifTrue:[ |
|
671 |
v := v + 16r10000000000000000 |
|
672 |
]. |
|
673 |
^ self unsignedLongLongAt:byteIndex put:v bigEndian:msb |
|
674 |
||
675 |
"Created: / 9.5.1998 / 01:10:24 / cg" |
|
676 |
"Modified: / 9.5.1998 / 01:13:34 / cg" |
|
677 |
! |
|
678 |
||
679 |
quadWordAt:index MSB:msb |
|
680 |
"return the 8-bytes starting at index as an (unsigned) Integer. |
|
681 |
The index is a smalltalk index (i.e. 1-based). |
|
682 |
Depending on msb, the value is retrieved MSB or LSB-first." |
|
683 |
||
684 |
|l |
|
685 |
bIdx "{ Class: SmallInteger }" |
|
686 |
delta "{ Class: SmallInteger }"| |
|
687 |
||
688 |
l := LargeInteger basicNew numberOfDigits:8. |
|
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 | 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 | 695 |
]. |
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 | 699 |
]. |
700 |
^ l compressed |
|
701 |
||
702 |
" |
|
703 |
|b| |
|
704 |
||
705 |
b := ByteArray withAll:#(1 2 3 4 5 6 7 8). |
|
706 |
(b quadWordAt:1 MSB:false) printStringRadix:16 |
|
707 |
" |
|
708 |
||
709 |
"Modified: 5.11.1996 / 14:06:21 / cg" |
|
710 |
! |
|
711 |
||
712 |
quadWordAt:index put:anInteger MSB:msb |
|
713 |
"set the 8-bytes starting at index from the (unsigned) Integer value. |
|
714 |
The index is a smalltalk index (i.e. 1-based). |
|
715 |
The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF. |
|
716 |
Depending on msb, the value is stored MSB-first or LSB-first." |
|
717 |
||
718 |
|bIdx "{ Class: SmallInteger }" |
|
719 |
delta "{ Class: SmallInteger }"| |
|
720 |
||
721 |
((anInteger < 0) or:[anInteger > 16rFFFFFFFFFFFFFFFF]) ifTrue:[ |
|
722 |
^ self elementBoundsError |
|
723 |
]. |
|
724 |
||
725 |
msb ifTrue:[ |
|
726 |
bIdx := index + 7. |
|
727 |
delta := -1 |
|
728 |
] ifFalse:[ |
|
729 |
bIdx := index. |
|
730 |
delta := 1 |
|
731 |
]. |
|
732 |
1 to:8 do:[:i | |
|
733 |
self basicAt:bIdx put:(anInteger digitAt:i). |
|
734 |
bIdx := bIdx + delta. |
|
735 |
]. |
|
736 |
^ anInteger |
|
737 |
||
738 |
" |
|
739 |
|b| |
|
740 |
b := ByteArray new:8. |
|
741 |
b quadWordAtIndex:1 put:16r0807060504030201 MSB:false. |
|
742 |
b inspect |
|
743 |
" |
|
744 |
! |
|
745 |
||
746 |
unsignedLongLongAt:index bigEndian:msb |
|
747 |
"return the 8-bytes starting at index as an (unsigned) Integer. |
|
748 |
The index is a smalltalk index (i.e. 1-based). |
|
749 |
Depending on msb, the value is retrieved MSB or LSB-first." |
|
750 |
||
751 |
|l |
|
752 |
bIdx "{ Class: SmallInteger }" |
|
753 |
delta "{ Class: SmallInteger }"| |
|
754 |
||
755 |
l := LargeInteger basicNew numberOfDigits:8. |
|
756 |
msb ifTrue:[ |
|
757 |
bIdx := index + 7. |
|
758 |
delta := -1 |
|
759 |
] ifFalse:[ |
|
760 |
bIdx := index. |
|
761 |
delta := 1 |
|
762 |
]. |
|
763 |
1 to:8 do:[:i | |
|
764 |
l digitAt:i put:(self basicAt:bIdx). |
|
765 |
bIdx := bIdx + delta |
|
766 |
]. |
|
767 |
^ l compressed |
|
768 |
||
769 |
" |
|
770 |
|b| |
|
771 |
||
772 |
b := ByteArray withAll:#(1 2 3 4 5 6 7 8). |
|
773 |
(b unsignedLongLongAt:1 bigEndian:false) printStringRadix:16 |
|
774 |
" |
|
775 |
||
776 |
"Modified: / 5.11.1996 / 14:06:21 / cg" |
|
777 |
"Modified: / 5.3.1998 / 14:04:44 / stefan" |
|
778 |
! |
|
779 |
||
780 |
unsignedLongLongAt:index put:anInteger |
|
781 |
"set the 8-bytes starting at index from the (unsigned) Integer value. |
|
782 |
The index is a smalltalk index (i.e. 1-based). |
|
783 |
The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF. |
|
784 |
The value is stored in natural byte order." |
|
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 | 787 |
|
788 |
"Created: / 5.3.1998 / 14:44:00 / stefan" |
|
789 |
"Modified: / 5.3.1998 / 15:02:32 / stefan" |
|
790 |
! |
|
791 |
||
792 |
unsignedLongLongAt:index put:anInteger bigEndian:msb |
|
793 |
"set the 8-bytes starting at index from the (unsigned) Integer value. |
|
794 |
The index is a smalltalk index (i.e. 1-based). |
|
795 |
The value must be in the range 0 to 16rFFFFFFFFFFFFFFFF. |
|
796 |
Depending on msb, the value is stored MSB-first or LSB-first." |
|
797 |
||
798 |
|bIdx "{ Class: SmallInteger }" |
|
799 |
delta "{ Class: SmallInteger }"| |
|
800 |
||
801 |
((anInteger < 0) or:[anInteger > 16rFFFFFFFFFFFFFFFF]) ifTrue:[ |
|
802 |
^ self elementBoundsError |
|
803 |
]. |
|
804 |
||
805 |
msb ifTrue:[ |
|
806 |
bIdx := index + 7. |
|
807 |
delta := -1 |
|
808 |
] ifFalse:[ |
|
809 |
bIdx := index. |
|
810 |
delta := 1 |
|
811 |
]. |
|
812 |
1 to:8 do:[:i | |
|
813 |
self basicAt:bIdx put:(anInteger digitAt:i). |
|
814 |
bIdx := bIdx + delta. |
|
815 |
]. |
|
816 |
^ anInteger |
|
817 |
||
818 |
" |
|
819 |
|b| |
|
820 |
b := ByteArray new:8. |
|
821 |
b unsignedLongLongAt:1 put:16r0807060504030201 bigEndian:false. |
|
822 |
b inspect |
|
823 |
" |
|
824 |
||
825 |
"Created: / 5.3.1998 / 14:06:02 / stefan" |
|
826 |
! ! |
|
827 |
||
828 |
!UninterpretedBytes methodsFor:'accessing-longs'! |
|
829 |
||
830 |
doubleWordAt:index |
|
831 |
"return the 4-bytes starting at index as an (unsigned) Integer. |
|
832 |
The index is a smalltalk index (i.e. 1-based). |
|
833 |
The value is retrieved in the machines natural byte order. |
|
834 |
Subclasses may redefine this for better performance. |
|
835 |
||
836 |
OBSOLETE: please use longAt: / unsignedLongAt:" |
|
837 |
||
838 |
%{ |
|
839 |
/* |
|
840 |
* handle the most common cases fast ... |
|
841 |
*/ |
|
842 |
if (__isSmallInteger(index)) { |
|
843 |
char *cp; |
|
844 |
int sz; |
|
845 |
||
846 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
847 |
if (cp) { |
|
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 | 850 |
|
851 |
if ((idx+(sizeof(int)-1)) < sz) { |
|
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 | 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 | 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 | 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 | 881 |
} |
882 |
} |
|
883 |
} |
|
884 |
%}. |
|
885 |
||
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
886 |
^ self doubleWordAt:index MSB:(UninterpretedBytes isBigEndian) |
3459 | 887 |
|
888 |
" |
|
889 |
|b| |
|
890 |
||
891 |
b := ByteArray withAll:#(1 2 3 4). |
|
892 |
(b doubleWordAt:1) printStringRadix:16 |
|
893 |
" |
|
894 |
||
895 |
"Modified: / 5.3.1998 / 14:57:35 / stefan" |
|
896 |
! |
|
897 |
||
898 |
doubleWordAt:index MSB:msb |
|
899 |
"return the 4-bytes starting at index as an (unsigned) Integer. |
|
900 |
The index is a smalltalk index (i.e. 1-based). |
|
901 |
The value is retrieved MSB-first, if the msb-arg is true; |
|
902 |
LSB-first otherwise. |
|
903 |
Subclasses may redefine this for better performance." |
|
904 |
||
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 | 908 |
i "{ Class: SmallInteger }" |
909 |
b1 "{ Class: SmallInteger }" |
|
910 |
b2 "{ Class: SmallInteger }" |
|
911 |
b3 "{ Class: SmallInteger }" |
|
912 |
b4 "{ Class: SmallInteger }"| |
|
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 | 978 |
i := index. |
979 |
b1 := self at:i. |
|
980 |
b2 := self at:(i+1). |
|
981 |
b3 := self at:(i+2). |
|
982 |
b4 := self at:(i+3). |
|
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 | 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 | 992 |
^ val |
993 |
||
994 |
" |
|
995 |
|b| |
|
996 |
||
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 | 1000 |
" |
1001 |
||
1002 |
! |
|
1003 |
||
1004 |
doubleWordAt:index put:value |
|
1005 |
"set the 4-bytes starting at index from the (unsigned) Integer value. |
|
1006 |
The index is a smalltalk index (i.e. 1-based). |
|
1007 |
The value should be in the range 0 to 16rFFFFFFFF |
|
1008 |
(for negative values, the stored value is not defined). |
|
1009 |
The value is stored in the machines natural byte order. |
|
1010 |
Subclasses may redefine this for better performance." |
|
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 | 1013 |
|
1014 |
" |
|
1015 |
|b| |
|
1016 |
b := ByteArray new:4. |
|
1017 |
b doubleWordAt:1 put:16r04030201. |
|
1018 |
b inspect |
|
1019 |
" |
|
1020 |
||
1021 |
"Modified: / 5.3.1998 / 14:57:48 / stefan" |
|
1022 |
! |
|
1023 |
||
1024 |
doubleWordAt:index put:aNumber MSB:msb |
|
1025 |
"set the 4-bytes starting at index from the (unsigned) Integer value. |
|
1026 |
The index is a smalltalk index (i.e. 1-based). |
|
1027 |
The value must be in the range 0 to 16rFFFFFFFF. |
|
1028 |
The value is stored MSB-first if msb is true; LSB-first otherwise. |
|
1029 |
Subclasses may redefine this for better performance." |
|
1030 |
||
1031 |
|i "{ Class: SmallInteger }" | |
|
1032 |
||
1033 |
((aNumber < 0) or:[aNumber > 16rFFFFFFFF]) ifTrue:[ |
|
1034 |
^ self elementBoundsError |
|
1035 |
]. |
|
1036 |
||
1037 |
i := index. |
|
1038 |
msb ifTrue:[ |
|
1039 |
self at:i put:(aNumber digitAt:4). |
|
1040 |
self at:(i+1) put:(aNumber digitAt:3). |
|
1041 |
self at:(i+2) put:(aNumber digitAt:2). |
|
1042 |
self at:(i+3) put:(aNumber digitAt:1). |
|
1043 |
] ifFalse:[ |
|
1044 |
self at:i put:(aNumber digitAt:1). |
|
1045 |
self at:(i+1) put:(aNumber digitAt:2). |
|
1046 |
self at:(i+2) put:(aNumber digitAt:3). |
|
1047 |
self at:(i+3) put:(aNumber digitAt:4). |
|
1048 |
]. |
|
1049 |
^ aNumber |
|
1050 |
||
1051 |
" |
|
1052 |
|b| |
|
1053 |
b := ByteArray new:8. |
|
1054 |
b doubleWordAt:1 put:16r04030201 MSB:true. |
|
1055 |
b doubleWordAt:5 put:16r04030201 MSB:false. |
|
1056 |
b inspect |
|
1057 |
" |
|
1058 |
||
1059 |
"Modified: / 21.1.1998 / 17:43:34 / cg" |
|
1060 |
"Modified: / 5.3.1998 / 11:42:17 / stefan" |
|
1061 |
! |
|
1062 |
||
1063 |
doubleWordAtDoubleWordIndex:index |
|
1064 |
"return the unsigned long at index, anInteger. |
|
1065 |
Fetching in the machines natural byte order. |
|
1066 |
Indices are 1-based and scaled as appropriate to allow |
|
1067 |
accessing the memory as an array of doubleWord entries. |
|
1068 |
(i.e. indices are 1, 2, ...)" |
|
1069 |
||
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
1070 |
^ self doubleWordAtDoubleWordIndex:index MSB:(UninterpretedBytes isBigEndian) |
3459 | 1071 |
|
1072 |
"Created: / 21.1.1998 / 17:43:53 / cg" |
|
1073 |
"Modified: / 5.3.1998 / 14:58:06 / stefan" |
|
1074 |
! |
|
1075 |
||
1076 |
doubleWordAtDoubleWordIndex:index MSB:msb |
|
1077 |
"return the unsigned long at index, anInteger. |
|
1078 |
Fetching is MSB if msb is true, LSB otherwise. |
|
1079 |
Indices are 1-based and scaled as appropriate to allow |
|
1080 |
accessing the memory as an array of doubleWord entries. |
|
1081 |
(i.e. indices are 1, 2, ...)" |
|
1082 |
||
1083 |
^ self doubleWordAt:(index - 1 * 4 + 1) MSB:msb |
|
1084 |
||
1085 |
"Created: / 21.1.1998 / 17:44:07 / cg" |
|
1086 |
! |
|
1087 |
||
1088 |
doubleWordAtDoubleWordIndex:index put:value |
|
1089 |
"set the long at index, anInteger. |
|
1090 |
Storing in the machines natural byte order. |
|
1091 |
Indices are 1-based and scaled as appropriate to allow |
|
1092 |
accessing the memory as an array of doubleWord entries. |
|
1093 |
(i.e. indices are 1, 2, ...)" |
|
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 | 1096 |
|
1097 |
"Created: / 21.1.1998 / 17:44:13 / cg" |
|
1098 |
"Modified: / 5.3.1998 / 14:58:19 / stefan" |
|
1099 |
! |
|
1100 |
||
1101 |
doubleWordAtDoubleWordIndex:index put:value MSB:msb |
|
1102 |
"set the long at index, anInteger. |
|
1103 |
Storing is MSB if msb is true, LSB otherwise. |
|
1104 |
Indices are 1-based and scaled as appropriate to allow |
|
1105 |
accessing the memory as an array of doubleWord entries. |
|
1106 |
(i.e. indices are 1, 2, ...)" |
|
1107 |
||
1108 |
^ self doubleWordAt:(index - 1 * 4 + 1) put:value MSB:msb |
|
1109 |
||
1110 |
"Created: / 21.1.1998 / 17:44:19 / cg" |
|
3323 | 1111 |
! |
1112 |
||
1113 |
longAt:index |
|
1114 |
"return the 4-bytes starting at index as a signed Integer. |
|
3433 | 1115 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1116 |
The value is retrieved in the machines natural byte order. |
1117 |
This may be worth a primitive." |
|
1118 |
||
1119 |
|w| |
|
1120 |
||
3434 | 1121 |
%{ |
1122 |
/* |
|
1123 |
* handle the most common cases fast ... |
|
1124 |
*/ |
|
1125 |
if (__isSmallInteger(index)) { |
|
1126 |
char *cp; |
|
1127 |
int sz; |
|
1128 |
||
1129 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
1130 |
if (cp) { |
|
1131 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
1132 |
||
1133 |
if ((idx+(sizeof(float)-1)) < sz) { |
|
1134 |
cp += idx; |
|
1135 |
/* |
|
1136 |
* aligned |
|
1137 |
*/ |
|
1138 |
if (((INT)cp & (sizeof(float)-1)) == 0) { |
|
1139 |
INT iVal = ((int *)cp)[0]; |
|
1140 |
||
1141 |
RETURN (__MKINT(iVal)); |
|
1142 |
} |
|
1143 |
} |
|
1144 |
} |
|
1145 |
} |
|
1146 |
%}. |
|
1147 |
||
3323 | 1148 |
w := self unsignedLongAt:index. |
1149 |
(w > (16r7FFFFFFF)) ifTrue:[ |
|
1150 |
^ w - (16r100000000) |
|
1151 |
]. |
|
1152 |
^ w |
|
1153 |
||
1154 |
" |
|
1155 |
|b| |
|
1156 |
b := ByteArray new:4. |
|
1157 |
b unsignedLongAt:1 put:16rFFFFFFFF. |
|
1158 |
(b longAt:1) |
|
1159 |
" |
|
1160 |
||
1161 |
"Modified: / 1.7.1996 / 21:11:28 / cg" |
|
1162 |
"Modified: / 5.3.1998 / 12:06:28 / stefan" |
|
1163 |
! |
|
1164 |
||
1165 |
longAt:index bigEndian:msb |
|
1166 |
"return the 4-bytes starting at index as a signed Integer. |
|
3433 | 1167 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1168 |
Depending on msb, the value is retrieved MSB-first or LSB-first. |
1169 |
This may be worth a primitive." |
|
1170 |
||
1171 |
|w| |
|
1172 |
||
1173 |
w := self unsignedLongAt:index bigEndian:msb. |
|
1174 |
(w > (16r7FFFFFFF)) ifTrue:[ |
|
1175 |
^ w - (16r100000000) |
|
1176 |
]. |
|
1177 |
^ w |
|
1178 |
||
1179 |
" |
|
1180 |
|b| |
|
1181 |
b := ByteArray new:4. |
|
1182 |
b unsignedLongAt:1 put:16rFFFFFFFF. |
|
1183 |
(b longAt:1) |
|
1184 |
" |
|
1185 |
||
1186 |
"Modified: / 1.7.1996 / 21:11:33 / cg" |
|
1187 |
"Created: / 5.3.1998 / 14:02:03 / stefan" |
|
1188 |
! |
|
1189 |
||
1190 |
longAt:index put:value |
|
1191 |
"set the 4-bytes starting at index from the signed Integer value. |
|
3433 | 1192 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1193 |
The value is stored in the machines natural byte order. |
1194 |
This may be worth a primitive. |
|
1195 |
||
1196 |
This is the ST80 version of #signedDoubleWordAt:put:" |
|
1197 |
||
1198 |
|v| |
|
1199 |
||
3434 | 1200 |
%{ |
1201 |
/* |
|
1202 |
* handle the most common cases fast ... |
|
1203 |
*/ |
|
1204 |
if (__isSmallInteger(index)) { |
|
1205 |
char *cp; |
|
1206 |
int sz; |
|
1207 |
||
1208 |
__fetchBytePointerAndSize__(self, &cp, &sz); |
|
1209 |
if (cp) { |
|
1210 |
unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
|
1211 |
||
1212 |
if ((idx+(sizeof(float)-1)) < sz) { |
|
1213 |
cp += idx; |
|
1214 |
/* |
|
1215 |
* aligned |
|
1216 |
*/ |
|
1217 |
if (((INT)cp & (sizeof(float)-1)) == 0) { |
|
1218 |
int __v; |
|
1219 |
||
1220 |
if (__isSmallInteger(value)) { |
|
1221 |
((int *)cp)[0] = __intVal(value); |
|
1222 |
RETURN (value); |
|
1223 |
} |
|
1224 |
if (__v = __signedLongIntVal(value)) { |
|
1225 |
((int *)cp)[0] = __v; |
|
1226 |
RETURN (value); |
|
1227 |
} |
|
1228 |
} |
|
1229 |
} |
|
1230 |
} |
|
1231 |
} |
|
1232 |
%}. |
|
1233 |
||
3323 | 1234 |
value >= 0 ifTrue:[ |
1235 |
v := value |
|
1236 |
] ifFalse:[ |
|
1237 |
v := value + 16r100000000 |
|
1238 |
]. |
|
1239 |
self unsignedLongAt:index put:v. |
|
1240 |
^ value |
|
1241 |
||
1242 |
" |
|
1243 |
|b| |
|
1244 |
b := ByteArray new:4. |
|
1245 |
b longAt:1 put:-1. |
|
1246 |
(b unsignedLongAt:1) printStringRadix:16 |
|
1247 |
" |
|
1248 |
||
1249 |
"Modified: / 1.7.1996 / 21:11:39 / cg" |
|
1250 |
"Created: / 5.3.1998 / 10:57:18 / stefan" |
|
1251 |
! |
|
1252 |
||
3444 | 1253 |
longAt:byteIndex put:anInteger bigEndian:msb |
1254 |
"store a signed long (32bit) integer. |
|
1255 |
The index is a smalltalk index (i.e. 1-based). |
|
1256 |
Same as #signedQuadWordAt:put: - for ST80 compatibility." |
|
1257 |
||
1258 |
|v| |
|
1259 |
||
1260 |
v := anInteger. |
|
1261 |
anInteger < 0 ifTrue:[ |
|
1262 |
v := v + 16r100000000 |
|
1263 |
]. |
|
1264 |
^ self unsignedLongAt:byteIndex put:v bigEndian:msb |
|
1265 |
||
1266 |
"Created: / 9.5.1998 / 01:10:24 / cg" |
|
1267 |
"Modified: / 9.5.1998 / 01:13:34 / cg" |
|
1268 |
! |
|
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 | 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 | 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 | 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 | 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 | 1370 |
unsignedLongAt:index |
1371 |
"return the 4-bytes starting at index as an (unsigned) Integer. |
|
3433 | 1372 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 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 | 1376 |
|
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
1377 |
^ self doubleWordAt:index |
3323 | 1378 |
|
1379 |
" |
|
1380 |
|b| |
|
1381 |
||
1382 |
b := ByteArray withAll:#(1 2 3 4). |
|
1383 |
(b unsignedLongAt:1) printStringRadix:16 |
|
1384 |
" |
|
1385 |
||
1386 |
"Created: / 5.3.1998 / 11:56:53 / stefan" |
|
1387 |
"Modified: / 5.3.1998 / 14:58:48 / stefan" |
|
1388 |
! |
|
1389 |
||
1390 |
unsignedLongAt:index bigEndian:msb |
|
1391 |
"return the 4-bytes starting at index as an (unsigned) Integer. |
|
3433 | 1392 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1393 |
The value is retrieved MSB-first, if the msb-arg is true; |
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 | 1397 |
|
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
1398 |
^ self doubleWordAt:index MSB:msb |
3323 | 1399 |
|
1400 |
" |
|
1401 |
|b| |
|
1402 |
||
1403 |
b := ByteArray withAll:#(1 2 3 4). |
|
1404 |
(b unsignedLongAt:1 bigEndian:true) printStringRadix:16. |
|
1405 |
(b unsignedLongAt:1 bigEndian:false) printStringRadix:16 |
|
1406 |
" |
|
1407 |
||
1408 |
"Modified: / 21.1.1998 / 17:42:30 / cg" |
|
1409 |
"Created: / 5.3.1998 / 11:46:05 / stefan" |
|
1410 |
! |
|
1411 |
||
1412 |
unsignedLongAt:index put:value |
|
1413 |
"set the 4-bytes starting at index from the (unsigned) Integer value. |
|
3433 | 1414 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1415 |
The value should be in the range 0 to 16rFFFFFFFF |
1416 |
(for negative values, the stored value is not defined). |
|
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 | 1420 |
|
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
1421 |
^ self doubleWordAt:index put:value |
3323 | 1422 |
|
1423 |
" |
|
1424 |
|b| |
|
1425 |
b := ByteArray new:4. |
|
1426 |
b unsignedLongAt:1 put:16r04030201. |
|
1427 |
b inspect |
|
1428 |
" |
|
1429 |
||
1430 |
"Created: / 5.3.1998 / 11:57:44 / stefan" |
|
1431 |
"Modified: / 5.3.1998 / 14:58:59 / stefan" |
|
1432 |
! |
|
1433 |
||
1434 |
unsignedLongAt:index put:aNumber bigEndian:msb |
|
1435 |
"set the 4-bytes starting at index from the (unsigned) Integer value. |
|
3433 | 1436 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1437 |
The value must be in the range 0 to 16rFFFFFFFF. |
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 | 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 | 1443 |
|
1444 |
" |
|
1445 |
|b| |
|
1446 |
b := ByteArray new:8. |
|
1447 |
b unsignedLongAt:1 put:16r04030201 bigEndian:true. |
|
1448 |
(b unsignedLongAt:1 bigEndian:false) printStringRadix:16 |
|
1449 |
" |
|
1450 |
||
1451 |
"Modified: / 21.1.1998 / 17:43:34 / cg" |
|
1452 |
"Created: / 5.3.1998 / 11:43:53 / stefan" |
|
1453 |
"Modified: / 5.3.1998 / 11:47:30 / stefan" |
|
3459 | 1454 |
! ! |
1455 |
||
1456 |
!UninterpretedBytes methodsFor:'accessing-shorts'! |
|
1457 |
||
1458 |
shortAt:index |
|
1459 |
"return the 2-bytes starting at index as a signed Integer. |
|
1460 |
The index is a smalltalk index (i.e. 1-based). |
|
1461 |
The value is retrieved in the machines natural byte order. |
|
1462 |
This may be worth a primitive. |
|
1463 |
This is the ST80 equivalent of #signedWordAt:" |
|
1464 |
||
1465 |
^ (self unsignedShortAt:index) signExtendedShortValue |
|
1466 |
||
1467 |
" |
|
1468 |
|b| |
|
1469 |
b := ByteArray new:2. |
|
1470 |
b unsignedShortAt:1 put:16rFFFF. |
|
1471 |
b shortAt:1 |
|
1472 |
" |
|
1473 |
||
1474 |
"Modified: / 1.7.1996 / 21:14:38 / cg" |
|
1475 |
"Created: / 5.3.1998 / 10:59:57 / stefan" |
|
1476 |
"Modified: / 5.3.1998 / 23:39:38 / stefan" |
|
3323 | 1477 |
! |
1478 |
||
3459 | 1479 |
shortAt:index bigEndian:msb |
1480 |
"return the 2-bytes starting at index as a signed Integer. |
|
3433 | 1481 |
The index is a smalltalk index (i.e. 1-based). |
3459 | 1482 |
The value is retrieved MSB-first, if the msb-arg is true; |
1483 |
LSB-first otherwise. |
|
1484 |
This is the ST80 equivalent of #signedWordAt:" |
|
1485 |
||
1486 |
^ (self unsignedShortAt:index bigEndian:msb) signExtendedShortValue |
|
1487 |
||
1488 |
" |
|
1489 |
|b| |
|
1490 |
b := ByteArray new:2. |
|
1491 |
b unsignedShortAt:1 put:16rFFFF. |
|
1492 |
b shortAt:1 |
|
1493 |
" |
|
3323 | 1494 |
|
3459 | 1495 |
"Modified: / 1.7.1996 / 21:14:38 / cg" |
1496 |
"Created: / 5.3.1998 / 23:41:21 / stefan" |
|
1497 |
! |
|
1498 |
||
1499 |
shortAt:index put:value |
|
1500 |
"set the 2-bytes starting at index from the signed Integer value. |
|
1501 |
The index is a smalltalk index (i.e. 1-based). |
|
1502 |
The stored value must be in the range -32768 .. +32676. |
|
1503 |
The value is stored in the machines natural byteorder. |
|
1504 |
This may be worth a primitive. |
|
1505 |
This is the ST80 equivalent of #signedWordAt:put:" |
|
1506 |
||
3323 | 1507 |
|
3459 | 1508 |
|v| |
1509 |
||
1510 |
value >= 0 ifTrue:[ |
|
1511 |
v := value |
|
3323 | 1512 |
] ifFalse:[ |
3459 | 1513 |
v := 16r10000 + value |
3323 | 1514 |
]. |
3459 | 1515 |
self unsignedShortAt:index put:v. |
1516 |
^ value |
|
1517 |
||
1518 |
" |
|
1519 |
|b| |
|
1520 |
b := ByteArray new:6. |
|
1521 |
b shortAt:1 put:-1. |
|
1522 |
b shortAt:3 put:-2. |
|
1523 |
b shortAt:5 put:0. |
|
1524 |
b inspect |
|
1525 |
" |
|
1526 |
||
1527 |
"Modified: / 1.7.1996 / 21:12:07 / cg" |
|
1528 |
"Created: / 5.3.1998 / 11:02:05 / stefan" |
|
1529 |
! |
|
1530 |
||
1531 |
signedWordAt:index |
|
1532 |
"return the 2-bytes starting at index as a signed Integer. |
|
1533 |
The index is a smalltalk index (i.e. 1-based). |
|
1534 |
The value is retrieved in the machines natural byte order. |
|
1535 |
This may be worth a primitive." |
|
1536 |
||
1537 |
^ (self wordAt:index) signExtendedShortValue |
|
3323 | 1538 |
|
1539 |
" |
|
1540 |
|b| |
|
3459 | 1541 |
b := ByteArray new:2. |
1542 |
b wordAt:1 put:16rFFFF. |
|
1543 |
b signedWordAt:1 |
|
3323 | 1544 |
" |
1545 |
||
3459 | 1546 |
"Modified: 1.7.1996 / 21:14:38 / cg" |
3323 | 1547 |
! |
1548 |
||
3459 | 1549 |
signedWordAt:index MSB:msb |
1550 |
"return the 2-bytes starting at index as a signed Integer. |
|
3433 | 1551 |
The index is a smalltalk index (i.e. 1-based). |
3459 | 1552 |
The value is retrieved MSB-first if the msb-arg is true, |
1553 |
LSB-first otherwise. |
|
1554 |
This may be worth a primitive." |
|
3323 | 1555 |
|
3459 | 1556 |
^ (self wordAt:index MSB:msb) signExtendedShortValue |
3323 | 1557 |
|
1558 |
" |
|
1559 |
|b| |
|
3459 | 1560 |
b := ByteArray new:2. |
1561 |
b wordAt:1 put:16r0080. |
|
1562 |
b signedWordAt:1 MSB:true. |
|
1563 |
b signedWordAt:1 MSB:false. |
|
1564 |
" |
|
1565 |
||
1566 |
"Modified: 1.7.1996 / 21:15:57 / cg" |
|
1567 |
! |
|
1568 |
||
1569 |
signedWordAt:index put:value |
|
1570 |
"set the 2-bytes starting at index from the signed Integer value. |
|
1571 |
The index is a smalltalk index (i.e. 1-based). |
|
1572 |
The stored value must be in the range -32768 .. +32676. |
|
1573 |
The value is stored in the machines natural byteorder. |
|
1574 |
This may be worth a primitive. |
|
1575 |
This is the ST80 equivalent of #signedWordAt:put:" |
|
1576 |
||
1577 |
||
1578 |
|v| |
|
1579 |
||
1580 |
value >= 0 ifTrue:[ |
|
1581 |
v := value |
|
1582 |
] ifFalse:[ |
|
1583 |
v := 16r10000 + value |
|
1584 |
]. |
|
1585 |
self unsignedShortAt:index put:v. |
|
1586 |
^ value |
|
1587 |
||
1588 |
" |
|
1589 |
|b| |
|
1590 |
b := ByteArray new:6. |
|
1591 |
b shortAt:1 put:-1. |
|
1592 |
b shortAt:3 put:-2. |
|
1593 |
b shortAt:5 put:0. |
|
3323 | 1594 |
b inspect |
1595 |
" |
|
1596 |
||
3459 | 1597 |
"Modified: / 1.7.1996 / 21:12:07 / cg" |
1598 |
"Modified: / 5.3.1998 / 11:01:30 / stefan" |
|
1599 |
! |
|
1600 |
||
1601 |
signedWordAt:index put:value MSB:msb |
|
1602 |
"set the 2-bytes starting at index from the signed Integer value. |
|
1603 |
The index is a smalltalk index (i.e. 1-based). |
|
1604 |
The stored value must be in the range -32768 .. +32676. |
|
1605 |
The value is stored MSB-first, if the msb-arg is true; |
|
1606 |
LSB-first otherwise. |
|
1607 |
This may be worth a primitive." |
|
1608 |
||
1609 |
|v| |
|
1610 |
||
1611 |
value >= 0 ifTrue:[ |
|
1612 |
v := value |
|
1613 |
] ifFalse:[ |
|
1614 |
v := 16r10000 + value |
|
1615 |
]. |
|
1616 |
self wordAt:index put:v MSB:msb. |
|
1617 |
^ value |
|
1618 |
||
1619 |
" |
|
1620 |
|b| |
|
1621 |
b := ByteArray new:4. |
|
1622 |
b signedWordAt:1 put:-1. |
|
1623 |
b signedWordAt:3 put:-2. |
|
1624 |
b inspect |
|
1625 |
" |
|
1626 |
||
1627 |
"Modified: 1.7.1996 / 21:12:13 / cg" |
|
3323 | 1628 |
! |
1629 |
||
1630 |
unsignedShortAt:index |
|
1631 |
"return the 2-bytes starting at index as an (unsigned) Integer. |
|
3433 | 1632 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1633 |
The value is retrieved in the machines natural byte order |
1634 |
Subclasses may redefine this for better performance. |
|
1635 |
This is the ST80 equivalent of #wordAt:" |
|
1636 |
||
1637 |
||
4019
c9284ca27a4a
tuned some doubleWordAt methods;
Claus Gittinger <cg@exept.de>
parents:
3936
diff
changeset
|
1638 |
^ self unsignedShortAt:index bigEndian:(UninterpretedBytes isBigEndian) |
3323 | 1639 |
|
1640 |
"Created: / 5.3.1998 / 11:38:25 / stefan" |
|
1641 |
"Modified: / 5.3.1998 / 14:59:25 / stefan" |
|
1642 |
! |
|
1643 |
||
1644 |
unsignedShortAt:index bigEndian:msb |
|
1645 |
"return the 2-bytes starting at index as an (unsigned) Integer. |
|
3433 | 1646 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1647 |
The value is retrieved MSB-first (high 8 bits at lower index) if msb is true; |
1648 |
LSB-first (i.e. low 8-bits at lower byte index) if its false)" |
|
1649 |
||
1650 |
|b1 "{ Class: SmallInteger }" |
|
1651 |
b2 "{ Class: SmallInteger }"| |
|
1652 |
||
1653 |
b1 := self at:index. |
|
1654 |
b2 := self at:(index + 1). |
|
1655 |
msb ifTrue:[ |
|
1656 |
^ (b1 bitShift:8) + b2 |
|
1657 |
]. |
|
1658 |
^ (b2 bitShift:8) + b1 |
|
1659 |
||
1660 |
"Modified: / 21.1.1998 / 17:46:07 / cg" |
|
1661 |
"Created: / 5.3.1998 / 11:49:29 / stefan" |
|
1662 |
! |
|
1663 |
||
1664 |
unsignedShortAt:index put:value |
|
1665 |
"set the 2-bytes starting at index from the (unsigned) Integer value. |
|
3433 | 1666 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1667 |
The stored value must be in the range 0 .. 16rFFFF. |
1668 |
The value is stored in the machines natural byteorder." |
|
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 | 1671 |
|
1672 |
" |
|
1673 |
|b| |
|
1674 |
b := ByteArray new:4. |
|
1675 |
b unsignedShortAt:1 put:16r0102. |
|
1676 |
b unsignedShortAt:3 put:16r0304. |
|
1677 |
b inspect |
|
1678 |
" |
|
1679 |
||
1680 |
"Created: / 5.3.1998 / 11:54:52 / stefan" |
|
1681 |
"Modified: / 5.3.1998 / 14:59:38 / stefan" |
|
1682 |
! |
|
1683 |
||
1684 |
unsignedShortAt:index put:value bigEndian:msb |
|
1685 |
"set the 2-bytes starting at index from the (unsigned) Integer value. |
|
3433 | 1686 |
The index is a smalltalk index (i.e. 1-based). |
3323 | 1687 |
The stored value must be in the range 0 .. 16rFFFF. |
1688 |
The value is stored LSB-first (i.e. the low 8bits are stored at the |
|
1689 |
lower index) if msb is false, MSB-first otherwise" |
|
1690 |
||
1691 |
|b1 b2 |
|
1692 |
iVal "{ Class: SmallInteger }"| |
|
1693 |
||
1694 |
iVal := value. |
|
1695 |
((iVal < 0) or:[iVal > 16rFFFF]) ifTrue:[ |
|
1696 |
^ self elementBoundsError |
|
1697 |
]. |
|
1698 |
msb ifTrue:[ |
|
1699 |
b1 := ((iVal bitShift:-8) bitAnd:16rFF). |
|
1700 |
b2 := (iVal bitAnd:16rFF). |
|
1701 |
] ifFalse:[ |
|
1702 |
b1 := (iVal bitAnd:16rFF). |
|
1703 |
b2 := ((iVal bitShift:-8) bitAnd:16rFF). |
|
1704 |
]. |
|
1705 |
self at:index put:b1. |
|
1706 |
self at:index+1 put:b2. |
|
1707 |
^ value |
|
1708 |
||
1709 |
" |
|
1710 |
|b| |
|
1711 |
b := ByteArray new:8. |
|
1712 |
b unsignedShortAt:1 put:16r0102 bigEndian:false. |
|
1713 |
b unsignedShortAt:3 put:16r0304 bigEndian:false. |
|
1714 |
b unsignedShortAt:5 put:16r0102 bigEndian:true. |
|
1715 |
b unsignedShortAt:7 put:16r0304 bigEndian:true. |
|
1716 |
b inspect |
|
1717 |
" |
|
1718 |
||
1719 |
"Modified: / 21.1.1998 / 17:48:15 / cg" |
|
1720 |
"Modified: / 5.3.1998 / 11:52:28 / stefan" |
|
1721 |
! |
|
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 | 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 | 1730 |
|
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 | 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 | 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 | 1770 |
|
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 | 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 | 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 | 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 | 1860 |
! ! |
1861 |
||
1862 |
!UninterpretedBytes methodsFor:'accessing-strings'! |
|
1863 |
||
1864 |
stringAt:index |
|
1865 |
"return a string starting at index up to the 0-byte. |
|
1866 |
The index is a smalltalk index (i.e. 1-based)." |
|
1867 |
||
1868 |
|stream i "{ Class: SmallInteger }" c| |
|
1869 |
||
1870 |
stream := WriteStream on:''. |
|
1871 |
i := index. |
|
1872 |
[(c := self basicAt:i) ~~ 0] whileTrue:[ |
|
1873 |
stream nextPut:(Character value:c). |
|
1874 |
i := i + 1. |
|
1875 |
]. |
|
1876 |
^ stream contents |
|
1877 |
||
1878 |
"Created: / 21.1.1998 / 17:44:50 / cg" |
|
1879 |
! |
|
1880 |
||
1881 |
stringAt:index put:aString |
|
1882 |
"copy aString to the externalBytes, starting at index up to |
|
1883 |
(and including) the 0-byte. |
|
1884 |
The index is a smalltalk index (i.e. 1-based)." |
|
1885 |
||
1886 |
|i "{ Class: SmallInteger }"| |
|
1887 |
||
1888 |
i := index. |
|
1889 |
aString do:[:aChar | |
|
1890 |
self basicAt:i put:aChar asciiValue. |
|
1891 |
i := i + 1. |
|
1892 |
]. |
|
1893 |
self basicAt:i put:0. |
|
1894 |
^ aString |
|
1895 |
||
1896 |
" |
|
1897 |
|bytes| |
|
1898 |
||
1899 |
bytes := ExternalBytes new:10. |
|
1900 |
bytes stringAt:1 put:'hello'. |
|
1901 |
1 to:bytes size do:[:i | |
|
1902 |
Transcript showCR:(bytes at:i) |
|
1903 |
] |
|
1904 |
" |
|
1905 |
||
1906 |
"Created: / 21.1.1998 / 17:45:02 / cg" |
|
1907 |
! |
|
1908 |
||
1909 |
stringAt:index size:maxSize |
|
1910 |
"return a string starting at index up to maxSize, or a 0-byte. |
|
1911 |
The index is a smalltalk index (i.e. 1-based)." |
|
1912 |
||
1913 |
|stream c i "{ Class: SmallInteger }"| |
|
1914 |
||
1915 |
stream := WriteStream on:(String new:maxSize). |
|
1916 |
i := index. |
|
1917 |
[(i <= maxSize) |
|
1918 |
and:[(c := self basicAt:i) ~~ 0]] whileTrue:[ |
|
1919 |
stream nextPut:(Character value:c). |
|
1920 |
i := i + 1. |
|
1921 |
]. |
|
1922 |
^ stream contents |
|
1923 |
||
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 | 1929 |
maximum number of characters (bytes). |
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 | 1945 |
"swap the byteOrder of a long. |
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 | 1960 |
!UninterpretedBytes methodsFor:'queries'! |
1961 |
||
1962 |
sizeInBytes |
|
1963 |
"return the number of 8-bit bytes in the receiver. |
|
1964 |
This is needed since subclasse may redefine #size (TwoByteString)" |
|
1965 |
||
1966 |
^ super size |
|
1967 |
||
1968 |
"Created: / 5.3.1998 / 10:41:13 / stefan" |
|
1969 |
! ! |
|
1970 |
||
695 | 1971 |
!UninterpretedBytes class methodsFor:'documentation'! |
1972 |
||
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 | 1975 |
! ! |