- public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
- if("print".equals(method)) {
- System.out.println(JS.toString(a0));
+ public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
+ if(!JS.isString(method)) return null;
+ if("print".equals(JS.toString(method))) {
+ System.out.println(JS.debugToString(a0));
+ return null;
+ }
+ if("clone".equals(JS.toString(method))) return a0 == null ? null : a0.jsclone();
+ if("firethis".equals(JS.toString(method))) {
+ String action = JS.toString(a0);
+ JS target = a1;
+ JS key = a2;
+ if(action.equals("get")) return a1.getAndTriggerTraps(key);
+ else if(action.equals("put")) a1.putAndTriggerTraps(key,JS.S("some value"));
+ else if(action.equals("trigger")) return target.justTriggerTraps(key,JS.S("some trigger value"));