Get instance data directly from the stack.

This commit is contained in:
James Roseborough
2009-10-24 03:36:51 +00:00
parent 3c2413a88a
commit ebb5c84b74

View File

@@ -227,9 +227,8 @@ public final class LuajavaLib extends LFunction {
mt = new LTable(); mt = new LTable();
mt.put( LValue.TM_INDEX, new LFunction() { mt.put( LValue.TM_INDEX, new LFunction() {
public boolean luaStackCall(LuaState vm) { public boolean luaStackCall(LuaState vm) {
LValue table = vm.topointer(2); Object instance = vm.touserdata(2);
LValue key = vm.topointer(3); LValue key = vm.topointer(3);
Object instance = table.toJavaInstance();
if ( key instanceof LInteger ) { if ( key instanceof LInteger ) {
if ( clazz.isArray() ) { if ( clazz.isArray() ) {
vm.resettop(); vm.resettop();
@@ -261,11 +260,9 @@ public final class LuajavaLib extends LFunction {
}); });
mt.put( LValue.TM_NEWINDEX, new LFunction() { mt.put( LValue.TM_NEWINDEX, new LFunction() {
public boolean luaStackCall(LuaState vm) { public boolean luaStackCall(LuaState vm) {
LValue table = vm.topointer(2); Object instance = vm.touserdata(2);
LValue key = vm.topointer(3); LValue key = vm.topointer(3);
LValue val = vm.topointer(4); LValue val = vm.topointer(4);
Object instance = table.toJavaInstance();
if ( key instanceof LInteger ) { if ( key instanceof LInteger ) {
if ( clazz.isArray() ) { if ( clazz.isArray() ) {
vm.resettop(); vm.resettop();