2003/08/09 23:43:23
[org.ibex.core.git] / src / org / xwt / Box.java
index c3fec81..f04c3c2 100644 (file)
@@ -1163,6 +1163,7 @@ public final class Box extends JS.Scope {
     public Object get(Object name_, boolean ignoretraps) {
         if (name_ instanceof Number) return get(((Number)name_).intValue());
 
+        if (!(name_ instanceof String)) return null;
         String name = (String)name_;
         if (name.equals("")) return null;
 
@@ -1203,7 +1204,8 @@ public final class Box extends JS.Scope {
     public void put(Object name, Object value, boolean ignoretraps) { put(name, value, ignoretraps, null); }
     public void put(Object name_, Object value, boolean ignoretraps, RootProxy rp) {
         if (name_ instanceof Number) { put(((Number)name_).intValue(), value); return; }
-        String name = (String)name_;
+        if (!(name_ instanceof String)) { super.put(name_,value); return; }
+        String name = name_.toString();
         if (name == null) return;  // FIXME, shouldn't be necessary
         if (name.startsWith("xwt_")) {
             if (Log.on) Log.logJS(this, "attempt to set reserved property " + name);
@@ -1416,6 +1418,9 @@ public final class Box extends JS.Scope {
         public Object get(Object name) { return box.get(name); }
         public void put(Object name, Object value) { box.put(name, value, false, this); }
         public Object[] keys() { return box.keys(); }
+        public Object callMethod(Object method, JS.Array args, boolean justChecking) {
+            return box.callMethod(method,args,justChecking);
+        }
     }
 
 
@@ -1501,34 +1506,11 @@ public final class Box extends JS.Scope {
         return this;
     }
     
+    // This is the name returned by typeof() by JS
+    public String typeName() {
+        return "box";
+    }
+    
 }
 
 
-/** this is in Box.java solely to work around a GCJ bug */
-class Apply extends JS.Callable {
-    Box b;
-    public Apply(Box b) { this.b = b; }
-    public Object call(JS.Array args) throws JS.Exn {
-        if (args.elementAt(0) instanceof String) {
-            String templatename = (String)args.elementAt(0);
-            Template t = Template.getTemplate(templatename, null);
-            if (t == null) {
-                if (Log.on) Log.logJS(this, "template " + templatename + " not found");
-            } else {
-                if (ThreadMessage.suspendThread()) try {
-                    JS.Callable callback = args.length() < 2 ? null : (Callable)args.elementAt(1);
-                    t.apply(b, null, null, callback, 0, t.numUnits());
-                } finally {
-                    ThreadMessage.resumeThread();
-                }
-            }
-            
-        } else if (args.elementAt(0) instanceof JS && !(args.elementAt(0) instanceof Box)) {
-            JS s = (JS)args.elementAt(0);
-            Object[] keys = s.keys();
-            for(int j=0; j<keys.length; j++) b.put(keys[j].toString(), s.get(keys[j]));
-        }
-        
-        return b;
-    }
-}