Mercurial Hosting > luan
comparison core/src/luan/modules/MathLuan.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 | 58752e3e4c5c |
children | 410e59ebad7d |
comparison
equal
deleted
inserted
replaced
296:7ea6dfdf81ba | 297:899253043270 |
---|---|
7 import luan.LuanJavaFunction; | 7 import luan.LuanJavaFunction; |
8 import luan.LuanException; | 8 import luan.LuanException; |
9 | 9 |
10 | 10 |
11 public final class MathLuan { | 11 public final class MathLuan { |
12 | |
13 public static final LuanFunction LOADER = new LuanFunction() { | |
14 @Override public Object call(LuanState luan,Object[] args) { | |
15 LuanTable module = Luan.newTable(); | |
16 try { | |
17 add( module, "abs", Double.TYPE ); | |
18 add( module, "acos", Double.TYPE ); | |
19 add( module, "asin", Double.TYPE ); | |
20 add( module, "atan", Double.TYPE ); | |
21 add( module, "atan2", Double.TYPE, Double.TYPE ); | |
22 add( module, "ceil", Double.TYPE ); | |
23 add( module, "cos", Double.TYPE ); | |
24 add( module, "cosh", Double.TYPE ); | |
25 add( module, "deg", Double.TYPE ); | |
26 add( module, "exp", Double.TYPE ); | |
27 add( module, "floor", Double.TYPE ); | |
28 add( module, "log", Double.TYPE ); | |
29 add( module, "min", Double.TYPE, new double[0].getClass() ); | |
30 add( module, "max", Double.TYPE, new double[0].getClass() ); | |
31 add( module, "modf", Double.TYPE ); | |
32 module.put("pi",Math.PI); | |
33 add( module, "pow", Double.TYPE, Double.TYPE ); | |
34 add( module, "rad", Double.TYPE ); | |
35 add( module, "random", Integer.class, Integer.class ); | |
36 add( module, "sin", Double.TYPE ); | |
37 add( module, "sinh", Double.TYPE ); | |
38 add( module, "sqrt", Double.TYPE ); | |
39 add( module, "tan", Double.TYPE ); | |
40 add( module, "tanh", Double.TYPE ); | |
41 } catch(NoSuchMethodException e) { | |
42 throw new RuntimeException(e); | |
43 } | |
44 return module; | |
45 } | |
46 }; | |
47 | |
48 private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { | |
49 t.put( method, new LuanJavaFunction(MathLuan.class.getMethod(method,parameterTypes),null) ); | |
50 } | |
51 | 12 |
52 public static double abs(double x) { | 13 public static double abs(double x) { |
53 return Math.abs(x); | 14 return Math.abs(x); |
54 } | 15 } |
55 | 16 |