Mercurial Hosting > luan
comparison src/luan/lib/PackageLib.java @ 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 | 1f8b6edc2b08 |
children | 3c404a296995 |
comparison
equal
deleted
inserted
replaced
95:9aa7d5f20333 | 96:72a4a5550ec7 |
---|---|
27 module.put("loaded",luan.loaded()); | 27 module.put("loaded",luan.loaded()); |
28 module.put("preload",luan.preload()); | 28 module.put("preload",luan.preload()); |
29 module.put("path","?.lua"); | 29 module.put("path","?.lua"); |
30 try { | 30 try { |
31 add( global, "require", LuanState.class, String.class ); | 31 add( global, "require", LuanState.class, String.class ); |
32 add( global, "module", LuanState.class, String.class ); | 32 add( global, "module", LuanState.class, String.class, String.class ); |
33 add( module, "search_path", String.class, String.class ); | 33 add( module, "search_path", String.class, String.class ); |
34 } catch(NoSuchMethodException e) { | 34 } catch(NoSuchMethodException e) { |
35 throw new RuntimeException(e); | 35 throw new RuntimeException(e); |
36 } | 36 } |
37 module.put("searchers",new LuanTable(Arrays.<Object>asList(preloadSearcher,fileSearcher,javaFileSearcher))); | 37 module.put("searchers",new LuanTable(Arrays.<Object>asList(preloadSearcher,fileSearcher,javaFileSearcher))); |
41 | 41 |
42 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | 42 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { |
43 t.put( method, new LuanJavaFunction(PackageLib.class.getMethod(method,parameterTypes),null) ); | 43 t.put( method, new LuanJavaFunction(PackageLib.class.getMethod(method,parameterTypes),null) ); |
44 } | 44 } |
45 | 45 |
46 public static void module(LuanState luan,String modName) throws LuanException { | 46 public static void module(LuanState luan,String modName,String superMod) throws LuanException { |
47 LuanTable module = new LuanTable(); | 47 LuanTable module; |
48 if( superMod==null ) { | |
49 module = new LuanTable(); | |
50 } else { | |
51 require(luan,superMod); | |
52 module = (LuanTable)luan.loaded().get(superMod); | |
53 } | |
48 luan.currentEnvironment().put(modName,module); | 54 luan.currentEnvironment().put(modName,module); |
49 luan.loaded().put(modName,module); | 55 luan.loaded().put(modName,module); |
50 } | 56 } |
51 | 57 |
52 public static void require(LuanState luan,String modName) throws LuanException { | 58 public static void require(LuanState luan,String modName) throws LuanException { |