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