2003/11/13 05:04:22
[org.ibex.core.git] / src / org / xwt / js / JSCallable.java
diff --git a/src/org/xwt/js/JSCallable.java b/src/org/xwt/js/JSCallable.java
new file mode 100644 (file)
index 0000000..42def05
--- /dev/null
@@ -0,0 +1,24 @@
+package org.xwt.js;
+
+/** anything that is callable with the () operator and wasn't compiled from JS code */
+public abstract class JSCallable extends JSObj {
+    public Object call0(Object method) throws JS.Exn {
+        JSArray args = new JSArray();
+        return call(method, args);
+    }
+    public Object call1(Object method, Object arg1) throws JS.Exn {
+        JSArray args = new JSArray();
+        args.addElement(arg1);
+        return call(method, args);
+    }
+    public Object call2(Object method, Object arg1, Object arg2) throws JS.Exn {
+        JSArray args = new JSArray();
+        args.addElement(arg1);
+        args.addElement(arg2);
+        return call(method, args);
+    }
+    public Object call(Object method, JSArray args) throws JS.Exn {
+        throw new JS.Exn("cannot invoke this method with " + args.size() + " arguments");
+    }
+}
+