public void SetObject(int reference, object field, object o) { int oldTop = LuaNativeMethods.lua_gettop(statePointer); LuaNativeMethods.lua_getref(statePointer, reference); LuaObject.PushObject(statePointer, field); LuaObject.PushObject(statePointer, o); LuaNativeMethods.lua_settable(statePointer, -3); LuaNativeMethods.lua_settop(statePointer, oldTop); }
public object GetObject(int reference, object field) { int oldTop = LuaNativeMethods.lua_gettop(statePointer); LuaNativeMethods.lua_getref(statePointer, reference); LuaObject.PushObject(statePointer, field); LuaNativeMethods.lua_gettable(statePointer, -2); object returnValue = GetObject(statePointer, -1); LuaNativeMethods.lua_settop(statePointer, oldTop); return(returnValue); }
public static int ToBytes(IntPtr ptr) { try { byte[] bytes = null; LuaObject.CheckBinaryString(ptr, 1, out bytes); LuaObject.PushValue(ptr, true); LuaObject.PushObject(ptr, bytes); return(2); } catch (System.Exception e) { return(Error(ptr, e)); } }
public static int GetClass(IntPtr ptr) { try { string cls; CheckType(ptr, 1, out cls); Type t = LuaObject.FindType(cls); if (t == null) { return(Error(ptr, "Can't find {0} to create", cls)); } LuaClassObject co = new LuaClassObject(t); LuaObject.PushValue(ptr, true); LuaObject.PushObject(ptr, co); return(2); } catch (Exception e) { return(Error(ptr, e)); } }