01: package elf;
02:
03: import java.lang.reflect.InvocationHandler;
04: import java.lang.reflect.Method;
05: import jsint.Procedure;
06: import jscheme.JScheme;
07:
08: /**
09: <p>
10: This InvocationHandler takes a Scheme procedure that is called on
11: each invoke() with arguments proxy, method and args (the Object[]
12: of arguments.
13:
14: <p> For examples of this, see the
15: <a href="http://www.cs.rice.edu/~matthias/Scheme2000/anderson.ps">Scheme2000
16: paper</a>, and
17: http://developer.java.sun.com/developer/TechTips/2000/tt0530.html
18: **/
19: public class SchemeInvocationHandler implements InvocationHandler {
20:
21: Procedure proc;
22:
23: public SchemeInvocationHandler(Procedure proc) {
24: this .proc = proc;
25: }
26:
27: public Object invoke(Object proxy, Method method, Object[] args)
28: throws Throwable {
29: return JScheme.forCurrentEvaluator().call(proc, proxy, method,
30: args);
31: }
32: }
|