--- a/ByteArray.st Fri Feb 02 17:22:25 1996 +0100
+++ b/ByteArray.st Fri Feb 02 20:20:45 1996 +0100
@@ -1729,6 +1729,75 @@
}
%}.
^ super reverse
+!
+
+swapBytes
+ "swap bytes inplace -
+ written as a primitive for speed on image grabbing (if display order is different)"
+
+%{ /* NOCONTEXT */
+
+ REGISTER unsigned char *p;
+ REGISTER int cnt;
+ REGISTER unsigned t;
+
+ if (__qClass(self) == ByteArray) {
+ cnt = __byteArraySize(self);
+ cnt = cnt & ~1; /* make it even */
+ p = _ByteArrayInstPtr(self)->ba_element;
+ while (cnt > 0) {
+ t = p[0];
+ p[0] = p[1];
+ p[1] = t;
+ p += 2;
+ cnt -= 2;
+ }
+ RETURN ( self );
+ }
+%}.
+ ^ super swapBytes "/ rubbish - there is no one currenly
+
+ "
+ #[1 2 3 4 5 6 7 8 9 10] copy swapBytes
+ #[1 2 3 4 5 6 7 8 9 10 11] copy swapBytes
+ "
+!
+
+swapLongs
+ "swap long bytes inplace -
+ written as a primitive for speed on image grabbing (if display order is different)"
+
+%{ /* NOCONTEXT */
+
+ REGISTER unsigned char *p;
+ REGISTER int cnt;
+ REGISTER unsigned t1, t2;
+
+ if (__qClass(self) == ByteArray) {
+ cnt = __byteArraySize(self);
+ cnt = cnt & ~3; /* make it even */
+ p = _ByteArrayInstPtr(self)->ba_element;
+ while (cnt > 0) {
+ t = p[0];
+ p[0] = p[3];
+ p[3] = t;
+ t = p[1];
+ p[1] = p[2];
+ p[2] = t;
+ p += 4;
+ cnt -= 4;
+ }
+ RETURN ( self );
+ }
+%}.
+ ^ super swapLongs "/ rubbish - there is no one currenly
+
+ "
+ #[1 2 3 4 5 6 7 8 9] copy swapLongs
+ #[1 2 3 4 5 6 7 8 9 10] copy swapLongs
+ #[1 2 3 4 5 6 7 8 9 10 11] copy swapLongs
+ #[1 2 3 4 5 6 7 8 9 10 11 12] copy swapLongs
+ "
! !
!ByteArray methodsFor:'printing & storing'!
@@ -2008,5 +2077,5 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.43 1996-01-05 12:33:08 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.44 1996-02-02 19:20:45 cg Exp $'
! !