Refactor luaGetTable() to return a value.

This commit is contained in:
James Roseborough
2008-05-23 00:37:45 +00:00
parent c20ea01bc9
commit c2c573744b
11 changed files with 154 additions and 44 deletions

View File

@@ -144,15 +144,14 @@ public final class LuajavaLib extends LFunction {
super(o);
this.clazz = clazz;
}
public void luaGetTable(LuaState vm, LValue table, LValue key) {
public LValue luaGetTable(LuaState vm, LValue table, LValue key) {
final String s = key.toJavaString();
try {
Field f = clazz.getField(s);
Object o = f.get(m_instance);
LValue v = CoerceJavaToLua.coerce( o );
vm.pushlvalue( v );
return CoerceJavaToLua.coerce( o );
} catch (NoSuchFieldException nsfe) {
vm.pushlvalue( new LMethod(m_instance,clazz,s) );
return new LMethod(m_instance,clazz,s);
} catch (Exception e) {
throw new LuaErrorException(e);
}