delegate metatable gets, sets to luastate
This commit is contained in:
@@ -33,22 +33,6 @@ public class LFunction extends LValue {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void luaSetTable(LuaState vm, LValue table, LValue key, LValue val) {
|
||||
vm.pushlvalue( this );
|
||||
vm.pushlvalue( table );
|
||||
vm.pushlvalue( key );
|
||||
vm.pushlvalue( val );
|
||||
vm.call( 3, 0 );
|
||||
}
|
||||
|
||||
public LValue luaGetTable(LuaState vm, LValue table, LValue key) {
|
||||
vm.pushlvalue( this );
|
||||
vm.pushlvalue( table );
|
||||
vm.pushlvalue( key );
|
||||
vm.call( 2, 1 );
|
||||
return vm.poplvalue();
|
||||
}
|
||||
|
||||
public int luaGetType() {
|
||||
return Lua.LUA_TFUNCTION;
|
||||
}
|
||||
|
||||
@@ -232,21 +232,13 @@ public class LTable extends LValue {
|
||||
(hashKeys.length>0 && hashKeys[hashFindSlot(LInteger.valueOf(key))]!=null));
|
||||
}
|
||||
|
||||
|
||||
public LValue luaGetTable(LuaState vm, LValue table, LValue key) {
|
||||
LValue v = get(key);
|
||||
if ( v.isNil() && m_metatable != null ) {
|
||||
return super.luaGetTable( vm, table, key );
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
vm.luaV_gettable(table, key);
|
||||
return vm.poplvalue();
|
||||
}
|
||||
|
||||
public void luaSetTable(LuaState vm, LValue table, LValue key, LValue val) {
|
||||
if ( (!containsKey( key )) && m_metatable != null && m_metatable.containsKey(TM_NEWINDEX) )
|
||||
m_metatable.get(TM_NEWINDEX).luaSetTable( vm, table, key, val );
|
||||
else
|
||||
put(key,val);
|
||||
vm.luaV_settable(table, key, val);
|
||||
}
|
||||
|
||||
private static final int MAX_KEY = 0x3fffffff;
|
||||
|
||||
Reference in New Issue
Block a user