--- a/ByteArray.st Tue Apr 22 13:52:28 1997 +0200
+++ b/ByteArray.st Tue Apr 22 20:59:18 1997 +0200
@@ -53,14 +53,14 @@
and store C-structure fields.
[warning:]
- read the warning about 'growing fixed size collection'
- in ArrayedCollection's documentation
+ read the warning about 'growing fixed size collection'
+ in ArrayedCollection's documentation
[author:]
- Claus Gittinger
+ Claus Gittinger
[See also:]
- Array CharacterArray String
+ Array CharacterArray String
"
! !
@@ -90,42 +90,42 @@
lastCharacter := aString last.
lastCharacter asciiValue > 96 ifTrue:[
- stop := stop - 3 + lastCharacter asciiValue - 96
+ stop := stop - 3 + lastCharacter asciiValue - 96
].
bytes := self new:stop.
index := 1. dstIndex := 1.
[dstIndex <= stop] whileTrue:[
- "take 4 characters ..."
- sixBits := (aString at:index) asciiValue.
- sixBits := sixBits bitAnd:16r3F.
- n := sixBits.
+ "take 4 characters ..."
+ sixBits := (aString at:index) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := sixBits.
- sixBits := (aString at:index+1) asciiValue.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
+ sixBits := (aString at:index+1) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
- sixBits := (aString at:index+2) asciiValue.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
+ sixBits := (aString at:index+2) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
- sixBits := (aString at:index+3) asciiValue.
- sixBits := sixBits bitAnd:16r3F.
- n := (n bitShift:6) + sixBits.
+ sixBits := (aString at:index+3) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
- index := index + 4.
+ index := index + 4.
- "/ now have 24 bits in n
+ "/ now have 24 bits in n
- bytes at:dstIndex put:(n bitShift:-16).
+ bytes at:dstIndex put:(n bitShift:-16).
- dstIndex < stop ifTrue:[
- bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
- dstIndex+2 <= stop ifTrue:[
- bytes at:dstIndex+2 put:(n bitAnd:16rFF).
- ]
- ].
- dstIndex := dstIndex + 3.
+ dstIndex < stop ifTrue:[
+ bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
+ dstIndex+2 <= stop ifTrue:[
+ bytes at:dstIndex+2 put:(n bitAnd:16rFF).
+ ]
+ ].
+ dstIndex := dstIndex + 3.
].
^ bytes
@@ -295,23 +295,23 @@
REGISTER OBJ cls;
if (__bothSmallInteger(index, value)) {
- val = __intVal(value);
- if ((unsigned)(val) <= 0xFF /* i.e. (val >= 0) && (val <= 255) */) {
- indx = __intVal(index) - 1;
- slf = self;
- if ((cls = __qClass(slf)) != @global(ByteArray)) {
- if (((INT)__ClassInstPtr(cls)->c_flags & __MASKSMALLINT(ARRAYMASK))
- != __MASKSMALLINT(BYTEARRAY)) {
- goto fail;
- }
- indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
- }
- nIndex = __byteArraySize(slf);
- if ((unsigned)indx < (unsigned)nIndex) {
- __ByteArrayInstPtr(slf)->ba_element[indx] = val;
- RETURN ( value );
- }
- }
+ val = __intVal(value);
+ if ((unsigned)(val) <= 0xFF /* i.e. (val >= 0) && (val <= 255) */) {
+ indx = __intVal(index) - 1;
+ slf = self;
+ if ((cls = __qClass(slf)) != @global(ByteArray)) {
+ if (((INT)__ClassInstPtr(cls)->c_flags & __MASKSMALLINT(ARRAYMASK))
+ != __MASKSMALLINT(BYTEARRAY)) {
+ goto fail;
+ }
+ indx += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+ }
+ nIndex = __byteArraySize(slf);
+ if ((unsigned)indx < (unsigned)nIndex) {
+ __ByteArrayInstPtr(slf)->ba_element[indx] = val;
+ RETURN ( value );
+ }
+ }
}
fail: ;
%}.
@@ -731,15 +731,15 @@
l := LargeInteger basicNew numberOfDigits:8.
msb ifTrue:[
- bIdx := index + 7.
- delta := -1
+ bIdx := index + 7.
+ delta := -1
] ifFalse:[
- bIdx := index.
- delta := 1
+ bIdx := index.
+ delta := 1
].
1 to:8 do:[:i |
- l digitAt:i put:(self basicAt:bIdx).
- bIdx := bIdx + delta
+ l digitAt:i put:(self basicAt:bIdx).
+ bIdx := bIdx + delta
].
^ l compressed
@@ -815,9 +815,9 @@
|b "{ Class: SmallInteger }"|
aSignedByteValue >= 0 ifTrue:[
- b := aSignedByteValue
+ b := aSignedByteValue
] ifFalse:[
- b := 16r100 + aSignedByteValue
+ b := 16r100 + aSignedByteValue
].
self at:index put:b.
^ aSignedByteValue
@@ -841,14 +841,14 @@
w := self doubleWordAt:index.
(w > (16r7FFFFFFF)) ifTrue:[
- ^ w - (16r100000000)
+ ^ w - (16r100000000)
].
^ w
"
w := self doubleWordAt:index.
(w > 16r7FFFFFFF) ifTrue:[
- ^ w - 16r100000000
+ ^ w - 16r100000000
].
^ w
"
@@ -872,13 +872,13 @@
w := self doubleWordAt:index MSB:msb.
(w > (16r7FFFFFFF)) ifTrue:[
- ^ w - (16r100000000)
+ ^ w - (16r100000000)
].
^ w
"
w := self doubleWordAt:index.
(w > 16r7FFFFFFF) ifTrue:[
- ^ w - 16r100000000
+ ^ w - 16r100000000
].
^ w
"
@@ -901,9 +901,9 @@
|v|
value >= 0 ifTrue:[
- v := value
+ v := value
] ifFalse:[
- v := value + 16r100000000
+ v := value + 16r100000000
].
self doubleWordAt:index put:v.
^ value
@@ -926,9 +926,9 @@
|v|
value >= 0 ifTrue:[
- v := value
+ v := value
] ifFalse:[
- v := value + 16r100000000
+ v := value + 16r100000000
].
self doubleWordAt:index put:v MSB:msb.
^ value
@@ -1004,9 +1004,9 @@
|v|
value >= 0 ifTrue:[
- v := value
+ v := value
] ifFalse:[
- v := 16r10000 + value
+ v := 16r10000 + value
].
self wordAt:index put:v.
^ value
@@ -1033,9 +1033,9 @@
|v|
value >= 0 ifTrue:[
- v := value
+ v := value
] ifFalse:[
- v := 16r10000 + value
+ v := 16r10000 + value
].
self wordAt:index put:v MSB:msb.
^ value
@@ -1253,7 +1253,7 @@
"not, if I have named instance variables"
(myClass := self class) instSize ~~ 0 ifTrue:[
- ^ super storeBinaryDefinitionOn:stream manager:manager
+ ^ super storeBinaryDefinitionOn:stream manager:manager
].
manager putIdOfClass:myClass on: stream.
stream nextNumber:4 put:(myBasicSize := self basicSize).
@@ -1364,13 +1364,38 @@
}
value = __intVal(aNumber);
- if (((value & ~0xFF) == 0) /* i.e. (value >= 0) && (value <= 255) */
+ if (((unsigned)value <= 0xFF) /* i.e. (value >= 0) && (value <= 255) */
&& (index1 <= index2)
&& (index1 > 0)) {
if (index2 <= len) {
count = index2 - index1 + 1;
+
+#ifdef memset4
+ if (count > 20) {
+ while (((unsigned)dstp & 3) != 0) {
+ *dstp++ = value;
+ count--;
+ }
+ {
+ int n4 = count & ~3;
+ int v4, nW;
+
+ v4 = (value << 8) | value;
+ v4 = (v4 << 16) | v4;
+ nW = n4>>2;
+ memset4(dstp, v4, nW);
+ count -= n4;
+ dstp += n4;
+ }
+ while (count--) {
+ *dstp++ = value;
+ }
+ RETURN (self);
+ }
+#endif /* memset4 */
+
#ifdef FAST_MEMSET
- memset(dstp, count, value);
+ memset(dstp, value, count);
#else
# ifdef UNROLL_LOOPS
while (count >= 8) {
@@ -1379,7 +1404,7 @@
dstp += 8;
count -= 8;
}
-# endif
+# endif /* UNROLL_LOOPS */
while (count--) {
*dstp++ = value;
}
@@ -1456,12 +1481,14 @@
RETURN ( self );
}
}
-#ifdef FAST_MEMCPY
-# ifdef bcopy4
- if (((src & 3) == 0)
- && ((dst & 3) == 0)) {
+
+#ifdef bcopy4
+ if ((((unsigned)src & 3) == 0)
+ && (((unsigned)dst & 3) == 0)) {
/* copy aligned part */
- bcopy4(src, dst, count//4);
+ int nW = count >> 2;
+
+ bcopy4(src, dst, nW);
/* copy rest */
if (count & 3) {
src += (count & ~3);
@@ -1471,10 +1498,23 @@
*dst++ = *src++;
}
}
- } else
-# endif /* bcopy4 */
- bcopy(src, dst, count);
+ RETURN ( self );
+ }
+#endif /* bcopy4 */
+
+#ifdef FAST_MEMCPY
+ bcopy(src, dst, count);
#else
+# ifdef UNROLL_LOOPS
+ while (count >= 8) {
+ dst[0] = src[0]; dst[1] = src[1];
+ dst[2] = src[2]; dst[3] = src[3];
+ dst[4] = src[4]; dst[5] = src[5];
+ dst[6] = src[6]; dst[7] = src[7];
+ dst += 8; src += 8;
+ count -= 8;
+ }
+# endif /* UNROLL_LOOPS */
while (count-- > 0) {
*dst++ = *src++;
}
@@ -1498,7 +1538,7 @@
with elements taken from replacementCollection starting at repStart."
(aCollection class == self class) ifTrue:[
- ^ self replaceBytesFrom:start to:stop with:aCollection startingAt:repStart
+ ^ self replaceBytesFrom:start to:stop with:aCollection startingAt:repStart
].
^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
@@ -1508,7 +1548,7 @@
!ByteArray methodsFor:'image manipulation support'!
compressPixels:nBitsPerPixel width:width height:height into:aByteArray
- mapping:aMapByteArray
+ mapping:aMapByteArray
"given the receiver with 8-bit pixels, compress them into aByteArray
with nBitsPerPixel-depth pixels. The width/height-arguments are needed
@@ -1540,82 +1580,82 @@
&& (__qClass(aByteArray) == @global(ByteArray))
&& __isSmallInteger(nBitsPerPixel)
&& __bothSmallInteger(height, width)) {
- if ((aMapByteArray != nil)
- && (__Class(aMapByteArray) == @global(ByteArray))) {
- map = __ByteArrayInstPtr(aMapByteArray)->ba_element;
- } else {
- map = (unsigned char *)0;
- }
+ if ((aMapByteArray != nil)
+ && (__Class(aMapByteArray) == @global(ByteArray))) {
+ map = __ByteArrayInstPtr(aMapByteArray)->ba_element;
+ } else {
+ map = (unsigned char *)0;
+ }
- bitsPerPixel = __intVal(nBitsPerPixel);
- w = __intVal(width);
- h = __intVal(height);
- src = __ByteArrayInstPtr(self)->ba_element;
- dst = __ByteArrayInstPtr(aByteArray)->ba_element;
- dstEnd = dst + __byteArraySize(aByteArray);
- switch (bitsPerPixel) {
- case 1:
- mask = 0x01;
- break;
- case 2:
- mask = 0x03;
- break;
- case 4:
- mask = 0x0F;
- break;
- case 8:
- mask = 0xFF;
- break;
- default:
- goto fail;
- }
- if (map) {
- /*
- * if a map is present, it must have entries for
- * all possible byte-values (i.e. its size must be >= 256)
- */
- if ((__qSize(aMapByteArray) - OHDR_SIZE) < 256)
- goto fail;
- }
+ bitsPerPixel = __intVal(nBitsPerPixel);
+ w = __intVal(width);
+ h = __intVal(height);
+ src = __ByteArrayInstPtr(self)->ba_element;
+ dst = __ByteArrayInstPtr(aByteArray)->ba_element;
+ dstEnd = dst + __byteArraySize(aByteArray);
+ switch (bitsPerPixel) {
+ case 1:
+ mask = 0x01;
+ break;
+ case 2:
+ mask = 0x03;
+ break;
+ case 4:
+ mask = 0x0F;
+ break;
+ case 8:
+ mask = 0xFF;
+ break;
+ default:
+ goto fail;
+ }
+ if (map) {
+ /*
+ * if a map is present, it must have entries for
+ * all possible byte-values (i.e. its size must be >= 256)
+ */
+ if ((__qSize(aMapByteArray) - OHDR_SIZE) < 256)
+ goto fail;
+ }
- bytesPerRow = (w * bitsPerPixel + 7) / 8;
- dstBytes = bytesPerRow * h;
- srcBytes = w * h;
+ bytesPerRow = (w * bitsPerPixel + 7) / 8;
+ dstBytes = bytesPerRow * h;
+ srcBytes = w * h;
- if ((__byteArraySize(self) >= srcBytes)
- && (__byteArraySize(aByteArray) >= dstBytes)) {
- for (hrun=h; hrun; hrun--) {
- dstNext = dst + bytesPerRow;
- bits = 0; shift = 8;
- if (map) {
- for (wrun=w; wrun; wrun--) {
- bits = (bits << bitsPerPixel) | (map[*src++] & mask);
- shift -= bitsPerPixel;
- if (shift == 0) {
- if (dst == dstEnd) goto fail;
- *dst++ = bits;
- bits = 0; shift = 8;
- }
- }
- } else {
- for (wrun=w; wrun; wrun--) {
- bits = (bits << bitsPerPixel) | (*src++ & mask);
- shift -= bitsPerPixel;
- if (shift == 0) {
- if (dst == dstEnd) goto fail;
- *dst++ = bits;
- bits = 0; shift = 8;
- }
- }
- }
- if (shift != 8) {
- if (dst == dstEnd) goto fail;
- *dst = bits;
- }
- dst = dstNext;
- }
- RETURN ( self );
- }
+ if ((__byteArraySize(self) >= srcBytes)
+ && (__byteArraySize(aByteArray) >= dstBytes)) {
+ for (hrun=h; hrun; hrun--) {
+ dstNext = dst + bytesPerRow;
+ bits = 0; shift = 8;
+ if (map) {
+ for (wrun=w; wrun; wrun--) {
+ bits = (bits << bitsPerPixel) | (map[*src++] & mask);
+ shift -= bitsPerPixel;
+ if (shift == 0) {
+ if (dst == dstEnd) goto fail;
+ *dst++ = bits;
+ bits = 0; shift = 8;
+ }
+ }
+ } else {
+ for (wrun=w; wrun; wrun--) {
+ bits = (bits << bitsPerPixel) | (*src++ & mask);
+ shift -= bitsPerPixel;
+ if (shift == 0) {
+ if (dst == dstEnd) goto fail;
+ *dst++ = bits;
+ bits = 0; shift = 8;
+ }
+ }
+ }
+ if (shift != 8) {
+ if (dst == dstEnd) goto fail;
+ *dst = bits;
+ }
+ dst = dstNext;
+ }
+ RETURN ( self );
+ }
}
fail: ;
%}
@@ -1629,12 +1669,12 @@
|inBits outBits|
inBits := #[0 0 0 0 1 1 1 1
- 0 0 1 1 0 0 1 1
- 0 1 0 1 0 1 0 1
- 1 1 1 1 0 0 0 0].
+ 0 0 1 1 0 0 1 1
+ 0 1 0 1 0 1 0 1
+ 1 1 1 1 0 0 0 0].
outBits := ByteArray new:4.
inBits compressPixels:1 width:8 height:4
- into:outBits mapping:nil.
+ into:outBits mapping:nil.
outBits inspect
"
@@ -1651,7 +1691,7 @@
outBits := ByteArray new:2.
inBits compressPixels:1 width:16 height:1
- into:outBits mapping:map.
+ into:outBits mapping:map.
outBits inspect
"
@@ -1668,13 +1708,13 @@
outBits := ByteArray new:2.
inBits compressPixels:1 width:16 height:1
- into:outBits mapping:map.
+ into:outBits mapping:map.
outBits inspect
"
!
expandPixels:nBitsPerPixel width:width height:height into:aByteArray
- mapping:aMapByteArray
+ mapping:aMapByteArray
"given the receiver with nBitsPerPixel-depth pixels, expand them into
aByteArray with 8-bit pixels. The width/height-arguments are needed
@@ -1707,92 +1747,92 @@
&& (__qClass(aByteArray) == @global(ByteArray))
&& __isSmallInteger(nBitsPerPixel)
&& __bothSmallInteger(height, width)) {
- if ((aMapByteArray != nil)
- && (__Class(aMapByteArray) == @global(ByteArray))) {
- map = __ByteArrayInstPtr(aMapByteArray)->ba_element;
- } else {
- map = (unsigned char *)0;
- }
+ if ((aMapByteArray != nil)
+ && (__Class(aMapByteArray) == @global(ByteArray))) {
+ map = __ByteArrayInstPtr(aMapByteArray)->ba_element;
+ } else {
+ map = (unsigned char *)0;
+ }
- bitsPerPixel = __intVal(nBitsPerPixel);
- w = __intVal(width);
- h = __intVal(height);
- src = __ByteArrayInstPtr(self)->ba_element;
- dst = __ByteArrayInstPtr(aByteArray)->ba_element;
- switch (bitsPerPixel) {
- case 1:
- mask = 0x01;
- break;
- case 2:
- mask = 0x03;
- break;
- case 4:
- mask = 0x0F;
- break;
- case 8:
- mask = 0xFF;
- break;
- default:
+ bitsPerPixel = __intVal(nBitsPerPixel);
+ w = __intVal(width);
+ h = __intVal(height);
+ src = __ByteArrayInstPtr(self)->ba_element;
+ dst = __ByteArrayInstPtr(aByteArray)->ba_element;
+ switch (bitsPerPixel) {
+ case 1:
+ mask = 0x01;
+ break;
+ case 2:
+ mask = 0x03;
+ break;
+ case 4:
+ mask = 0x0F;
+ break;
+ case 8:
+ mask = 0xFF;
+ break;
+ default:
printf("invalid depth\n");
- goto fail;
- }
- ncells = mask + 1;
- if (map) {
- /*
- * if a map is present, it must have the correct size
- * (i.e. 2 raisedTo:nBitsPerPixel)
- */
- if ((__qSize(aMapByteArray) - OHDR_SIZE) < ncells) {
+ goto fail;
+ }
+ ncells = mask + 1;
+ if (map) {
+ /*
+ * if a map is present, it must have the correct size
+ * (i.e. 2 raisedTo:nBitsPerPixel)
+ */
+ if ((__qSize(aMapByteArray) - OHDR_SIZE) < ncells) {
printf("invalid map\n");
- goto fail;
- }
- }
+ goto fail;
+ }
+ }
- bytesPerRow = (w * bitsPerPixel + 7) / 8;
- shift0 = 8 - bitsPerPixel;
- srcBytes = bytesPerRow * h;
- dstBytes = w * h;
+ bytesPerRow = (w * bitsPerPixel + 7) / 8;
+ shift0 = 8 - bitsPerPixel;
+ srcBytes = bytesPerRow * h;
+ dstBytes = w * h;
- if ((__byteArraySize(self) >= srcBytes)
- && (__byteArraySize(aByteArray) >= dstBytes)) {
- for (hrun=h; hrun; hrun--) {
- srcNext = src + bytesPerRow;
- shift = shift0;
- if (map) {
- if (shift0 == 0) {
- /* translate only */
- for (wrun=w; wrun; wrun--) {
- bits = *src++;
- *dst++ = map[bits];
- }
- } else {
- for (wrun=w; wrun; wrun--) {
- if (shift == shift0) {
- bits = *src++;
- }
- *dst++ = map[(bits >> shift) & mask];
- shift -= bitsPerPixel;
- if (shift < 0) {
- shift = shift0;
- }
- }
- }
- } else {
- for (wrun=w; wrun; wrun--) {
- if (shift == shift0) {
- bits = *src++;
- }
- *dst++ = (bits >> shift) & mask;
- shift -= bitsPerPixel;
- if (shift < 0) {
- shift = shift0;
- }
- }
- }
- src = srcNext;
- }
- RETURN ( self );
- }
+ if ((__byteArraySize(self) >= srcBytes)
+ && (__byteArraySize(aByteArray) >= dstBytes)) {
+ for (hrun=h; hrun; hrun--) {
+ srcNext = src + bytesPerRow;
+ shift = shift0;
+ if (map) {
+ if (shift0 == 0) {
+ /* translate only */
+ for (wrun=w; wrun; wrun--) {
+ bits = *src++;
+ *dst++ = map[bits];
+ }
+ } else {
+ for (wrun=w; wrun; wrun--) {
+ if (shift == shift0) {
+ bits = *src++;
+ }
+ *dst++ = map[(bits >> shift) & mask];
+ shift -= bitsPerPixel;
+ if (shift < 0) {
+ shift = shift0;
+ }
+ }
+ }
+ } else {
+ for (wrun=w; wrun; wrun--) {
+ if (shift == shift0) {
+ bits = *src++;
+ }
+ *dst++ = (bits >> shift) & mask;
+ shift -= bitsPerPixel;
+ if (shift < 0) {
+ shift = shift0;
+ }
+ }
+ }
+ src = srcNext;
+ }
+ RETURN ( self );
+ }
}
printf("invalid args\n");
@@ -1808,12 +1848,12 @@
|inBits outBits|
inBits := #[2r11110000
- 2r11001100
- 2r01010101
- 2r00001111].
+ 2r11001100
+ 2r01010101
+ 2r00001111].
outBits := ByteArray new:(8*4).
inBits expandPixels:1 width:8 height:4
- into:outBits mapping:nil.
+ into:outBits mapping:nil.
outBits inspect
"
@@ -1827,7 +1867,7 @@
inBits := #[2r11110000 2r11001100].
outBits := ByteArray new:16.
inBits expandPixels:1 width:16 height:1
- into:outBits mapping:#[99 176].
+ into:outBits mapping:#[99 176].
outBits inspect
"
!
@@ -1844,30 +1884,30 @@
REGISTER int cnt;
if (__qClass(self) == @global(ByteArray)) {
- cnt = __byteArraySize(self);
- dst = __ByteArrayInstPtr(self)->ba_element;
- if (! ((int)dst & (sizeof(long)-1))) {
- ldst = (unsigned long *)dst;
- while (cnt > 16) {
- ldst[0] = ~(ldst[0]);
- ldst[1] = ~(ldst[1]);
- ldst[2] = ~(ldst[2]);
- ldst[3] = ~(ldst[3]);
- ldst += 4;
- cnt -= 16;
- }
- while (cnt >= sizeof(long)) {
- *ldst = ~(*ldst);
- ldst++;
- cnt -= sizeof(long);
- }
- dst = (unsigned char *)ldst;
- }
- while (cnt--) {
- *dst = ~(*dst);
- dst++;
- }
- RETURN ( self );
+ cnt = __byteArraySize(self);
+ dst = __ByteArrayInstPtr(self)->ba_element;
+ if (! ((int)dst & (sizeof(long)-1))) {
+ ldst = (unsigned long *)dst;
+ while (cnt > 16) {
+ ldst[0] = ~(ldst[0]);
+ ldst[1] = ~(ldst[1]);
+ ldst[2] = ~(ldst[2]);
+ ldst[3] = ~(ldst[3]);
+ ldst += 4;
+ cnt -= 16;
+ }
+ while (cnt >= sizeof(long)) {
+ *ldst = ~(*ldst);
+ ldst++;
+ cnt -= sizeof(long);
+ }
+ dst = (unsigned char *)ldst;
+ }
+ while (cnt--) {
+ *dst = ~(*dst);
+ dst++;
+ }
+ RETURN ( self );
}
%}
.
@@ -1993,28 +2033,28 @@
index := 1.
stop := self size.
[index <= stop] whileTrue:[
- "take 3 source bytes"
- n := (self at:index) bitShift:16.
- (index < stop) ifTrue:[
- nextIndex := index + 1.
- n := n bitOr:((self at:nextIndex) bitShift:8).
- (nextIndex < stop) ifTrue:[
- n := n bitOr:(self at:(index + 2)).
- ].
- ].
+ "take 3 source bytes"
+ n := (self at:index) bitShift:16.
+ (index < stop) ifTrue:[
+ nextIndex := index + 1.
+ n := n bitOr:((self at:nextIndex) bitShift:8).
+ (nextIndex < stop) ifTrue:[
+ n := n bitOr:(self at:(index + 2)).
+ ].
+ ].
- "took me a while to find that one out ..."
- n := n bitXor:16r820820.
+ "took me a while to find that one out ..."
+ n := n bitXor:16r820820.
- outStream nextPut:(Character value:(n bitShift:-18) + 32).
- outStream nextPut:(Character value:((n bitShift:-12) bitAnd:16r3F) + 32).
- outStream nextPut:(Character value:((n bitShift:-6) bitAnd:16r3F) + 32).
- outStream nextPut:(Character value:(n bitAnd:16r3F) + 32).
- index := index + 3.
+ outStream nextPut:(Character value:(n bitShift:-18) + 32).
+ outStream nextPut:(Character value:((n bitShift:-12) bitAnd:16r3F) + 32).
+ outStream nextPut:(Character value:((n bitShift:-6) bitAnd:16r3F) + 32).
+ outStream nextPut:(Character value:(n bitAnd:16r3F) + 32).
+ index := index + 3.
].
(mod := stop \\ 3) ~~ 0 ifTrue:[
- outStream position:(outStream position - 1).
- outStream nextPut:(Character value:(mod + 96)).
+ outStream position:(outStream position - 1).
+ outStream nextPut:(Character value:(mod + 96)).
].
^ outStream contents
@@ -2037,15 +2077,15 @@
|first|
self class == ByteArray ifTrue:[ "/ care for subclasses
- aStream nextPutAll:'#['.
- first := true.
- self do:[:byte |
- first ifFalse:[aStream space]
- ifTrue:[first := false].
- byte storeOn:aStream.
- ].
- aStream nextPutAll:']'.
- ^ self
+ aStream nextPutAll:'#['.
+ first := true.
+ self do:[:byte |
+ first ifFalse:[aStream space]
+ ifTrue:[first := false].
+ byte storeOn:aStream.
+ ].
+ aStream nextPutAll:']'.
+ ^ self
].
^ super storeOn:aStream
@@ -2266,5 +2306,5 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.77 1997-03-19 18:52:53 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.78 1997-04-22 18:59:18 cg Exp $'
! !