/* * Creates a new unnamed table */ public LuaTable NewTable() { int oldTop = LuaDLL.lua_gettop(luaState); LuaDLL.lua_newtable(luaState); LuaTable table = translator.getTable(luaState, -1); LuaDLL.lua_settop(luaState, oldTop); table.IsOrphaned = true; return(table); }
public static int registerTable(IntPtr luaState) { #if __NOGEN__ throwError(luaState, "Tables as Objects not implemnented"); #else ObjectTranslator translator = ObjectTranslator.FromState(luaState); if (LuaDLL.lua_type(luaState, 1) == LuaTypes.LUA_TTABLE) { LuaTable luaTable = translator.getTable(luaState, 1); string superclassName = LuaDLL.lua_tostring(luaState, 2); if (superclassName != null) { Type klass = translator.FindType(superclassName); if (klass != null) { // Creates and pushes the object in the stack, setting // it as the metatable of the first argument object obj = CodeGeneration.Instance.GetClassInstance(klass, luaTable); translator.pushObject(luaState, obj, "luaNet_metatable"); LuaDLL.lua_newtable(luaState); LuaDLL.lua_pushstring(luaState, "__index"); LuaDLL.lua_pushvalue(luaState, -3); LuaDLL.lua_settable(luaState, -3); LuaDLL.lua_pushstring(luaState, "__newindex"); LuaDLL.lua_pushvalue(luaState, -3); LuaDLL.lua_settable(luaState, -3); LuaDLL.lua_setmetatable(luaState, 1); // Pushes the object again, this time as the base field // of the table and with the luaNet_searchbase metatable LuaDLL.lua_pushstring(luaState, "base"); int index = translator.addObject(obj); translator.pushNewObject(luaState, obj, index, "luaNet_searchbase"); LuaDLL.lua_rawset(luaState, 1); } else { translator.throwError(luaState, "register_table: can not find superclass '" + superclassName + "'"); } } else { translator.throwError(luaState, "register_table: superclass name can not be null"); } } else { translator.throwError(luaState, "register_table: first arg is not a table"); } #endif return(0); }
public static int registerTable(IntPtr luaState) { ObjectTranslator objectTranslator = ObjectTranslator.FromState(luaState); if (LuaDLL.lua_type(luaState, 1) == LuaTypes.LUA_TTABLE) { LuaTable table = objectTranslator.getTable(luaState, 1); string text = LuaDLL.lua_tostring(luaState, 2); if (text != null) { Type type = objectTranslator.FindType(text); if (type != null) { object classInstance = CodeGeneration.Instance.GetClassInstance(type, table); objectTranslator.pushObject(luaState, classInstance, "luaNet_metatable"); LuaDLL.lua_newtable(luaState); LuaDLL.lua_pushstring(luaState, "__index"); LuaDLL.lua_pushvalue(luaState, -3); LuaDLL.lua_settable(luaState, -3); LuaDLL.lua_pushstring(luaState, "__newindex"); LuaDLL.lua_pushvalue(luaState, -3); LuaDLL.lua_settable(luaState, -3); LuaDLL.lua_setmetatable(luaState, 1); LuaDLL.lua_pushstring(luaState, "base"); int index = objectTranslator.addObject(classInstance); objectTranslator.pushNewObject(luaState, classInstance, index, "luaNet_searchbase"); LuaDLL.lua_rawset(luaState, 1); } else { objectTranslator.throwError(luaState, "register_table: can not find superclass '" + text + "'"); } } else { objectTranslator.throwError(luaState, "register_table: superclass name can not be null"); } } else { objectTranslator.throwError(luaState, "register_table: first arg is not a table"); } return(0); }
public object extractGenerated(IntPtr luaState, int stackPos) { return(CodeGeneration.Instance.GetClassInstance(klass, translator.getTable(luaState, stackPos))); }
private object getAsTable(IntPtr luaState, int stackPos) { return(translator.getTable(luaState, stackPos)); }
public object extractGenerated(lua.State L, int index) { Debug.Assert(translator.interpreter.IsSameLua(L)); return(CodeGeneration.Instance.GetClassInstance(klass, translator.getTable(L, index))); }
private object getAsTable(KopiLua.LuaState luaState, int stackPos) { return(translator.getTable(luaState, stackPos)); }
object asTable(lua.State L, int index) { return(lua.type(L, index) == LUA.T.TABLE ? translator.getTable(L, index) : null); }
private object getAsTable(LuaCore.lua_State luaState, int stackPos) { return(translator.getTable(luaState, stackPos)); }