Mercurial Hosting > luan
changeset 62:7c05f53ef6cb
improve java.proxy
git-svn-id: https://luan-java.googlecode.com/svn/trunk@63 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 08 Jan 2013 04:29:24 +0000 |
parents | 183d470be7e8 |
children | ebe578282363 |
files | src/luan/lib/JavaLib.java |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/lib/JavaLib.java Tue Jan 08 03:06:23 2013 +0000 +++ b/src/luan/lib/JavaLib.java Tue Jan 08 04:29:24 2013 +0000 @@ -35,7 +35,7 @@ try { global.put( "import", new LuanJavaFunction(JavaLib.class.getMethod("importClass",LuanState.class,String.class),null) ); module.put( "class", new LuanJavaFunction(JavaLib.class.getMethod("getClass",LuanState.class,String.class),null) ); - add( module, "proxy", LuanState.class, Static.class, LuanTable.class ); + add( module, "proxy", LuanState.class, Static.class, LuanTable.class, Object.class ); } catch(NoSuchMethodException e) { throw new RuntimeException(e); } @@ -344,7 +344,7 @@ } - public static Object proxy(final LuanState luan,Static st,final LuanTable t) throws LuanException { + public static Object proxy(final LuanState luan,Static st,final LuanTable t,final Object base) throws LuanException { return Proxy.newProxyInstance( st.cls.getClassLoader(), new Class[]{st.cls}, @@ -353,7 +353,10 @@ throws Throwable { String name = method.getName(); - LuanFunction fn = luan.checkFunction(LuanElement.JAVA,t.get(name)); + Object fnObj = t.get(name); + if( fnObj==null && base!=null ) + return method.invoke(base,args); + LuanFunction fn = luan.checkFunction(LuanElement.JAVA,fnObj); return Luan.first(luan.call(fn,LuanElement.JAVA,name,args)); } }