-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 abstract class JSCallable extends JS {
+
+ // return this from get() if the key was actually a method.
+ public static final Object METHOD = new Object();
+
+ public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) {
+ if (method == null) return call(a0, a1, a2, rest, nargs);
+ Class c = this.getClass();
+ String descrip = c.getName();
+ if (c == Internal.JSCallableStub.class) {
+ descrip = ((Internal.JSCallableStub)this).obj.getClass().getName();
+ }
+ throw new JS.Exn("attempted to call an undefined method ("+method+") on a " + descrip);