comparison src/luan/lib/MathLib.java @ 55:9381b23ea9e1

various fixes git-svn-id: https://luan-java.googlecode.com/svn/trunk@56 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 04 Jan 2013 04:50:18 +0000
parents
children f86e4f77ef32
comparison
equal deleted inserted replaced
54:f5b27ef14d73 55:9381b23ea9e1
1 package luan.lib;
2
3 import luan.LuanState;
4 import luan.LuanTable;
5 import luan.LuanJavaFunction;
6
7
8 public final class MathLib {
9
10 public static void register(LuanState luan) {
11 LuanTable module = new LuanTable();
12 LuanTable global = luan.global();
13 global.put("math",module);
14 try {
15 add( module, "floor", Double.TYPE );
16 } catch(NoSuchMethodException e) {
17 throw new RuntimeException(e);
18 }
19 }
20
21 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException {
22 t.put( method, new LuanJavaFunction(MathLib.class.getMethod(method,parameterTypes),null) );
23 }
24
25 public static double floor(double x) {
26 return Math.floor(x);
27 }
28
29 }