comparison src/luan/modules/JavaLuan.java @ 1562:b89212fd04b5

remove table.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 08 Nov 2020 16:50:59 -0700
parents e1a13e707bf3
children 8fbcc4747091
comparison
equal deleted inserted replaced
1561:e1a13e707bf3 1562:b89212fd04b5
300 300
301 @Override public boolean isSynthetic() { 301 @Override public boolean isSynthetic() {
302 return cls.isSynthetic(); 302 return cls.isSynthetic();
303 } 303 }
304 304
305 public Object luan_proxy(final LuanTable t) throws LuanException { 305 public Object luan_proxy(Luan luan,final LuanTable t) throws LuanException {
306 return Proxy.newProxyInstance( 306 return Proxy.newProxyInstance(
307 cls.getClassLoader(), 307 cls.getClassLoader(),
308 new Class[]{cls}, 308 new Class[]{cls},
309 new InvocationHandler() { 309 new InvocationHandler() {
310 public Object invoke(Object proxy,Method method, Object[] args) 310 public Object invoke(Object proxy,Method method, Object[] args)
311 throws Throwable 311 throws Throwable
312 { 312 {
313 if( args==null ) 313 if( args==null )
314 args = new Object[0]; 314 args = new Object[0];
315 String name = method.getName(); 315 String name = method.getName();
316 Object fnObj = t.get(name); 316 Object fnObj = t.get(luan,name);
317 if( fnObj == null ) 317 if( fnObj == null )
318 throw new NullPointerException("luan_proxy couldn't find method '"+name+"'"); 318 throw new NullPointerException("luan_proxy couldn't find method '"+name+"'");
319 LuanFunction fn = Luan.checkFunction(fnObj); 319 LuanFunction fn = Luan.checkFunction(fnObj);
320 return Luan.first(fn.call(args)); 320 return Luan.first(fn.call(args));
321 } 321 }
324 } 324 }
325 } 325 }
326 private static final Method luan_proxyMethod; 326 private static final Method luan_proxyMethod;
327 static { 327 static {
328 try { 328 try {
329 luan_proxyMethod = Static.class.getMethod("luan_proxy",LuanTable.class); 329 luan_proxyMethod = Static.class.getMethod("luan_proxy",Luan.class,LuanTable.class);
330 luan_proxyMethod.setAccessible(true); 330 luan_proxyMethod.setAccessible(true);
331 } catch(NoSuchMethodException e) { 331 } catch(NoSuchMethodException e) {
332 throw new RuntimeException(e); 332 throw new RuntimeException(e);
333 } 333 }
334 } 334 }