2003/09/23 08:24:59
[org.ibex.core.git] / src / org / xwt / Trap.java
index 3e6302b..c6c6a47 100644 (file)
@@ -19,12 +19,16 @@ public class Trap {
     private static final Hash PROHIBITED = new Hash(120, 3);
 
     static {
+        // FIXME: review
         String[] p = new String[] {
-            "sizetoimage", "shrink", "hshrink", "vshrink", "x", "y", "width", "height",
-            "flex", "hflex", "vflex", /*"cols", "rows",*/ "align", "invisible", "absolute", "globalx", "globaly",
-            "minwidth", "minheight", "height", "width", "maxwidth", "maxheight", 
-            "numchildren", "hpad", "vpad", "doublebuffered", "cursor",
-            "mousex", "mousey", "xwt", "static", "mouseinside", "root", "thisbox", "indexof", "svg"
+            "sizetoimage", "shrink", "hshrink", "vshrink", "x", "y",
+            "width", "height", "flex", "hflex", "vflex", "cols",
+            "rows", "align", "invisible", "absolute", "globalx",
+            "globaly", "minwidth", "minheight", "height", "width",
+            "maxwidth", "maxheight", "numchildren", "hpad", "vpad",
+            "doublebuffered", "cursor", "mousex", "mousey", "xwt",
+            "static", "mouseinside", "root", "thisbox", "indexof",
+            "path"
         };
         for(int i=0; i<p.length; i++) PROHIBITED.put(p[i], Boolean.TRUE);
     };
@@ -54,16 +58,15 @@ public class Trap {
      *  @param f the function to place as a trap
      */
     static void addTrap(Box trapee, Object name, JS.CompiledFunction f) {
-        if (trapee.traps == null) trapee.traps = new Hash(10, 3);
 
         // check if this script has already placed a trap on this property
-        for(Trap t = (Trap)trapee.traps.get(name); t != null; t = t.next)
+        for(Trap t = (Trap)trapee.get(name, Trap.class); t != null; t = t.next)
             if (t.f == f) return;
         
         // actually place the trap
         Trap t = new Trap();
-        t.next = (Trap)trapee.traps.get(name);
-        trapee.traps.put(name, t);
+        t.next = (Trap)trapee.get(name, Trap.class);
+        trapee.put(name, Trap.class, t);
         t.trapee = trapee;
         t.name = name;
         t.f = f;
@@ -77,18 +80,16 @@ public class Trap {
      *  @param f the function to remove
      */
     static void delTrap(Box trapee, Object name, JS.CompiledFunction f) {
-        if (trapee.traps != null) {
-            Trap t = (Trap)trapee.traps.get(name);
-            if (t.f == f) {
-                trapee.traps.put(name, t.next);
+        Trap t = (Trap)trapee.get(name, Trap.class);
+        if (t.f == f) {
+            trapee.put(name, Trap.class, t.next);
+            return;
+        }
+        for(; t.next != null; t = t.next)
+            if (t.next.f == f) {
+                t.next = t.next.next;
                 return;
             }
-            for(; t.next != null; t = t.next)
-                if (t.next.f == f) {
-                    t.next = t.next.next;
-                    return;
-                }
-        }
         Log.logJS("warning: tried to remove a trap that had not been placed");
     }
 
@@ -97,9 +98,6 @@ public class Trap {
 
     private Trap() { }
 
-    /** the empty object, used for get-traps */
-    public static JS.Array emptyargs = new JS.Array();
-
     public Object perform() throws JS.Exn {
         if (f.getNumFormalArgs() > 0) return cascade();
         return f.call(new TrapArgs(this));