internal void setObject(int reference, object field, object o) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getref(L, reference); LuaObject.pushObject(L, field); LuaObject.pushObject(L, o); LuaDLL.lua_settable(L, -3); LuaDLL.lua_settop(L, oldTop); }
static public new int ToBytes(IntPtr l) { try{ byte[] bytes = null; checkBinaryString(l, 1, out bytes); LuaObject.pushObject(l, bytes); return(1); }catch (System.Exception e) { return(error(l, e)); } }
internal object getObject(int reference, object field) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getref(L, reference); LuaObject.pushObject(L, field); LuaDLL.lua_gettable(L, -2); object returnValue = getObject(L, -1); LuaDLL.lua_settop(L, oldTop); return(returnValue); }
internal static void pushVar(IntPtr l, object o) { if (o == null) { LuaDLL.lua_pushnil(l); return; } string t = o.GetType().Name; switch (t) { case "Single": LuaDLL.lua_pushnumber(l, (float)o); break; case "Double": LuaDLL.lua_pushnumber(l, (double)o); break; case "Int32": case "Uint32": LuaDLL.lua_pushinteger(l, (int)o); break; case "Int64": case "UInt64": #if LUA_5_3 LuaDLL.lua_pushinteger(l, (long)o); #else LuaDLL.lua_pushnumber(l, (double)o); #endif break; case "String": LuaDLL.lua_pushstring(l, (string)o); break; case "Boolean": LuaDLL.lua_pushboolean(l, (bool)o); break; case "LuaTable": case "LuaFunction": ((LuaVar)o).push(l); break; default: LuaObject.pushObject(l, o); break; } }
static void PushComponentObjectToLua(MenuCommand cmd) { Component com = cmd.context as Component; if (com == null) { return; } LuaState luaState = LuaState.main; if (luaState == null) { return; } LuaObject.pushObject(luaState.L, com); LuaDLL.lua_setglobal(luaState.L, "_"); }
internal object getObject(int reference, object field, bool rawget = false) { int oldTop = LuaDLL.lua_gettop(L); LuaDLL.lua_getref(L, reference); LuaObject.pushObject(L, field); if (rawget) { LuaDLL.lua_rawget(L, -2); } else { LuaDLL.lua_gettable(L, -2); } object returnValue = getObject(L, -1); LuaDLL.lua_settop(L, oldTop); return(returnValue); }
static public int GetClass(IntPtr l) { try { string cls; checkType(l, 1, out cls); Type t = LuaObject.FindType(cls); if (t == null) { return(error(l, "Can't find {0} to create", cls)); } LuaClassObject co = new LuaClassObject(t); pushValue(l, true); LuaObject.pushObject(l, co); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int GetClass(IntPtr l) { try { string cls; checkType(l, 1, out cls); Type t = Type.GetType(cls); if (t == null) { LuaDLL.luaL_error(l, "Can't find {0} to create", cls); return(0); } LuaClassObject co = new LuaClassObject(t); LuaObject.pushObject(l, co); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }