Mercurial Hosting > luan
changeset 96:72a4a5550ec7
add param to module() for super module
git-svn-id: https://luan-java.googlecode.com/svn/trunk@97 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Sat, 09 Mar 2013 03:11:50 +0000 |
parents | 9aa7d5f20333 |
children | 7b15f56660fa |
files | src/luan/lib/PackageLib.java |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
diff -r 9aa7d5f20333 -r 72a4a5550ec7 src/luan/lib/PackageLib.java --- a/src/luan/lib/PackageLib.java Fri Mar 08 06:48:17 2013 +0000 +++ b/src/luan/lib/PackageLib.java Sat Mar 09 03:11:50 2013 +0000 @@ -29,7 +29,7 @@ module.put("path","?.lua"); try { add( global, "require", LuanState.class, String.class ); - add( global, "module", LuanState.class, String.class ); + add( global, "module", LuanState.class, String.class, String.class ); add( module, "search_path", String.class, String.class ); } catch(NoSuchMethodException e) { throw new RuntimeException(e); @@ -43,8 +43,14 @@ t.put( method, new LuanJavaFunction(PackageLib.class.getMethod(method,parameterTypes),null) ); } - public static void module(LuanState luan,String modName) throws LuanException { - LuanTable module = new LuanTable(); + public static void module(LuanState luan,String modName,String superMod) throws LuanException { + LuanTable module; + if( superMod==null ) { + module = new LuanTable(); + } else { + require(luan,superMod); + module = (LuanTable)luan.loaded().get(superMod); + } luan.currentEnvironment().put(modName,module); luan.loaded().put(modName,module); }