Mercurial Hosting > luan
diff core/src/luan/modules/JavaLuan.java @ 502:d3183a330ff5
improve the __index metamethod to work with any type;
simplify luan_proxy to eliminate base;
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 19 May 2015 17:57:20 -0600 |
parents | 34a4ed3597ea |
children | 92c3d22745b8 |
line wrap: on
line diff
--- a/core/src/luan/modules/JavaLuan.java Mon May 18 23:23:01 2015 -0600 +++ b/core/src/luan/modules/JavaLuan.java Tue May 19 17:57:20 2015 -0600 @@ -307,7 +307,7 @@ return cls.isSynthetic(); } - public Object luan_proxy(final LuanState luan,final LuanTable t,final Object base) throws LuanException { + public Object luan_proxy(final LuanState luan,final LuanTable t) throws LuanException { return Proxy.newProxyInstance( cls.getClassLoader(), new Class[]{cls}, @@ -319,8 +319,8 @@ args = new Object[0]; String name = method.getName(); Object fnObj = t.get(luan,name); - if( fnObj==null && base!=null ) - return method.invoke(base,args); + if( fnObj == null ) + throw new NullPointerException("luan_proxy couldn't find method '"+name+"'"); LuanFunction fn = luan.checkFunction(fnObj); return Luan.first(luan.call(fn,name,args)); } @@ -331,7 +331,7 @@ private static final Method luan_proxyMethod; static { try { - luan_proxyMethod = Static.class.getMethod("luan_proxy",LuanState.class,LuanTable.class,Object.class); + luan_proxyMethod = Static.class.getMethod("luan_proxy",LuanState.class,LuanTable.class); luan_proxyMethod.setAccessible(true); } catch(NoSuchMethodException e) { throw new RuntimeException(e);