Mercurial Hosting > luan
comparison core/src/luan/modules/BasicLuan.java @ 297:899253043270
remove PackageLuan.load_lib()
git-svn-id: https://luan-java.googlecode.com/svn/trunk@298 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 16 Dec 2014 03:26:43 +0000 |
parents | 7ea6dfdf81ba |
children | a74559240b4f |
comparison
equal
deleted
inserted
replaced
296:7ea6dfdf81ba | 297:899253043270 |
---|---|
18 import luan.impl.LuanCompiler; | 18 import luan.impl.LuanCompiler; |
19 | 19 |
20 | 20 |
21 public final class BasicLuan { | 21 public final class BasicLuan { |
22 | 22 |
23 public static final LuanFunction LOADER = new LuanFunction() { | |
24 @Override public Object call(LuanState luan,Object[] args) { | |
25 LuanTable module = Luan.newTable(); | |
26 try { | |
27 module.put( "assert", new LuanJavaFunction(BasicLuan.class.getMethod("assert_",LuanState.class,Object.class,String.class),null) ); | |
28 add( module, "assert_boolean", LuanState.class, Boolean.TYPE ); | |
29 add( module, "assert_nil", LuanState.class, Object.class ); | |
30 add( module, "assert_number", LuanState.class, Number.class ); | |
31 add( module, "assert_string", LuanState.class, String.class ); | |
32 add( module, "assert_table", LuanState.class, LuanTable.class ); | |
33 add( module, "assert_integer", LuanState.class, Integer.TYPE ); | |
34 add( module, "assert_long", LuanState.class, Long.TYPE ); | |
35 add( module, "do_file", LuanState.class, String.class ); | |
36 add( module, "error", LuanState.class, Object.class ); | |
37 add( module, "get_metatable", LuanState.class, Object.class ); | |
38 add( module, "ipairs", LuanState.class, LuanTable.class ); | |
39 add( module, "load", LuanState.class, String.class, String.class, LuanTable.class, Boolean.class ); | |
40 add( module, "load_file", LuanState.class, String.class, LuanTable.class ); | |
41 add( module, "pairs", LuanState.class, LuanTable.class ); | |
42 add( module, "range", LuanState.class, Double.TYPE, Double.TYPE, Double.class ); | |
43 add( module, "raw_equal", Object.class, Object.class ); | |
44 add( module, "raw_get", LuanTable.class, Object.class ); | |
45 add( module, "raw_len", LuanState.class, Object.class ); | |
46 add( module, "raw_set", LuanTable.class, Object.class, Object.class ); | |
47 add( module, "repr", LuanState.class, Object.class ); | |
48 add( module, "set_metatable", LuanTable.class, LuanTable.class ); | |
49 add( module, "to_boolean", Object.class ); | |
50 add( module, "to_number", Object.class, Integer.class ); | |
51 add( module, "to_string", LuanState.class, Object.class ); | |
52 add( module, "type", Object.class ); | |
53 add( module, "values", new Object[0].getClass() ); | |
54 } catch(NoSuchMethodException e) { | |
55 throw new RuntimeException(e); | |
56 } | |
57 return module; | |
58 } | |
59 }; | |
60 | |
61 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | |
62 t.put( method, new LuanJavaFunction(BasicLuan.class.getMethod(method,parameterTypes),null) ); | |
63 } | |
64 | |
65 public static String type(Object obj) { | 23 public static String type(Object obj) { |
66 return Luan.type(obj); | 24 return Luan.type(obj); |
67 } | 25 } |
68 | 26 |
69 public static LuanFunction load(LuanState luan,String text,String sourceName,LuanTable env,Boolean allowExpr) | 27 public static LuanFunction load(LuanState luan,String text,String sourceName,LuanTable env,Boolean allowExpr) |