comparison src/luan/lib/MathLib.java @ 74:f003338d503b

improve package lib git-svn-id: https://luan-java.googlecode.com/svn/trunk@75 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 13 Feb 2013 06:27:56 +0000
parents f86e4f77ef32
children 4bf3d0c0b6b9
comparison
equal deleted inserted replaced
73:f86e4f77ef32 74:f003338d503b
12 12
13 public static final LuanFunction LOADER = new LuanFunction() { 13 public static final LuanFunction LOADER = new LuanFunction() {
14 public Object[] call(LuanState luan,Object[] args) { 14 public Object[] call(LuanState luan,Object[] args) {
15 LuanTable module = new LuanTable(); 15 LuanTable module = new LuanTable();
16 LuanTable global = luan.global; 16 LuanTable global = luan.global;
17 global.put(NAME,module);
18 try { 17 try {
19 add( module, "floor", Double.TYPE ); 18 add( module, "floor", Double.TYPE );
20 } catch(NoSuchMethodException e) { 19 } catch(NoSuchMethodException e) {
21 throw new RuntimeException(e); 20 throw new RuntimeException(e);
22 } 21 }
23 return LuanFunction.EMPTY_RTN; 22 return new Object[]{module};
24 } 23 }
25 }; 24 };
26 25
27 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { 26 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException {
28 t.put( method, new LuanJavaFunction(MathLib.class.getMethod(method,parameterTypes),null) ); 27 t.put( method, new LuanJavaFunction(MathLib.class.getMethod(method,parameterTypes),null) );