annotate core/src/luan/LuanJavaFunction.java @ 724:4f8e30a3ffd0

add Hosting.change_domain()
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 07 Jun 2016 16:00:41 -0600
parents cdc70de628b5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
1 package luan;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
2
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
3 import java.lang.reflect.Array;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
4 import java.lang.reflect.Method;
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
5 import java.lang.reflect.Constructor;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
6 import java.lang.reflect.InvocationTargetException;
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
7 import java.util.List;
209
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
8 import java.util.ArrayList;
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
9 import java.util.Map;
95
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
10 import java.util.HashMap;
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
11 import java.util.Set;
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
12 import java.util.Arrays;
396
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
13 import java.util.Collection;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
14
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
15
213
4a27f24ce2b5 Make LuanJavaFunction not DeepCloneable. There is no reason for most to be DeepCloneable and those that should be can be made DeepCloneable individually.
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 212
diff changeset
16 public final class LuanJavaFunction extends LuanFunction {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
17 private final JavaMethod method;
197
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
18 private Object obj;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
19 private final RtnConverter rtnConverter;
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
20 private final boolean takesLuaState;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
21 private final ArgConverter[] argConverters;
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
22 private final Class varArgCls;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
23
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
24 public LuanJavaFunction(Method method,Object obj) {
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
25 this( JavaMethod.of(method), obj );
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
26 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
27
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
28 public LuanJavaFunction(Constructor constr,Object obj) {
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
29 this( JavaMethod.of(constr), obj );
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
30 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
31
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
32 private LuanJavaFunction(JavaMethod method,Object obj) {
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
33 this.method = method;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
34 this.obj = obj;
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
35 this.rtnConverter = getRtnConverter(method);
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
36 this.takesLuaState = takesLuaState(method);
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
37 this.argConverters = getArgConverters(takesLuaState,method);
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
38 if( method.isVarArgs() ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
39 Class[] paramTypes = method.getParameterTypes();
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
40 this.varArgCls = paramTypes[paramTypes.length-1].getComponentType();
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
41 } else {
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
42 this.varArgCls = null;
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
43 }
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
44 }
213
4a27f24ce2b5 Make LuanJavaFunction not DeepCloneable. There is no reason for most to be DeepCloneable and those that should be can be made DeepCloneable individually.
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 212
diff changeset
45 /*
197
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
46 private LuanJavaFunction(LuanJavaFunction f) {
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
47 this.method = f.method;
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
48 this.rtnConverter = f.rtnConverter;
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
49 this.takesLuaState = f.takesLuaState;
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
50 this.argConverters = f.argConverters;
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
51 this.varArgCls = f.varArgCls;
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
52 }
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
53
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
54 @Override public LuanJavaFunction shallowClone() {
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
55 return obj==null ? this : new LuanJavaFunction(this);
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
56 }
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
57
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
58 @Override public void deepenClone(LuanJavaFunction clone,DeepCloner cloner) {
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
59 clone.obj = cloner.get(obj);
4c96cb73dd93 fix metatable cloning
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 171
diff changeset
60 }
213
4a27f24ce2b5 Make LuanJavaFunction not DeepCloneable. There is no reason for most to be DeepCloneable and those that should be can be made DeepCloneable individually.
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 212
diff changeset
61 */
60
a68ccb7aaa9c implement setting java field values
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 57
diff changeset
62 @Override public String toString() {
a68ccb7aaa9c implement setting java field values
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 57
diff changeset
63 return "java-function: " + method;
a68ccb7aaa9c implement setting java field values
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 57
diff changeset
64 }
a68ccb7aaa9c implement setting java field values
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 57
diff changeset
65
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
66 public Class[] getParameterTypes() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
67 return method.getParameterTypes();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
68 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
69
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
70 @Override public Object call(LuanState luan,Object[] args) throws LuanException {
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
71 try {
210
e84655b4c45e better exception handling
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 209
diff changeset
72 args = fixArgs(luan,args);
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
73 return doCall(args);
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
74 } catch(IllegalArgumentException e) {
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
75 checkArgs(args);
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
76 throw e;
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
77 }
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
78 }
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
79
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
80 public Object rawCall(LuanState luan,Object[] args) throws LuanException {
49
8ede219cd111 add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 48
diff changeset
81 args = fixArgs(luan,args);
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
82 return doCall(args);
68
877288464542 better type checking
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 67
diff changeset
83 }
877288464542 better type checking
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 67
diff changeset
84
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
85 private Object doCall(Object[] args) throws LuanException {
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
86 Object rtn;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
87 try {
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
88 rtn = method.invoke(obj,args);
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
89 } catch(IllegalAccessException e) {
129
486a0641bca4 add pickle client/server;
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 123
diff changeset
90 throw new RuntimeException("method = "+method,e);
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
91 } catch(InvocationTargetException e) {
40
e3624b7cd603 implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 37
diff changeset
92 Throwable cause = e.getCause();
e3624b7cd603 implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 37
diff changeset
93 if( cause instanceof Error )
e3624b7cd603 implement stack trace
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 37
diff changeset
94 throw (Error)cause;
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
95 if( cause instanceof LuanException )
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
96 throw (LuanException)cause;
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
97 throw new LuanException(cause);
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
98 } catch(InstantiationException e) {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
99 throw new RuntimeException(e);
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
100 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
101 return rtnConverter.convert(rtn);
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
102 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
103
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
104 private static final Map primitiveMap = new HashMap();
95
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
105 static {
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
106 primitiveMap.put(Boolean.TYPE,Boolean.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
107 primitiveMap.put(Character.TYPE,Character.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
108 primitiveMap.put(Byte.TYPE,Byte.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
109 primitiveMap.put(Short.TYPE,Short.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
110 primitiveMap.put(Integer.TYPE,Integer.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
111 primitiveMap.put(Long.TYPE,Long.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
112 primitiveMap.put(Float.TYPE,Float.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
113 primitiveMap.put(Double.TYPE,Double.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
114 primitiveMap.put(Void.TYPE,Void.class);
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
115 }
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
116
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
117 private void checkArgs(Object[] args) throws LuanException {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
118 Class[] a = getParameterTypes();
69
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 68
diff changeset
119 int start = takesLuaState ? 1 : 0;
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 68
diff changeset
120 for( int i=start; i<a.length; i++ ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
121 Class paramType = a[i];
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
122 Class type = paramType;
95
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
123 if( type.isPrimitive() )
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
124 type = (Class)primitiveMap.get(type);
67
8ca58ab6919b fix LuanJavaFunction.checkArgs() for nulls
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 64
diff changeset
125 Object arg = args[i];
95
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
126 if( !type.isInstance(arg) ) {
447
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
127 String expected;
210
e84655b4c45e better exception handling
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 209
diff changeset
128 if( i==a.length-1 && method.isVarArgs() )
447
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
129 expected = fixType(paramType.getComponentType().getSimpleName())+"...";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
130 else
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
131 expected = fixType(paramType.getSimpleName());
67
8ca58ab6919b fix LuanJavaFunction.checkArgs() for nulls
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 64
diff changeset
132 if( arg==null ) {
8ca58ab6919b fix LuanJavaFunction.checkArgs() for nulls
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 64
diff changeset
133 if( paramType.isPrimitive() )
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
134 throw new LuanException("bad argument #"+(i+1-start)+" ("+expected+" expected, got nil)");
67
8ca58ab6919b fix LuanJavaFunction.checkArgs() for nulls
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 64
diff changeset
135 } else {
447
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
136 String got = fixType(arg.getClass().getSimpleName());
646
cdc70de628b5 simplify LuanException
Franklin Schmidt <fschmidt@gmail.com>
parents: 578
diff changeset
137 throw new LuanException("bad argument #"+(i+1-start)+" ("+expected+" expected, got "+got+")");
67
8ca58ab6919b fix LuanJavaFunction.checkArgs() for nulls
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 64
diff changeset
138 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
139 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
140 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
141 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
142
447
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
143 private static String fixType(String type) {
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
144 if( type.equals("byte[]") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
145 return "binary";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
146 if( type.equals("Double") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
147 return "number";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
148 if( type.equals("LuanTable") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
149 return "table";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
150 if( type.equals("Boolean") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
151 return "boolean";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
152 if( type.equals("String") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
153 return "string";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
154 if( type.equals("Closure") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
155 return "function";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
156 if( type.equals("LuanJavaFunction") )
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
157 return "function";
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
158 return type;
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
159 }
0bd42e774c50 add assert_binary;
Franklin Schmidt <fschmidt@gmail.com>
parents: 446
diff changeset
160
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
161 private Object[] fixArgs(LuanState luan,Object[] args) throws LuanException {
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
162 int n = argConverters.length;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
163 Object[] rtn;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
164 int start = 0;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
165 if( !takesLuaState && varArgCls==null && args.length == n ) {
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
166 rtn = args;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
167 } else {
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
168 if( takesLuaState )
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
169 n++;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
170 rtn = new Object[n];
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
171 if( takesLuaState ) {
49
8ede219cd111 add WebShell
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 48
diff changeset
172 rtn[start++] = luan;
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
173 }
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
174 n = argConverters.length;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
175 if( varArgCls != null ) {
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
176 n--;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
177 if( args.length < argConverters.length ) {
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
178 rtn[rtn.length-1] = Array.newInstance(varArgCls,0);
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
179 } else {
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
180 int len = args.length - n;
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
181 Object varArgs = Array.newInstance(varArgCls,len);
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
182 ArgConverter ac = argConverters[n];
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
183 for( int i=0; i<len; i++ ) {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
184 Array.set( varArgs, i, ac.convert(luan,args[n+i]) );
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
185 }
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
186 rtn[rtn.length-1] = varArgs;
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
187 }
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
188 }
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
189 System.arraycopy(args,0,rtn,start,Math.min(args.length,n));
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
190 }
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
191 for( int i=0; i<n; i++ ) {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
192 rtn[start+i] = argConverters[i].convert(luan,rtn[start+i]);
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
193 }
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
194 return rtn;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
195 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
196
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
197
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
198 private interface RtnConverter {
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
199 public Object convert(Object obj);
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
200 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
201
123
d7be9b3abf1a minor - rename LuanFunction.EMPTY to NOTHING
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 115
diff changeset
202 private static final RtnConverter RTN_NOTHING = new RtnConverter() {
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
203 @Override public Object[] convert(Object obj) {
123
d7be9b3abf1a minor - rename LuanFunction.EMPTY to NOTHING
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 115
diff changeset
204 return NOTHING;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
205 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
206 };
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
207
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
208 private static final RtnConverter RTN_SAME = new RtnConverter() {
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
209 @Override public Object convert(Object obj) {
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
210 return obj;
12
9cea1aea5eef CmdLine can run files
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 4
diff changeset
211 }
9cea1aea5eef CmdLine can run files
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 4
diff changeset
212 };
9cea1aea5eef CmdLine can run files
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 4
diff changeset
213
209
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
214 private static final RtnConverter RTN_ARRAY = new RtnConverter() {
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
215 @Override public Object convert(Object obj) {
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
216 if( obj == null )
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
217 return null;
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
218 Object[] a = new Object[Array.getLength(obj)];
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
219 for( int i=0; i<a.length; i++ ) {
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
220 a[i] = Array.get(obj,i);
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
221 }
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
222 return new LuanTable(new ArrayList<Object>(Arrays.asList(a)));
209
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
223 }
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
224 };
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
225
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
226 private static RtnConverter getRtnConverter(JavaMethod m) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
227 Class rtnType = m.getReturnType();
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
228 if( rtnType == Void.TYPE )
123
d7be9b3abf1a minor - rename LuanFunction.EMPTY to NOTHING
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 115
diff changeset
229 return RTN_NOTHING;
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
230 if( !m.isLuan() && rtnType.isArray() && !rtnType.getComponentType().isPrimitive() ) {
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
231 //System.out.println("qqqqqq "+m);
209
239c8d650028 convert returned arrays to tables for java methods
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 197
diff changeset
232 return RTN_ARRAY;
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
233 }
111
2428ecfed375 change LuanFunction.call() from returning Object[] to returning Object, to reduce garbage collection
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 98
diff changeset
234 return RTN_SAME;
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
235 }
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
236
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
237 private static boolean isNumber(Class rtnType) {
113
8c706d6eb5dc add binary type
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 111
diff changeset
238 return rtnType == Short.TYPE
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
239 || rtnType == Integer.TYPE
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
240 || rtnType == Long.TYPE
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
241 || rtnType == Float.TYPE
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
242 || rtnType == Double.TYPE
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
243 ;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
244 }
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
245
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
246 private interface ArgConverter {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
247 public Object convert(LuanState luan,Object obj) throws LuanException;
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
248 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
249
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
250 private static final ArgConverter ARG_SAME = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
251 public Object convert(LuanState luan,Object obj) {
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
252 return obj;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
253 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
254 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
255 return "ARG_SAME";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
256 }
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
257 };
95
9aa7d5f20333 in LuanJavaFunction, fix primitive type checking and add boolean conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 88
diff changeset
258
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
259 private static final ArgConverter ARG_DOUBLE = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
260 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
261 if( obj instanceof Double )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
262 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
263 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
264 Number n = (Number)obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
265 return n.doubleValue();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
266 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
267 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
268 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
269 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
270 return "ARG_DOUBLE";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
271 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
272 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
273
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
274 private static final ArgConverter ARG_FLOAT = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
275 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
276 if( obj instanceof Float )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
277 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
278 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
279 Number n = (Number)obj;
98
3a0ff21f0c96 fix LuanJavaFunction.ARG_FLOAT
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 95
diff changeset
280 return n.floatValue();
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
281 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
282 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
283 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
284 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
285 return "ARG_FLOAT";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
286 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
287 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
288
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
289 private static final ArgConverter ARG_LONG = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
290 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
291 if( obj instanceof Long )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
292 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
293 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
294 Number n = (Number)obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
295 long r = n.longValue();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
296 if( r==n.doubleValue() )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
297 return r;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
298 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
299 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
300 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
301 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
302 return "ARG_LONG";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
303 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
304 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
305
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
306 private static final ArgConverter ARG_INTEGER = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
307 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
308 if( obj instanceof Integer )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
309 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
310 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
311 Number n = (Number)obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
312 int r = n.intValue();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
313 if( r==n.doubleValue() )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
314 return r;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
315 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
316 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
317 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
318 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
319 return "ARG_INTEGER";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
320 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
321 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
322
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
323 private static final ArgConverter ARG_SHORT = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
324 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
325 if( obj instanceof Short )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
326 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
327 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
328 Number n = (Number)obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
329 short r = n.shortValue();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
330 if( r==n.doubleValue() )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
331 return r;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
332 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
333 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
334 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
335 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
336 return "ARG_SHORT";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
337 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
338 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
339
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
340 private static final ArgConverter ARG_BYTE = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
341 public Object convert(LuanState luan,Object obj) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
342 if( obj instanceof Byte )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
343 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
344 if( obj instanceof Number ) {
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
345 Number n = (Number)obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
346 byte r = n.byteValue();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
347 if( r==n.doubleValue() )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
348 return r;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
349 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
350 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
351 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
352 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
353 return "ARG_BYTE";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
354 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
355 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
356
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
357 private static final ArgConverter ARG_TABLE = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
358 public Object convert(LuanState luan,Object obj) {
86
6db8f286fa6c _ENV is per module, not global
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 69
diff changeset
359 if( obj == null )
6db8f286fa6c _ENV is per module, not global
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 69
diff changeset
360 return null;
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
361 if( obj instanceof List ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
362 return new LuanTable((List)obj);
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
363 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
364 if( obj instanceof Map ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
365 return new LuanTable((Map)obj);
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
366 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
367 if( obj instanceof Set ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
368 return new LuanTable((Set)obj);
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
369 }
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
370 Class cls = obj.getClass();
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
371 if( cls.isArray() && !cls.getComponentType().isPrimitive() ) {
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
372 Object[] a = (Object[])obj;
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
373 return new LuanTable(Arrays.asList(a));
55
9381b23ea9e1 various fixes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 49
diff changeset
374 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
375 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
376 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
377 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
378 return "ARG_TABLE";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
379 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
380 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
381
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
382 private static final ArgConverter ARG_MAP = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
383 public Object convert(LuanState luan,Object obj) throws LuanException {
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
384 if( obj instanceof LuanTable ) {
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
385 LuanTable t = (LuanTable)obj;
575
7c3ad6db8ac3 make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents: 572
diff changeset
386 return t.asMap(luan);
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
387 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
388 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
389 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
390 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
391 return "ARG_MAP";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
392 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
393 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
394
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
395 private static final ArgConverter ARG_LIST = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
396 public Object convert(LuanState luan,Object obj) {
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
397 if( obj instanceof LuanTable ) {
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
398 LuanTable t = (LuanTable)obj;
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
399 if( t.isList() )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
400 return t.asList();
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
401 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
402 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
403 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
404 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
405 return "ARG_LIST";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
406 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
407 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
408
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
409 private static final ArgConverter ARG_SET = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
410 public Object convert(LuanState luan,Object obj) throws LuanException {
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
411 if( obj instanceof LuanTable ) {
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
412 LuanTable t = (LuanTable)obj;
575
7c3ad6db8ac3 make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents: 572
diff changeset
413 if( t.isSet(luan) )
7c3ad6db8ac3 make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents: 572
diff changeset
414 return t.asSet(luan);
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
415 }
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
416 return obj;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
417 }
244
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
418 @Override public String toString() {
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
419 return "ARG_SET";
0a8e6fdb62f0 fix Math.random()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 221
diff changeset
420 }
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
421 };
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
422
396
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
423 private static final ArgConverter ARG_COLLECTION = new ArgConverter() {
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
424 public Object convert(LuanState luan,Object obj) throws LuanException {
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
425 if( obj instanceof LuanTable ) {
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
426 LuanTable t = (LuanTable)obj;
396
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
427 if( t.isList() )
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
428 return t.asList();
575
7c3ad6db8ac3 make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents: 572
diff changeset
429 if( t.isSet(luan) )
7c3ad6db8ac3 make LuanState.JAVA private
Franklin Schmidt <fschmidt@gmail.com>
parents: 572
diff changeset
430 return t.asSet(luan);
396
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
431 }
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
432 return obj;
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
433 }
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
434 @Override public String toString() {
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
435 return "ARG_COLLECTION";
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
436 }
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
437 };
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
438
57
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
439 private static class ArgArray implements ArgConverter {
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
440 private final Object[] a;
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
441
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
442 ArgArray(Class cls) {
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
443 a = (Object[])Array.newInstance(cls.getComponentType(),0);
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
444 }
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
445
432
d9df6d6cb927 finish fixing LuanTable to use metatables
Franklin Schmidt <fschmidt@gmail.com>
parents: 431
diff changeset
446 public Object convert(LuanState luan,Object obj) {
408
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
447 if( obj instanceof LuanTable ) {
1b38de2b1845 merge LuanTableImpl into LuanTable
Franklin Schmidt <fschmidt@gmail.com>
parents: 396
diff changeset
448 LuanTable t = (LuanTable)obj;
57
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
449 if( t.isList() ) {
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
450 try {
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
451 return t.asList().toArray(a);
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
452 } catch(ArrayStoreException e) {}
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
453 }
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
454 }
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
455 return obj;
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
456 }
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
457 }
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
458
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
459 private static boolean takesLuaState(JavaMethod m) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
460 Class[] paramTypes = m.getParameterTypes();
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
461 return paramTypes.length > 0 && paramTypes[0].equals(LuanState.class);
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
462 }
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
463
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
464 private static ArgConverter[] getArgConverters(boolean takesLuaState,JavaMethod m) {
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
465 final boolean isVarArgs = m.isVarArgs();
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
466 Class[] paramTypes = m.getParameterTypes();
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
467 if( takesLuaState ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
468 Class[] t = new Class[paramTypes.length-1];
21
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
469 System.arraycopy(paramTypes,1,t,0,t.length);
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
470 paramTypes = t;
c93d8c781853 add functions
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 12
diff changeset
471 }
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
472 ArgConverter[] a = new ArgConverter[paramTypes.length];
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
473 for( int i=0; i<a.length; i++ ) {
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
474 Class paramType = paramTypes[i];
4
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
475 if( isVarArgs && i == a.length-1 )
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
476 paramType = paramType.getComponentType();
24fd6381caca add to interp
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 2
diff changeset
477 a[i] = getArgConverter(paramType);
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
478 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
479 return a;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
480 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
481
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
482 private static ArgConverter getArgConverter(Class cls) {
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
483 if( cls == Double.TYPE || cls.equals(Double.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
484 return ARG_DOUBLE;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
485 if( cls == Float.TYPE || cls.equals(Float.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
486 return ARG_FLOAT;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
487 if( cls == Long.TYPE || cls.equals(Long.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
488 return ARG_LONG;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
489 if( cls == Integer.TYPE || cls.equals(Integer.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
490 return ARG_INTEGER;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
491 if( cls == Short.TYPE || cls.equals(Short.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
492 return ARG_SHORT;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
493 if( cls == Byte.TYPE || cls.equals(Byte.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
494 return ARG_BYTE;
48
64ecb7a3aad7 rename Lua to Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 47
diff changeset
495 if( cls.equals(LuanTable.class) )
47
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
496 return ARG_TABLE;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
497 if( cls.equals(Map.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
498 return ARG_MAP;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
499 if( cls.equals(List.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
500 return ARG_LIST;
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
501 if( cls.equals(Set.class) )
659c7139e903 better conversion
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 46
diff changeset
502 return ARG_SET;
396
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
503 if( cls.equals(Collection.class) )
ba8b0aae6453 work on manual;
Franklin Schmidt <fschmidt@gmail.com>
parents: 297
diff changeset
504 return ARG_COLLECTION;
57
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
505 if( cls.isArray() && !cls.getComponentType().isPrimitive() )
19ca9c4c6c7f auto-convert table to java array
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 56
diff changeset
506 return new ArgArray(cls);
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
507 return ARG_SAME;
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
508 }
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
509
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
510
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
511
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
512 private static abstract class JavaMethod {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
513 abstract boolean isVarArgs();
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
514 abstract Class[] getParameterTypes();
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
515 abstract Object invoke(Object obj,Object... args)
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
516 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException;
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
517 abstract Class getReturnType();
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
518 abstract boolean isLuan();
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
519
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
520 static JavaMethod of(final Method m) {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
521 return new JavaMethod() {
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
522 @Override boolean isVarArgs() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
523 return m.isVarArgs();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
524 }
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
525 @Override Class[] getParameterTypes() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
526 return m.getParameterTypes();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
527 }
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
528 @Override Object invoke(Object obj,Object... args)
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
529 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
530 {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
531 return m.invoke(obj,args);
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
532 }
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
533 @Override Class getReturnType() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
534 return m.getReturnType();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
535 }
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
536 @Override boolean isLuan() {
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
537 return m.getAnnotation(LuanMethod.class) != null;
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
538 }
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
539 @Override public String toString() {
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
540 return m.toString();
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
541 }
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
542 };
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
543 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
544
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
545 static JavaMethod of(final Constructor c) {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
546 return new JavaMethod() {
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
547 @Override boolean isVarArgs() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
548 return c.isVarArgs();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
549 }
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
550 @Override Class[] getParameterTypes() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
551 return c.getParameterTypes();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
552 }
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
553 @Override Object invoke(Object obj,Object... args)
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
554 throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
555 {
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
556 return c.newInstance(args);
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
557 }
434
472fc70853cd remove more generics
Franklin Schmidt <fschmidt@gmail.com>
parents: 432
diff changeset
558 @Override Class getReturnType() {
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
559 return c.getDeclaringClass();
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
560 }
297
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
561 @Override boolean isLuan() {
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
562 return false;
899253043270 remove PackageLuan.load_lib()
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 249
diff changeset
563 }
43
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
564 @Override public String toString() {
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
565 return c.toString();
80b67b1a653c implement string lib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 40
diff changeset
566 }
37
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
567 };
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
568 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
569
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
570 }
8a57ebfdfd78 add JavaLib
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents: 21
diff changeset
571
1
2df768b926aa start Luan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff changeset
572 }