Mercurial Hosting > luan
comparison core/src/luan/modules/PackageLuan.java @ 259:f9b201530b85
remove Package.preload
git-svn-id: https://luan-java.googlecode.com/svn/trunk@260 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 28 Oct 2014 21:20:48 +0000 |
parents | 4dfa86dbca45 |
children | f1f7d8c7e94e |
comparison
equal
deleted
inserted
replaced
258:4dfa86dbca45 | 259:f9b201530b85 |
---|---|
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 = Luan.newTable(); | 22 LuanTable module = Luan.newTable(); |
23 module.put( "loaded", loaded(luan) ); | 23 module.put( "loaded", loaded(luan) ); |
24 module.put( "preload", Luan.newTable() ); | |
25 module.put( "path", "?.luan;classpath:luan/modules/?.luan" ); | 24 module.put( "path", "?.luan;classpath:luan/modules/?.luan" ); |
26 module.put( "jpath", jpath ); | 25 module.put( "jpath", jpath ); |
27 try { | 26 try { |
28 module.put("require",requireFn); | 27 module.put("require",requireFn); |
29 add( module, "load", LuanState.class, String.class ); | 28 add( module, "load", LuanState.class, String.class ); |
67 private static LuanTable searchers(LuanState luan) { | 66 private static LuanTable searchers(LuanState luan) { |
68 String key = "Package.searchers"; | 67 String key = "Package.searchers"; |
69 LuanTable tbl = (LuanTable)luan.registry().get(key); | 68 LuanTable tbl = (LuanTable)luan.registry().get(key); |
70 if( tbl == null ) { | 69 if( tbl == null ) { |
71 tbl = Luan.newTable(); | 70 tbl = Luan.newTable(); |
72 tbl.add(preloadSearcher); | |
73 tbl.add(fileSearcher); | 71 tbl.add(fileSearcher); |
74 tbl.add(javaSearcher); | 72 tbl.add(javaSearcher); |
75 tbl.add(JavaLuan.javaSearcher); | 73 tbl.add(JavaLuan.javaSearcher); |
76 luan.registry().put(key,tbl); | 74 luan.registry().put(key,tbl); |
77 } | 75 } |
116 return a; | 114 return a; |
117 } | 115 } |
118 return null; | 116 return null; |
119 } | 117 } |
120 | 118 |
121 public static final LuanFunction preloadSearcher = new LuanFunction() { | |
122 @Override public Object call(LuanState luan,Object[] args) { | |
123 String modName = (String)args[0]; | |
124 LuanTable preload = (LuanTable)pkg(luan,"preload"); | |
125 return preload==null ? LuanFunction.NOTHING : preload.get(modName); | |
126 } | |
127 }; | |
128 | |
129 public static String search_path(String name,String path) { | 119 public static String search_path(String name,String path) { |
130 for( String s : path.split(";") ) { | 120 for( String s : path.split(";") ) { |
131 String file = s.replaceAll("\\?",name); | 121 String file = s.replaceAll("\\?",name); |
132 if( Utils.exists(file) ) | 122 if( Utils.exists(file) ) |
133 return file; | 123 return file; |