2003/11/22 06:44:38
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:01 +0000 (07:42 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:01 +0000 (07:42 +0000)
darcs-hash:20040130074201-2ba56-1db8491b1bc01fe1519d7f0423b441abaf63aac6.gz

Makefile
src/org/xwt/Box.java

index d0c0dd2..a14148e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -211,7 +211,8 @@ build/res/freetype.mips: build/mips/org/xwt/translators/Freetype.c.o build/mips/
                $^ \
                -lfreetype
 
                $^ \
                -lfreetype
 
-.install_libmspack-20030726:; make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf && touch .install_libmspack-20030726
+.install_libmspack-20030726_mips-unknown-elf:
+       make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
 build/mips/org/xwt/translators/MSPack.c.o: .install_libmspack-20030726
 build/res/libmspack.mips: build/mips/org/xwt/translators/MSPack.c.o build/mips/org/xwt/mips/crt0.c.o build/mips/org/xwt/mips/syscalls.c.o
        @echo -e "\n\033[1mlinking               .o -> .mips:  $@\033[0m"
 build/mips/org/xwt/translators/MSPack.c.o: .install_libmspack-20030726
 build/res/libmspack.mips: build/mips/org/xwt/translators/MSPack.c.o build/mips/org/xwt/mips/crt0.c.o build/mips/org/xwt/mips/syscalls.c.o
        @echo -e "\n\033[1mlinking               .o -> .mips:  $@\033[0m"
index b7512bb..fb36594 100644 (file)
@@ -412,12 +412,11 @@ public final class Box extends JSScope {
         case "Minimized": if (parent == null && getSurface() != null) return B(getSurface().minimized);
         default: return super.get(name);
         //#end
         case "Minimized": if (parent == null && getSurface() != null) return B(getSurface().minimized);
         default: return super.get(name);
         //#end
-        return null;
+        throw new Error("unreachable"); // unreachable
     }
 
     public void put(Object name, Object value) {
         if (name instanceof Number) { put(toInt(name), value); return; }
     }
 
     public void put(Object name, Object value) {
         if (name instanceof Number) { put(toInt(name), value); return; }
-
         //#switch(name)
         case "text": CHECKSET_STRING(text); MARK_RESIZE; dirty();
         case "strokecolor": value = N(stringToColor((String)value)); CHECKSET_INT(strokecolor); MARK_RESIZE; dirty();
         //#switch(name)
         case "text": CHECKSET_STRING(text); MARK_RESIZE; dirty();
         case "strokecolor": value = N(stringToColor((String)value)); CHECKSET_INT(strokecolor); MARK_RESIZE; dirty();
@@ -468,12 +467,13 @@ public final class Box extends JSScope {
         case "fontsize": font = Font.getFont(font == null ? null : font.res, toInt(value)); MARK_RESIZE; dirty();
         case "x": if (test(PACKED) && parent != null) return; CHECKSET_INT(x); dirty(); MARK_RESIZE; dirty();
         case "y": if (test(PACKED) && parent != null) return; CHECKSET_INT(y); dirty(); MARK_RESIZE; dirty();
         case "fontsize": font = Font.getFont(font == null ? null : font.res, toInt(value)); MARK_RESIZE; dirty();
         case "x": if (test(PACKED) && parent != null) return; CHECKSET_INT(x); dirty(); MARK_RESIZE; dirty();
         case "y": if (test(PACKED) && parent != null) return; CHECKSET_INT(y); dirty(); MARK_RESIZE; dirty();
-        case "KeyPressed":     // prevent stuff from hitting the Hash
-        case "KeyReleased":    // prevent stuff from hitting the Hash
-        case "PosChange":      // prevent stuff from hitting the Hash
-        case "SizeChange":     // prevent stuff from hitting the Hash
-        case "childadded":     // prevent stuff from hitting the Hash
-        case "childremoved":   // prevent stuff from hitting the Hash
+        case "KeyPressed":   return;  // prevent stuff from hitting the Hash
+        case "KeyReleased":   return; // prevent stuff from hitting the Hash
+        case "PosChange":   return;   // prevent stuff from hitting the Hash
+        case "SizeChange":   return;  // prevent stuff from hitting the Hash
+        case "childadded":   return;  // prevent stuff from hitting the Hash
+        case "childremoved": return;  // prevent stuff from hitting the Hash
+        default: super.put(name, value);
         //#end
     }
 
         //#end
     }
 
@@ -646,8 +646,8 @@ public final class Box extends JSScope {
     public final Box peerTree_rightmost() { for (Box p = this; ; p = p.right) if (p.right == null) return p; }
     static Box     peerTree_parent(Box p) { return (p == null)? null: p.peerTree_parent; }
 
     public final Box peerTree_rightmost() { for (Box p = this; ; p = p.right) if (p.right == null) return p; }
     static Box     peerTree_parent(Box p) { return (p == null)? null: p.peerTree_parent; }
 
-    public Box insertBeforeMe(Box cell) { left = cell; cell.peerTree_parent = this; return cell.fixAfterInsertion(); }
-    public Box insertAfterMe(Box cell) { right = cell; cell.peerTree_parent = this; return cell.fixAfterInsertion(); }
+    public void insertBeforeMe(Box cell) { left = cell; cell.peerTree_parent = this; cell.fixAfterInsertion(); }
+    public void insertAfterMe(Box cell) { right = cell; cell.peerTree_parent = this; cell.fixAfterInsertion(); }
 
     static boolean colorOf(Box p) { return (p == null) ? BLACKbool : p.test(BLACK); }
     static void    setColor(Box p, boolean c) { if (p != null) { if (c) p.set(BLACK); else p.clear(BLACK); } }
 
     static boolean colorOf(Box p) { return (p == null) ? BLACKbool : p.test(BLACK); }
     static void    setColor(Box p, boolean c) { if (p != null) { if (c) p.set(BLACK); else p.clear(BLACK); } }
@@ -676,11 +676,10 @@ public final class Box extends JSScope {
         }
     }
 
         }
     }
 
-    public Box removeNode() {
-        Box root = peerTree_parent.rootChild;
+    public void removeNode() {
 
         // handle case where we are only node
 
         // handle case where we are only node
-        if (left == null && right == null && peerTree_parent == null) return null;
+        if (left == null && right == null && peerTree_parent == null) return;
 
         // if strictly internal, swap places with a successor
         if (left != null && right != null) {
 
         // if strictly internal, swap places with a successor
         if (left != null && right != null) {
@@ -688,7 +687,7 @@ public final class Box extends JSScope {
             // To work nicely with arbitrary subclasses of Box, we don't want to
             // just copy successor's fields. since we don't know what
             // they are.  Instead we swap positions in the tree.
             // To work nicely with arbitrary subclasses of Box, we don't want to
             // just copy successor's fields. since we don't know what
             // they are.  Instead we swap positions in the tree.
-            root = swapPosition(this, s);
+            swapPosition(this, s);
         }
 
         // Start fixup at replacement node (normally a child).
         }
 
         // Start fixup at replacement node (normally a child).
@@ -696,7 +695,7 @@ public final class Box extends JSScope {
 
         if (left == null && right == null) {
       
 
         if (left == null && right == null) {
       
-            if (test(BLACK)) root = this.fixAfterDeletion();
+            if (test(BLACK)) fixAfterDeletion();
 
             // Unlink  (Couldn't before since fixAfterDeletion needs peerTree_parent ptr)
 
 
             // Unlink  (Couldn't before since fixAfterDeletion needs peerTree_parent ptr)
 
@@ -716,28 +715,25 @@ public final class Box extends JSScope {
             // link replacement to peerTree_parent 
             replacement.peerTree_parent = peerTree_parent;
 
             // link replacement to peerTree_parent 
             replacement.peerTree_parent = peerTree_parent;
 
-            if (peerTree_parent == null)             root = replacement; 
+            if (peerTree_parent == null) parent.rootChild = replacement; 
             else if (this == peerTree_parent.left)  peerTree_parent.left  = replacement;
             else if (this == peerTree_parent.left)  peerTree_parent.left  = replacement;
-            else                             peerTree_parent.right = replacement;
+            else peerTree_parent.right = replacement;
 
             left = null;
             right = null;
             peerTree_parent = null;
 
             // fix replacement
 
             left = null;
             right = null;
             peerTree_parent = null;
 
             // fix replacement
-            if (test(BLACK)) root = replacement.fixAfterDeletion();
+            if (test(BLACK)) replacement.fixAfterDeletion();
       
         }
       
         }
-
-        return root;
     }
 
     /**
      * Swap the linkages of two nodes in a tree.
      * Return new root, in case it changed.
      **/
     }
 
     /**
      * Swap the linkages of two nodes in a tree.
      * Return new root, in case it changed.
      **/
-    Box swapPosition(Box x, Box y) {
-        Box root = peerTree_parent.rootChild;
+    void swapPosition(Box x, Box y) {
 
         /* Too messy. TODO: find sequence of assigments that are always OK */
 
 
         /* Too messy. TODO: find sequence of assigments that are always OK */
 
@@ -795,45 +791,39 @@ public final class Box extends JSScope {
         if (y.test(BLACK)) x.set(BLACK); else x.clear(BLACK);
         if (c) y.set(BLACK); else y.clear(BLACK);
 
         if (y.test(BLACK)) x.set(BLACK); else x.clear(BLACK);
         if (c) y.set(BLACK); else y.clear(BLACK);
 
-        if (root == x) root = y;
-        else if (root == y) root = x;
-        return parent.rootChild = root;
+        if (parent.rootChild == x) parent.rootChild = y;
+        else if (parent.rootChild == y) parent.rootChild = x;
     }
 
     }
 
-    Box rotateLeft() {
-        Box root = parent.rootChild;
+    void rotateLeft() {
         Box r = right;
         right = r.left;
         if (r.left != null) r.left.peerTree_parent = this;
         r.peerTree_parent = peerTree_parent;
         Box r = right;
         right = r.left;
         if (r.left != null) r.left.peerTree_parent = this;
         r.peerTree_parent = peerTree_parent;
-        if (peerTree_parent == null) root = r;
+        if (peerTree_parent == null) parent.rootChild = r;
         else if (peerTree_parent.left == this) peerTree_parent.left = r;
         else peerTree_parent.right = r;
         r.left = this;
         peerTree_parent = r;
         else if (peerTree_parent.left == this) peerTree_parent.left = r;
         else peerTree_parent.right = r;
         r.left = this;
         peerTree_parent = r;
-        return parent.rootChild = root;
     }
 
     }
 
-    Box rotateRight() {
-        Box root = parent.rootChild;
+    void rotateRight() {
         Box l = left;
         left = l.right;
         if (l.right != null) l.right.peerTree_parent = this;
         l.peerTree_parent = peerTree_parent;
         Box l = left;
         left = l.right;
         if (l.right != null) l.right.peerTree_parent = this;
         l.peerTree_parent = peerTree_parent;
-        if (peerTree_parent == null) root = l;
+        if (peerTree_parent == null) parent.rootChild = l;
         else if (peerTree_parent.right == this) peerTree_parent.right = l;
         else peerTree_parent.left = l;
         l.right = this;
         peerTree_parent = l;
         else if (peerTree_parent.right == this) peerTree_parent.right = l;
         else peerTree_parent.left = l;
         l.right = this;
         peerTree_parent = l;
-        return parent.rootChild;
     }
 
     }
 
-    Box fixAfterInsertion() {
-        Box root = parent.rootChild;
+    void fixAfterInsertion() {
         clear(BLACK);
         Box x = this;
     
         clear(BLACK);
         Box x = this;
     
-        while (x != null && x != root && !x.peerTree_parent.test(BLACK)) {
+        while (x != null && x != parent.rootChild && !x.peerTree_parent.test(BLACK)) {
             if (peerTree_parent(x) == leftOf(peerTree_parent(peerTree_parent(x)))) {
                 Box y = rightOf(peerTree_parent(peerTree_parent(x)));
                 if (colorOf(y) == REDbool) {
             if (peerTree_parent(x) == leftOf(peerTree_parent(peerTree_parent(x)))) {
                 Box y = rightOf(peerTree_parent(peerTree_parent(x)));
                 if (colorOf(y) == REDbool) {
@@ -845,12 +835,12 @@ public final class Box extends JSScope {
                 else {
                     if (x == rightOf(peerTree_parent(x))) {
                         x = peerTree_parent(x);
                 else {
                     if (x == rightOf(peerTree_parent(x))) {
                         x = peerTree_parent(x);
-                        root = x.rotateLeft();
+                        x.rotateLeft();
                     }
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(peerTree_parent(peerTree_parent(x)), REDbool);
                     if (peerTree_parent(peerTree_parent(x)) != null) 
                     }
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(peerTree_parent(peerTree_parent(x)), REDbool);
                     if (peerTree_parent(peerTree_parent(x)) != null) 
-                        root = peerTree_parent(peerTree_parent(x)).rotateRight();
+                        peerTree_parent(peerTree_parent(x)).rotateRight();
                 }
             }
             else {
                 }
             }
             else {
@@ -864,30 +854,28 @@ public final class Box extends JSScope {
                 else {
                     if (x == leftOf(peerTree_parent(x))) {
                         x = peerTree_parent(x);
                 else {
                     if (x == leftOf(peerTree_parent(x))) {
                         x = peerTree_parent(x);
-                        root = x.rotateRight();
+                        x.rotateRight();
                     }
                     setColor(peerTree_parent(x),  BLACKbool);
                     setColor(peerTree_parent(peerTree_parent(x)), REDbool);
                     if (peerTree_parent(peerTree_parent(x)) != null) 
                     }
                     setColor(peerTree_parent(x),  BLACKbool);
                     setColor(peerTree_parent(peerTree_parent(x)), REDbool);
                     if (peerTree_parent(peerTree_parent(x)) != null) 
-                        root = peerTree_parent(peerTree_parent(x)).rotateLeft();
+                        peerTree_parent(peerTree_parent(x)).rotateLeft();
                 }
             }
         }
                 }
             }
         }
-        root.set(BLACK);
-        return parent.rootChild = root;
+        parent.rootChild.set(BLACK);
     }
 
     /** From CLR **/
     }
 
     /** From CLR **/
-    Box fixAfterDeletion() {
-        Box root = peerTree_parent.rootChild;
+    void fixAfterDeletion() {
         Box x = this;
         Box x = this;
-        while (x != root && colorOf(x) == BLACKbool) {
+        while (x != parent.rootChild && colorOf(x) == BLACKbool) {
             if (x == leftOf(peerTree_parent(x))) {
                 Box sib = rightOf(peerTree_parent(x));
                 if (colorOf(sib) == REDbool) {
                     setColor(sib, BLACKbool);
                     setColor(peerTree_parent(x), REDbool);
             if (x == leftOf(peerTree_parent(x))) {
                 Box sib = rightOf(peerTree_parent(x));
                 if (colorOf(sib) == REDbool) {
                     setColor(sib, BLACKbool);
                     setColor(peerTree_parent(x), REDbool);
-                    root = peerTree_parent(x).rotateLeft();
+                    peerTree_parent(x).rotateLeft();
                     sib = rightOf(peerTree_parent(x));
                 }
                 if (colorOf(leftOf(sib)) == BLACKbool && colorOf(rightOf(sib)) == BLACKbool) {
                     sib = rightOf(peerTree_parent(x));
                 }
                 if (colorOf(leftOf(sib)) == BLACKbool && colorOf(rightOf(sib)) == BLACKbool) {
@@ -898,14 +886,14 @@ public final class Box extends JSScope {
                     if (colorOf(rightOf(sib)) == BLACKbool) {
                         setColor(leftOf(sib), BLACKbool);
                         setColor(sib, REDbool);
                     if (colorOf(rightOf(sib)) == BLACKbool) {
                         setColor(leftOf(sib), BLACKbool);
                         setColor(sib, REDbool);
-                        root = sib.rotateRight();
+                        sib.rotateRight();
                         sib = rightOf(peerTree_parent(x));
                     }
                     setColor(sib, colorOf(peerTree_parent(x)));
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(rightOf(sib), BLACKbool);
                         sib = rightOf(peerTree_parent(x));
                     }
                     setColor(sib, colorOf(peerTree_parent(x)));
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(rightOf(sib), BLACKbool);
-                    root = peerTree_parent(x).rotateLeft();
-                    x = root;
+                    peerTree_parent(x).rotateLeft();
+                    x = parent.rootChild;
                 }
             }
             else {
                 }
             }
             else {
@@ -913,7 +901,7 @@ public final class Box extends JSScope {
                 if (colorOf(sib) == REDbool) {
                     setColor(sib, BLACKbool);
                     setColor(peerTree_parent(x), REDbool);
                 if (colorOf(sib) == REDbool) {
                     setColor(sib, BLACKbool);
                     setColor(peerTree_parent(x), REDbool);
-                    root = peerTree_parent(x).rotateRight();
+                    peerTree_parent(x).rotateRight();
                     sib = leftOf(peerTree_parent(x));
                 }
                 if (colorOf(rightOf(sib)) == BLACKbool && colorOf(leftOf(sib)) == BLACKbool) {
                     sib = leftOf(peerTree_parent(x));
                 }
                 if (colorOf(rightOf(sib)) == BLACKbool && colorOf(leftOf(sib)) == BLACKbool) {
@@ -924,19 +912,18 @@ public final class Box extends JSScope {
                     if (colorOf(leftOf(sib)) == BLACKbool) {
                         setColor(rightOf(sib), BLACKbool);
                         setColor(sib, REDbool);
                     if (colorOf(leftOf(sib)) == BLACKbool) {
                         setColor(rightOf(sib), BLACKbool);
                         setColor(sib, REDbool);
-                        root = sib.rotateLeft();
+                        sib.rotateLeft();
                         sib = leftOf(peerTree_parent(x));
                     }
                     setColor(sib, colorOf(peerTree_parent(x)));
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(leftOf(sib), BLACKbool);
                         sib = leftOf(peerTree_parent(x));
                     }
                     setColor(sib, colorOf(peerTree_parent(x)));
                     setColor(peerTree_parent(x), BLACKbool);
                     setColor(leftOf(sib), BLACKbool);
-                    root = peerTree_parent(x).rotateRight();
-                    x = root;
+                    peerTree_parent(x).rotateRight();
+                    x = parent.rootChild;
                 }
             }
         }
         setColor(x, BLACKbool);
                 }
             }
         }
         setColor(x, BLACKbool);
-        return parent.rootChild = root;
     }
 
     // Tree Manipulation /////////////////////////////////////////////////////////////////////
     }
 
     // Tree Manipulation /////////////////////////////////////////////////////////////////////