private static int toString (LuaCore.lua_State luaState, ObjectTranslator translator) { object obj = translator.getRawNetObject (luaState, 1); if (!obj.IsNull ()) translator.push (luaState, obj.ToString () + ": " + obj.GetHashCode ()); else LuaLib.lua_pushnil (luaState); return 1; }
/// <summary> /// Debug tool to dump the lua stack /// </summary> /// FIXME, move somewhere else public static void dumpStack (ObjectTranslator translator, LuaCore.lua_State luaState) { int depth = LuaLib.lua_gettop (luaState); Debug.WriteLine ("lua stack depth: " + depth); for (int i = 1; i <= depth; i++) { var type = LuaLib.lua_type (luaState, i); // we dump stacks when deep in calls, calling typename while the stack is in flux can fail sometimes, so manually check for key types string typestr = (type == LuaTypes.Table) ? "table" : LuaLib.lua_typename (luaState, type); string strrep = LuaLib.lua_tostring (luaState, i).ToString (); if (type == LuaTypes.UserData) { object obj = translator.getRawNetObject (luaState, i); strrep = obj.ToString (); } #if WINDOWS_PHONE Debug.WriteLine("{0}: ({1}) {2}", i, typestr, strrep); #elif !SILVERLIGHT Debug.Print ("{0}: ({1}) {2}", i, typestr, strrep); #endif } }
private static int runFunctionDelegate (LuaCore.lua_State luaState, ObjectTranslator translator) { LuaCore.lua_CFunction func = (LuaCore.lua_CFunction)translator.getRawNetObject (luaState, 1); LuaLib.lua_remove (luaState, 1); return func (luaState); }