81 |
81 |
82 documentation |
82 documentation |
83 " |
83 " |
84 UninterpretedBytes provides the common protocol for byte-storage |
84 UninterpretedBytes provides the common protocol for byte-storage |
85 containers; concrete subclasses are |
85 containers; concrete subclasses are |
86 ByteArray (which store the bytes within the Smalltalk object memory) |
86 ByteArray (which store the bytes within the Smalltalk object memory) |
87 String (which is a subclass of ByteArray) knows that the bytes represent characters |
87 String (which is a subclass of ByteArray) knows that the bytes represent characters |
88 and |
88 and |
89 ExternalBytes (which store the bytes in the malloc-heap). |
89 ExternalBytes (which store the bytes in the malloc-heap). |
90 |
90 |
91 UninterpretedBytes itself is abstract, so no instances of it can be created. |
91 UninterpretedBytes itself is abstract, so no instances of it can be created. |
92 |
92 |
93 [See also:] |
93 [See also:] |
94 ByteArray String ExternalBytes |
94 ByteArray String ExternalBytes |
95 |
95 |
96 [author:] |
96 [author:] |
97 Claus Gittinger |
97 Claus Gittinger |
98 |
98 |
99 [Notice:] |
99 [Notice:] |
100 Notice the confusion due to multiple methods with the same |
100 Notice the confusion due to multiple methods with the same |
101 functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:'). |
101 functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:'). |
102 The reason is that at the time this class was written, |
102 The reason is that at the time this class was written, |
103 ST80 sid not offer protocol to specify the byteOrder, and |
103 ST80 sid not offer protocol to specify the byteOrder, and |
104 ST/X provided methods ending in 'MSB:' for this. |
104 ST/X provided methods ending in 'MSB:' for this. |
105 In the meanwhile, VW added protocol ending in 'bigEndian:', |
105 In the meanwhile, VW added protocol ending in 'bigEndian:', |
106 which has been added here for compatibility. |
106 which has been added here for compatibility. |
107 (certainly a point, where an ansi-standard will help) |
107 (certainly a point, where an ansi-standard will help) |
108 " |
108 " |
109 ! ! |
109 ! ! |
110 |
110 |
111 !UninterpretedBytes class methodsFor:'initialization'! |
111 !UninterpretedBytes class methodsFor:'initialization'! |
112 |
112 |
142 sz odd ifTrue:[ ConversionError raiseWith:aString errorString:'invalid hex string (odd size)' ]. |
142 sz odd ifTrue:[ ConversionError raiseWith:aString errorString:'invalid hex string (odd size)' ]. |
143 |
143 |
144 bytes := self new: sz // 2. |
144 bytes := self new: sz // 2. |
145 s := aString readStream. |
145 s := aString readStream. |
146 1 to: sz // 2 do: [ :idx | |
146 1 to: sz // 2 do: [ :idx | |
147 hi := s next digitValue. |
147 hi := s next digitValue. |
148 lo := s next digitValue. |
148 lo := s next digitValue. |
149 bytes at:idx put: ((hi bitShift:4) bitOr: lo) |
149 bytes at:idx put: ((hi bitShift:4) bitOr: lo) |
150 ]. |
150 ]. |
151 ^ bytes |
151 ^ bytes |
152 |
152 |
153 " |
153 " |
154 ByteArray fromHexString:'1234FEFF' |
154 ByteArray fromHexString:'1234FEFF' |
198 6bits are encoded per character. The argument, aString must be a multiple |
198 6bits are encoded per character. The argument, aString must be a multiple |
199 of 4 in size (since 24 is the lcm of 6 and 8). This is somewhat like |
199 of 4 in size (since 24 is the lcm of 6 and 8). This is somewhat like |
200 the radix-encoding used in good old PDP11 times ;-) |
200 the radix-encoding used in good old PDP11 times ;-) |
201 ST-80 uses this encoding for Images ... |
201 ST-80 uses this encoding for Images ... |
202 This is a base64 encoding, very similar (but not equal) to the algorithm used in RFC1421. |
202 This is a base64 encoding, very similar (but not equal) to the algorithm used in RFC1421. |
203 PS: It took a while to figure that one out ... |
203 PS: It took a while to figure that one out ... |
204 I don't like it ;-)" |
204 I don't like it ;-)" |
205 |
205 |
206 |index "{ Class: SmallInteger }" |
206 |index "{ Class: SmallInteger }" |
207 dstIndex "{ Class: SmallInteger }" |
207 dstIndex "{ Class: SmallInteger }" |
208 stop "{ Class: SmallInteger }" |
208 stop "{ Class: SmallInteger }" |
219 "the size modulo 3 is encoded in the last character, if it is in the |
219 "the size modulo 3 is encoded in the last character, if it is in the |
220 range 97 .. otherwise, its exact." |
220 range 97 .. otherwise, its exact." |
221 |
221 |
222 last := aString last codePoint. |
222 last := aString last codePoint. |
223 last > 96 ifTrue:[ |
223 last > 96 ifTrue:[ |
224 stop := stop - 3 + (last - 96) |
224 stop := stop - 3 + (last - 96) |
225 ]. |
225 ]. |
226 bytes := self new:stop. |
226 bytes := self new:stop. |
227 |
227 |
228 index := 1. dstIndex := 1. |
228 index := 1. dstIndex := 1. |
229 [dstIndex <= stop] whileTrue:[ |
229 [dstIndex <= stop] whileTrue:[ |
230 "/ take 4 characters ... |
230 "/ take 4 characters ... |
231 "/ allow a line break before each group of 4 |
231 "/ allow a line break before each group of 4 |
232 sixBits := (aString at:index) codePoint. |
232 sixBits := (aString at:index) codePoint. |
233 [sixBits < 32] whileTrue:[ |
233 [sixBits < 32] whileTrue:[ |
234 index := index + 1. |
234 index := index + 1. |
235 sixBits := (aString at:index) codePoint. |
235 sixBits := (aString at:index) codePoint. |
236 ]. |
236 ]. |
237 sixBits := sixBits bitAnd:16r3F. |
237 sixBits := sixBits bitAnd:16r3F. |
238 n := sixBits. |
238 n := sixBits. |
239 |
239 |
240 "/ self assert:(aString at:index+1) codePoint >= 32. |
240 "/ self assert:(aString at:index+1) codePoint >= 32. |
241 sixBits := (aString at:index+1) codePoint bitAnd:16r3F. |
241 sixBits := (aString at:index+1) codePoint bitAnd:16r3F. |
242 n := (n bitShift:6) + sixBits. |
242 n := (n bitShift:6) + sixBits. |
243 |
243 |
244 "/ self assert:(aString at:index+2) codePoint >= 32. |
244 "/ self assert:(aString at:index+2) codePoint >= 32. |
245 sixBits := (aString at:index+2) codePoint bitAnd:16r3F. |
245 sixBits := (aString at:index+2) codePoint bitAnd:16r3F. |
246 n := (n bitShift:6) + sixBits. |
246 n := (n bitShift:6) + sixBits. |
247 |
247 |
248 "/ self assert:(aString at:index+3) codePoint >= 32. |
248 "/ self assert:(aString at:index+3) codePoint >= 32. |
249 sixBits := (aString at:index+3) codePoint bitAnd:16r3F. |
249 sixBits := (aString at:index+3) codePoint bitAnd:16r3F. |
250 n := (n bitShift:6) + sixBits. |
250 n := (n bitShift:6) + sixBits. |
251 |
251 |
252 index := index + 4. |
252 index := index + 4. |
253 |
253 |
254 "/ now have 24 bits in n |
254 "/ now have 24 bits in n |
255 |
255 |
256 bytes at:dstIndex put:(n bitShift:-16). |
256 bytes at:dstIndex put:(n bitShift:-16). |
257 |
257 |
258 dstIndex < stop ifTrue:[ |
258 dstIndex < stop ifTrue:[ |
259 bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF). |
259 bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF). |
260 dstIndex+2 <= stop ifTrue:[ |
260 dstIndex+2 <= stop ifTrue:[ |
261 bytes at:dstIndex+2 put:(n bitAnd:16rFF). |
261 bytes at:dstIndex+2 put:(n bitAnd:16rFF). |
262 ] |
262 ] |
263 ]. |
263 ]. |
264 dstIndex := dstIndex + 3. |
264 dstIndex := dstIndex + 3. |
265 ]. |
265 ]. |
266 ^ bytes |
266 ^ bytes |
267 |
267 |
268 " |
268 " |
269 ByteArray fromPackedString:(#[1 1 1 1] asPackedString) |
269 ByteArray fromPackedString:(#[1 1 1 1] asPackedString) |
294 OBJ newobj; |
294 OBJ newobj; |
295 INT instsize, nInstVars, nindexedinstvars; |
295 INT instsize, nInstVars, nindexedinstvars; |
296 REGISTER OBJ *op; |
296 REGISTER OBJ *op; |
297 |
297 |
298 if (__isSmallInteger(anInteger)) { |
298 if (__isSmallInteger(anInteger)) { |
299 nindexedinstvars = __intVal(anInteger); |
299 nindexedinstvars = __intVal(anInteger); |
300 if (nindexedinstvars >= 0) { |
300 if (nindexedinstvars >= 0) { |
301 if (self == ByteArray) { |
301 if (self == ByteArray) { |
302 /* |
302 /* |
303 * the most common case |
303 * the most common case |
304 */ |
304 */ |
305 instsize = OHDR_SIZE + nindexedinstvars; |
305 instsize = OHDR_SIZE + nindexedinstvars; |
306 if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */ |
306 if (__CanDoQuickNew(instsize)) { /* OBJECT ALLOCATION */ |
307 __qCheckedNew(newobj, instsize); |
307 __qCheckedNew(newobj, instsize); |
308 __InstPtr(newobj)->o_class = self; |
308 __InstPtr(newobj)->o_class = self; |
309 __qSTORE(newobj, self); |
309 __qSTORE(newobj, self); |
310 RETURN (newobj ); |
310 RETURN (newobj ); |
311 } |
311 } |
312 } else { |
312 } else { |
313 /* |
313 /* |
314 * Take care for subclasses like TwoByteString |
314 * Take care for subclasses like TwoByteString |
315 */ |
315 */ |
316 switch (__smallIntegerVal(__ClassInstPtr(self)->c_flags) & ARRAYMASK) { |
316 switch (__smallIntegerVal(__ClassInstPtr(self)->c_flags) & ARRAYMASK) { |
317 case BYTEARRAY: |
317 case BYTEARRAY: |
318 break; |
318 break; |
319 |
319 |
320 case WORDARRAY: |
320 case WORDARRAY: |
321 case SWORDARRAY: |
321 case SWORDARRAY: |
322 nindexedinstvars *= 2; |
322 nindexedinstvars *= 2; |
323 break; |
323 break; |
324 |
324 |
325 case LONGARRAY: |
325 case LONGARRAY: |
326 case SLONGARRAY: |
326 case SLONGARRAY: |
327 nindexedinstvars *= 4; |
327 nindexedinstvars *= 4; |
328 break; |
328 break; |
329 |
329 |
330 default: |
330 default: |
331 /* don't know about this array type, delegate to super */ |
331 /* don't know about this array type, delegate to super */ |
332 goto out; |
332 goto out; |
333 } |
333 } |
334 } |
334 } |
335 nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars); |
335 nInstVars = __intVal(__ClassInstPtr(self)->c_ninstvars); |
336 instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars; |
336 instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars) + nindexedinstvars; |
337 __PROTECT_CONTEXT__ |
337 __PROTECT_CONTEXT__ |
338 __qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
338 __qNew(newobj, instsize); /* OBJECT ALLOCATION */ |
339 __UNPROTECT_CONTEXT__ |
339 __UNPROTECT_CONTEXT__ |
340 if (newobj != nil) { |
340 if (newobj != nil) { |
341 __InstPtr(newobj)->o_class = self; |
341 __InstPtr(newobj)->o_class = self; |
342 __qSTORE(newobj, self); |
342 __qSTORE(newobj, self); |
343 if (nInstVars) { |
343 if (nInstVars) { |
344 /* |
344 /* |
345 * still have to nil out named instvars ... |
345 * still have to nil out named instvars ... |
346 */ |
346 */ |
347 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) |
347 #if defined(memset4) && defined(FAST_OBJECT_MEMSET4) |
348 memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
348 memset4(__InstPtr(newobj)->i_instvars, nil, nInstVars); |
349 #else |
349 #else |
350 # if defined(FAST_MEMSET) && !defined(NEGATIVE_ADDRESSES) |
350 # if defined(FAST_MEMSET) && !defined(NEGATIVE_ADDRESSES) |
351 /* |
351 /* |
352 * knowing that nil is 0 |
352 * knowing that nil is 0 |
353 */ |
353 */ |
354 memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
354 memset(__InstPtr(newobj)->i_instvars, 0, instsize - OHDR_SIZE); |
355 # else |
355 # else |
356 op = __InstPtr(newobj)->i_instvars; |
356 op = __InstPtr(newobj)->i_instvars; |
357 while (nInstVars--) |
357 while (nInstVars--) |
358 *op++ = nil; |
358 *op++ = nil; |
359 # endif |
359 # endif |
360 #endif |
360 #endif |
361 } |
361 } |
362 RETURN ( newobj ); |
362 RETURN ( newobj ); |
363 } |
363 } |
364 } |
364 } |
365 } |
365 } |
366 out:; |
366 out:; |
367 %}. |
367 %}. |
368 ^ self basicNew:anInteger |
368 ^ self basicNew:anInteger |
369 ! |
369 ! |
536 Useful to extract arbitrary long integers" |
538 Useful to extract arbitrary long integers" |
537 |
539 |
538 |val| |
540 |val| |
539 |
541 |
540 val := 0. |
542 val := 0. |
541 bigEndian ifTrue:[ |
543 bigEndian ifTrue:[ |
542 index to:index+n-1 do:[:i | |
544 index to:index+n-1 do:[:i | |
543 val := (val<<8) + (self at:i) |
545 val := (val<<8) + (self at:i) |
544 ] |
546 ] |
545 ] ifFalse:[ |
547 ] ifFalse:[ |
546 index+n-1 to:index by:-1 do:[:i | |
548 index+n-1 to:index by:-1 do:[:i | |
547 val := (val<<8) + (self at:i) |
549 val := (val<<8) + (self at:i) |
548 ] |
550 ] |
549 ]. |
551 ]. |
550 ^ val |
552 ^ val |
551 |
553 |
552 " |
554 " |
553 |b| |
555 |b| |
554 b := #[ 16r01 16r02 16r03 16r04 16r05 ]. |
556 b := #[ 16r01 16r02 16r03 16r04 16r05 ]. |
555 (b unsignedIntegerAt:2 length:4 bigEndian:false). |
557 (b unsignedIntegerAt:2 length:4 bigEndian:false). |
556 (b unsignedIntegerAt:2 length:4 bigEndian:true). |
558 (b unsignedIntegerAt:2 length:4 bigEndian:true). |
557 " |
559 " |
558 ! ! |
560 ! ! |
559 |
561 |
560 !UninterpretedBytes methodsFor:'accessing-bytes'! |
562 !UninterpretedBytes methodsFor:'accessing-bytes'! |
561 |
563 |
707 machine, some conversion is usually needed." |
709 machine, some conversion is usually needed." |
708 |
710 |
709 |newFloat| |
711 |newFloat| |
710 |
712 |
711 msb == IsBigEndian ifTrue:[ |
713 msb == IsBigEndian ifTrue:[ |
712 ^ self doubleAt:index. |
714 ^ self doubleAt:index. |
713 ]. |
715 ]. |
714 |
716 |
715 newFloat := Float basicNew. |
717 newFloat := Float basicNew. |
716 1 to:8 do:[:destIndex| |
718 1 to:8 do:[:destIndex| |
717 newFloat basicAt:(9-destIndex) put:(self at:index - 1 + destIndex) |
719 newFloat basicAt:(9-destIndex) put:(self at:index - 1 + destIndex) |
718 ]. |
720 ]. |
719 ^ newFloat. |
721 ^ newFloat. |
720 |
722 |
721 "Created: / 15.5.1998 / 17:21:45 / cg" |
723 "Created: / 15.5.1998 / 17:21:45 / cg" |
722 ! |
724 ! |
735 %{ |
737 %{ |
736 /* |
738 /* |
737 * handle the most common cases fast ... |
739 * handle the most common cases fast ... |
738 */ |
740 */ |
739 if (__isSmallInteger(index)) { |
741 if (__isSmallInteger(index)) { |
740 unsigned char *cp; |
742 unsigned char *cp; |
741 INT sz; |
743 INT sz; |
742 |
744 |
743 __fetchBytePointerAndSize__(self, &cp, &sz); |
745 __fetchBytePointerAndSize__(self, &cp, &sz); |
744 if (cp) { |
746 if (cp) { |
745 unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
747 unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
746 |
748 |
747 if ((idx+(sizeof(double)-1)) < sz) { |
749 if ((idx+(sizeof(double)-1)) < sz) { |
748 cp += idx; |
750 cp += idx; |
749 /* |
751 /* |
750 * aligned |
752 * aligned |
751 */ |
753 */ |
752 if (((INT)cp & (sizeof(double)-1)) == 0) { |
754 if (((INT)cp & (sizeof(double)-1)) == 0) { |
753 if (__isFloat(aFloat)) { |
755 if (__isFloat(aFloat)) { |
754 ((double *)cp)[0] = __floatVal(aFloat); |
756 ((double *)cp)[0] = __floatVal(aFloat); |
755 RETURN (aFloat); |
757 RETURN (aFloat); |
756 } |
758 } |
757 if (__isShortFloat(aFloat)) { |
759 if (__isShortFloat(aFloat)) { |
758 ((double *)cp)[0] = (double)(__shortFloatVal(aFloat)); |
760 ((double *)cp)[0] = (double)(__shortFloatVal(aFloat)); |
759 RETURN (aFloat); |
761 RETURN (aFloat); |
760 } |
762 } |
761 if (__isSmallInteger(aFloat)) { |
763 if (__isSmallInteger(aFloat)) { |
762 ((double *)cp)[0] = (double)(__intVal(aFloat)); |
764 ((double *)cp)[0] = (double)(__intVal(aFloat)); |
763 RETURN (aFloat); |
765 RETURN (aFloat); |
764 } |
766 } |
765 } |
767 } |
766 } |
768 } |
767 } |
769 } |
768 } |
770 } |
769 %}. |
771 %}. |
770 |
772 |
771 flt := aFloat asFloat. |
773 flt := aFloat asFloat. |
772 1 to:8 do:[:srcIndex| |
774 1 to:8 do:[:srcIndex| |
773 self at:index - 1 + srcIndex put:(flt basicAt:srcIndex) |
775 self at:index - 1 + srcIndex put:(flt basicAt:srcIndex) |
774 ]. |
776 ]. |
775 ^ aFloat |
777 ^ aFloat |
776 ! |
778 ! |
777 |
779 |
778 doubleAt:index put:aFloat MSB:msb |
780 doubleAt:index put:aFloat MSB:msb |
785 machine, some conversion is usually needed." |
787 machine, some conversion is usually needed." |
786 |
788 |
787 |flt| |
789 |flt| |
788 |
790 |
789 msb == IsBigEndian ifTrue:[ |
791 msb == IsBigEndian ifTrue:[ |
790 ^ self doubleAt:index put:aFloat. |
792 ^ self doubleAt:index put:aFloat. |
791 ]. |
793 ]. |
792 |
794 |
793 flt := aFloat asFloat. |
795 flt := aFloat asFloat. |
794 1 to:8 do:[:srcIndex| |
796 1 to:8 do:[:srcIndex| |
795 self at:index - 1 + srcIndex put:(flt basicAt:(9-srcIndex)) |
797 self at:index - 1 + srcIndex put:(flt basicAt:(9-srcIndex)) |
796 ]. |
798 ]. |
797 ^ aFloat |
799 ^ aFloat |
798 |
800 |
799 "Created: / 15.5.1998 / 17:22:27 / cg" |
801 "Created: / 15.5.1998 / 17:22:27 / cg" |
800 "Modified: / 15.5.1998 / 17:26:29 / cg" |
802 "Modified: / 15.5.1998 / 17:26:29 / cg" |
859 machine, some conversion is usually needed." |
861 machine, some conversion is usually needed." |
860 |
862 |
861 |newFloat| |
863 |newFloat| |
862 |
864 |
863 msb == IsBigEndian ifTrue:[ |
865 msb == IsBigEndian ifTrue:[ |
864 ^ self floatAt:index |
866 ^ self floatAt:index |
865 ]. |
867 ]. |
866 |
868 |
867 newFloat := ShortFloat basicNew. |
869 newFloat := ShortFloat basicNew. |
868 1 to:4 do:[:destIndex| |
870 1 to:4 do:[:destIndex| |
869 newFloat basicAt:(5-destIndex) put:(self at:index - 1 + destIndex) |
871 newFloat basicAt:(5-destIndex) put:(self at:index - 1 + destIndex) |
870 ]. |
872 ]. |
871 ^ newFloat. |
873 ^ newFloat. |
872 |
874 |
873 "Modified: / 15.5.1998 / 17:20:19 / cg" |
875 "Modified: / 15.5.1998 / 17:20:19 / cg" |
874 "Created: / 15.5.1998 / 17:20:35 / cg" |
876 "Created: / 15.5.1998 / 17:20:35 / cg" |
888 %{ |
890 %{ |
889 /* |
891 /* |
890 * handle the most common cases fast ... |
892 * handle the most common cases fast ... |
891 */ |
893 */ |
892 if (__isSmallInteger(index)) { |
894 if (__isSmallInteger(index)) { |
893 unsigned char *cp; |
895 unsigned char *cp; |
894 INT sz; |
896 INT sz; |
895 |
897 |
896 __fetchBytePointerAndSize__(self, &cp, &sz); |
898 __fetchBytePointerAndSize__(self, &cp, &sz); |
897 if (cp) { |
899 if (cp) { |
898 unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
900 unsigned INT idx = ((unsigned INT)__intVal(index)) - 1; |
899 |
901 |
900 if ((idx+(sizeof(float)-1)) < sz) { |
902 if ((idx+(sizeof(float)-1)) < sz) { |
901 cp += idx; |
903 cp += idx; |
902 /* |
904 /* |
903 * aligned |
905 * aligned |
904 */ |
906 */ |
905 if (((INT)cp & (sizeof(float)-1)) == 0) { |
907 if (((INT)cp & (sizeof(float)-1)) == 0) { |
906 if (__isShortFloat(aFloat)) { |
908 if (__isShortFloat(aFloat)) { |
907 ((float *)cp)[0] = __shortFloatVal(aFloat); |
909 ((float *)cp)[0] = __shortFloatVal(aFloat); |
908 RETURN (self); |
910 RETURN (self); |
909 } |
911 } |
910 if (__isFloat(aFloat)) { |
912 if (__isFloat(aFloat)) { |
911 ((float *)cp)[0] = (float)__floatVal(aFloat); |
913 ((float *)cp)[0] = (float)__floatVal(aFloat); |
912 RETURN (self); |
914 RETURN (self); |
913 } |
915 } |
914 if (__isSmallInteger(aFloat)) { |
916 if (__isSmallInteger(aFloat)) { |
915 ((float *)cp)[0] = (float)__intVal(aFloat); |
917 ((float *)cp)[0] = (float)__intVal(aFloat); |
916 RETURN (self); |
918 RETURN (self); |
917 } |
919 } |
918 // bail out to smalltalk code |
920 // bail out to smalltalk code |
919 } |
921 } |
920 } |
922 } |
921 } |
923 } |
922 } |
924 } |
923 %}. |
925 %}. |
924 |
926 |
925 sflt := aFloat asShortFloat. |
927 sflt := aFloat asShortFloat. |
926 1 to:4 do:[:srcIndex| |
928 1 to:4 do:[:srcIndex| |
927 self at:index - 1 + srcIndex put:(sflt basicAt:srcIndex) |
929 self at:index - 1 + srcIndex put:(sflt basicAt:srcIndex) |
928 ]. |
930 ]. |
929 ! |
931 ! |
930 |
932 |
931 floatAt:index put:aFloat MSB:msb |
933 floatAt:index put:aFloat MSB:msb |
932 "store the 4 bytes of value of the argument, aFloat into the receiver |
934 "store the 4 bytes of value of the argument, aFloat into the receiver |
938 machine, some conversion is usually needed." |
940 machine, some conversion is usually needed." |
939 |
941 |
940 |sflt| |
942 |sflt| |
941 |
943 |
942 msb == IsBigEndian ifTrue:[ |
944 msb == IsBigEndian ifTrue:[ |
943 self floatAt:index put:aFloat. |
945 self floatAt:index put:aFloat. |
944 ^ self. |
946 ^ self. |
945 ]. |
947 ]. |
946 |
948 |
947 sflt := aFloat asShortFloat. |
949 sflt := aFloat asShortFloat. |
948 1 to:4 do:[:srcIndex| |
950 1 to:4 do:[:srcIndex| |
949 self at:index - 1 + srcIndex put:(sflt basicAt:(5-srcIndex)) |
951 self at:index - 1 + srcIndex put:(sflt basicAt:(5-srcIndex)) |
950 ]. |
952 ]. |
951 |
953 |
952 "Created: / 15.5.1998 / 17:20:41 / cg" |
954 "Created: / 15.5.1998 / 17:20:41 / cg" |
953 ! |
955 ! |
954 |
956 |