Mercurial Hosting > luan
comparison src/luan/lib/JavaLib.java @ 55:9381b23ea9e1
various fixes
git-svn-id: https://luan-java.googlecode.com/svn/trunk@56 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 04 Jan 2013 04:50:18 +0000 |
parents | 28dfd91a816c |
children | c84274b18f0c |
comparison
equal
deleted
inserted
replaced
54:f5b27ef14d73 | 55:9381b23ea9e1 |
---|---|
10 import java.util.Map; | 10 import java.util.Map; |
11 import java.util.HashMap; | 11 import java.util.HashMap; |
12 import java.util.List; | 12 import java.util.List; |
13 import java.util.ArrayList; | 13 import java.util.ArrayList; |
14 import java.util.Iterator; | 14 import java.util.Iterator; |
15 import java.util.Collections; | |
15 import luan.Luan; | 16 import luan.Luan; |
16 import luan.LuanState; | 17 import luan.LuanState; |
17 import luan.LuanTable; | 18 import luan.LuanTable; |
18 import luan.MetatableGetter; | 19 import luan.MetatableGetter; |
19 import luan.LuanException; | 20 import luan.LuanException; |
108 if( !members.isEmpty() ) { | 109 if( !members.isEmpty() ) { |
109 return member(obj,members); | 110 return member(obj,members); |
110 } | 111 } |
111 } | 112 } |
112 } | 113 } |
113 throw new LuanException(luan,LuanElement.JAVA,"invalid index for java object: "+key); | 114 throw new LuanException(luan,LuanElement.JAVA,"invalid member for java object: "+key); |
114 } | 115 } |
115 | 116 |
116 private static Object member(Object obj,List<AccessibleObject> members) throws LuanException { | 117 private static Object member(Object obj,List<AccessibleObject> members) throws LuanException { |
117 try { | 118 try { |
118 for( AccessibleObject m : members ) { | 119 for( AccessibleObject m : members ) { |
164 } | 165 } |
165 list.add(method); | 166 list.add(method); |
166 } | 167 } |
167 memberMap.put(cls,clsMap); | 168 memberMap.put(cls,clsMap); |
168 } | 169 } |
169 return clsMap.get(name); | 170 List<AccessibleObject> rtn = clsMap.get(name); |
171 if( rtn==null ) | |
172 rtn = Collections.emptyList(); | |
173 return rtn; | |
170 } | 174 } |
171 | 175 |
172 private static synchronized List<AccessibleObject> getStaticMembers(Class cls,String name) { | 176 private static synchronized List<AccessibleObject> getStaticMembers(Class cls,String name) { |
173 List<AccessibleObject> staticMembers = new ArrayList<AccessibleObject>(); | 177 List<AccessibleObject> staticMembers = new ArrayList<AccessibleObject>(); |
174 for( AccessibleObject m : getMembers(cls,name) ) { | 178 for( AccessibleObject m : getMembers(cls,name) ) { |
220 } | 224 } |
221 | 225 |
222 @Override public Object[] call(LuanState luan,Object[] args) throws LuanException { | 226 @Override public Object[] call(LuanState luan,Object[] args) throws LuanException { |
223 for( LuanJavaFunction fn : fnMap.get(args.length) ) { | 227 for( LuanJavaFunction fn : fnMap.get(args.length) ) { |
224 try { | 228 try { |
225 return fn.call(luan,args); | 229 return fn.rawCall(luan,args); |
226 } catch(IllegalArgumentException e) {} | 230 } catch(IllegalArgumentException e) {} |
227 } | 231 } |
228 throw new LuanException(luan,LuanElement.JAVA,"no method matched args"); | 232 throw new LuanException(luan,LuanElement.JAVA,"no method matched args"); |
229 } | 233 } |
230 } | 234 } |