comparison src/luan/lib/PackageLib.java @ 163:3c95a2291d64

make all module fns non-global and make global fns call module fns git-svn-id: https://luan-java.googlecode.com/svn/trunk@164 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 20 Jun 2014 09:32:36 +0000
parents 01e9707a2fb0
children
comparison
equal deleted inserted replaced
162:01e9707a2fb0 163:3c95a2291d64
18 private static final String jpath = "luan.lib.?Lib.LOADER"; 18 private static final String jpath = "luan.lib.?Lib.LOADER";
19 19
20 public static final LuanFunction LOADER = new LuanFunction() { 20 public static final LuanFunction LOADER = new LuanFunction() {
21 @Override public Object call(LuanState luan,Object[] args) { 21 @Override public Object call(LuanState luan,Object[] args) {
22 LuanTable module = new LuanTable(); 22 LuanTable module = new LuanTable();
23 LuanTable global = luan.global();
24 module.put("loaded",luan.loaded()); 23 module.put("loaded",luan.loaded());
25 module.put("preload",luan.preload()); 24 module.put("preload",luan.preload());
26 module.put("path","?.luan;java:luan/modules/?.luan"); 25 module.put("path","?.luan;java:luan/modules/?.luan");
27 module.put("jpath",jpath); 26 module.put("jpath",jpath);
28 try { 27 try {
29 add( global, "require", LuanState.class, String.class ); 28 add( module, "require", LuanState.class, String.class );
30 add( module, "load_lib", String.class ); 29 add( module, "load_lib", String.class );
31 add( module, "search_path", String.class, String.class ); 30 add( module, "search_path", String.class, String.class );
32 add( module, "search", LuanState.class, String.class ); 31 add( module, "search", LuanState.class, String.class );
33 } catch(NoSuchMethodException e) { 32 } catch(NoSuchMethodException e) {
34 throw new RuntimeException(e); 33 throw new RuntimeException(e);