ByteArray.st
changeset 4829 b0791306880b
parent 4809 ec743bebdd72
child 4919 ba0dbdaceab1
--- a/ByteArray.st	Sun Oct 03 10:43:25 1999 +0200
+++ b/ByteArray.st	Sun Oct 03 10:45:31 1999 +0200
@@ -1669,6 +1669,46 @@
     "
 !
 
+copyReverse
+    "reverse the order of my elements inplace - 
+     written as a primitive for speed on image manipulations (mirror)"
+
+%{  /* NOCONTEXT */
+
+    REGISTER unsigned char *src, *dst;
+    REGISTER int cnt;
+    REGISTER unsigned t;
+    OBJ cls;
+    OBJ newByteArray;
+    int sz;
+    unsigned char *start;
+
+    if (__qClass(self) == @global(ByteArray)) {
+        cnt = __byteArraySize(self);
+        __PROTECT_CONTEXT__
+        sz = OHDR_SIZE + cnt;
+        __qNew(newByteArray, sz);       /* OBJECT ALLOCATION */
+        __UNPROTECT_CONTEXT__
+        if (newByteArray != nil) {
+            __InstPtr(newByteArray)->o_class = ByteArray;
+            src = __ByteArrayInstPtr(self)->ba_element;
+            start = __ByteArrayInstPtr(newByteArray)->ba_element;
+            dst = start + cnt - 1;
+            while (dst >= start) {
+                *dst-- = *src++;
+            }
+            RETURN ( newByteArray );
+        }
+    }
+%}.
+    ^ super copy reverse
+
+    "
+     #[1 2 3 4 5] copyReverse
+     #[1 2 3 4] copyReverse
+    "
+!
+
 expandPixels:nBitsPerPixel width:width height:height into:aByteArray mapping:aMapByteArray
     "given the receiver with nBitsPerPixel-depth pixels, expand them into
      aByteArray with 8-bit pixels. The width/height-arguments are needed
@@ -2382,5 +2422,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.121 1999-09-24 18:18:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.122 1999-10-03 08:45:31 cg Exp $'
 ! !