sbool exposeMethods2_debug; static S exposeMethods2(O receiver, S s, L methodNames) { ret exposeMethods2(receiver, s, methodNames, null); } static S exposeMethods2(O receiver, S s, L methodNames, Lock lock) { new Matches m; if (exposeMethods2_debug) print("Received: " + s); if "call *" { L l; if (isIdentifier(m.unq(0))) l = ll(m.unq(0)); else l = (L) unstructure(m.unq(0)); // we used to have safeUnstructure here S method = getString(l, 0); if (!contains(methodNames, method)) fail("Method not allowed: " + method); if (lock != null) lock.lock(); try { if (exposeMethods2_debug) print("Calling: " + method); O o = call(receiver, method, asObjectArray(subList(l, 1))); if (exposeMethods2_debug) print("Got: " + getClassName(o)); ret ok2(structure(o)); } finally { if (lock != null) lock.unlock(); } } if "list methods" ret ok2(structure(methodNames)); null; }