// use lunaStack::push if possible. public static void push(Lua.lua_State L, LWF.Point obj, bool gc, Lua.CharPtr metatable = null) { int objectId = -1; if (!objectIdentifiers[L].TryGetValue(obj, out objectId)) { objectId = idOffset++; objectIdentifiers[L].Add(obj, objectId); objects[L].Add(objectId, obj); } if (metatable == null) { metatable = LunaTraits_LWF_Point.className; } Lua.lua_pushstring(L, "__luna"); Lua.lua_gettable(L, Lua.LUA_GLOBALSINDEX); int __luna = Lua.lua_gettop(L); Luna.userdataType ud = new Luna.userdataType( objectId: objectId, // store object in userdata gc: gc, // collect garbage has_env: false, // does this userdata has a table attached to it? typeId: LunaTraits_LWF_Point.uniqueID ); ud.ToBytes((byte[])Lua.lua_newuserdata(L, Luna.userdataType.Size)); Lua.lua_pushstring(L, metatable); Lua.lua_gettable(L, __luna); Lua.lua_setmetatable(L, -2); //Luna.printStack(L); Lua.lua_insert(L, -2); // swap __luna and userdata Lua.lua_pop(L, 1); }
} // hide default constructor // create a new T object and // push onto the Lua stack a userdata containing a pointer to T object private static int new_T(Lua.lua_State L) { Lua.lua_remove(L, 1); // use classname:new(), instead of classname.new() LWF.Point obj = LunaTraits_LWF_Point._bind_ctor(L); // call constructor for T objects push(L, obj, true); return(1); // userdata containing pointer to T object }
public static void Destroy(Lua.lua_State L, LWF.Point obj) { int objectId = -1; if (objectIdentifiers[L].TryGetValue(obj, out objectId)) { objectIdentifiers[L].Remove(obj); objects[L].Remove(objectId); } }
private static int tostring_T(Lua.lua_State L) { Luna.userdataType ud = (Luna.userdataType)Lua.lua_touserdata(L, 1); LWF.Point obj = null; if (!objects[L].TryGetValue(ud.ObjectId, out obj)) { return(0); } char[] buff = obj.ToString().ToCharArray(0, 32); Lua.lua_pushfstring(L, "%s (%s)", new object[] { LunaTraits_LWF_Point.className, buff }); return(1); }
public static int _bind__property_get_x(Lua.lua_State L) { if (Lua.lua_gettop(L) != 1 || Luna.get_uniqueid(L, 1) != 32383421) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_get_x(LWF.Point a)"); } LWF.Point a = Luna_LWF_Point.check(L, 1); try { float ret = _property_get_x(a); Lua.lua_pushnumber(L, ret); } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); } return(1); }
// garbage collection metamethod private static int gc_T(Lua.lua_State L) { Luna.userdataType ud = (Luna.userdataType)Lua.lua_touserdata(L, 1); LWF.Point obj = null; if (!objects[L].TryGetValue(ud.ObjectId, out obj)) { return(0); } if (ud.Gc) { LunaTraits_LWF_Point._bind_dtor(obj); // call constructor for T objects } Destroy(L, obj); return(0); }
public static int _bind__property_set_y(Lua.lua_State L) { if (Lua.lua_gettop(L) != 2 || Luna.get_uniqueid(L, 1) != 32383421 || Lua.lua_isnumber(L, 2) == 0) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_set_y(LWF.Point a, float b)"); } LWF.Point a = Luna_LWF_Point.check(L, 1); float b = (float)(float)Lua.lua_tonumber(L, 2); try { _property_set_y(a, b); } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); } return(0); }
public static int _bind_localToGlobal(Lua.lua_State L) { if (Lua.lua_gettop(L) != 2 || Luna.get_uniqueid(L, 1) != 29625181 || Luna.get_uniqueid(L, 2) != LunaTraits_LWF_Point.uniqueID) { Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:localToGlobal(LWF.Movie self)"); } LWF.Movie self = Luna_LWF_Movie.check(L, 1); LWF.Point point = Luna_LWF_Point.check(L, 2); try { LWF.Point ret = self.LocalToGlobal(point); Luna_LWF_Point.push(L, ret, true, "LWF_Point"); } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); } return(1); }
private static int tostring_T(Lua.lua_State L) { byte[] d = (byte[])Lua.lua_touserdata(L, 1); if (d == null) { Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, 1, LunaTraits_LWF_Point.className); } Luna.userdataType ud = new Luna.userdataType(d); LWF.Point obj = null; if (!objects[L].TryGetValue(ud.ObjectId, out obj)) { return(0); } char[] buff = obj.ToString().ToCharArray(0, 32); Lua.lua_pushfstring(L, "%s (%s)", new object[] { LunaTraits_LWF_Point.className, buff }); return(1); }
static public LWF.Point check(Lua.lua_State L, int narg) { byte[] d = (byte[])Lua.lua_touserdata(L, narg); if (d == null) { Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, narg, LunaTraits_LWF_Point.className); } Luna.userdataType ud = new Luna.userdataType(d); if (ud.TypeId != LunaTraits_LWF_Point.uniqueID) // type checking with almost no overhead { Luna.print(String.Format("ud.uid: {0} != interface::uid : {1}\n", ud.TypeId, LunaTraits_LWF_Point.uniqueID)); Lua.luaL_typerror(L, narg, LunaTraits_LWF_Point.className); } LWF.Point obj = null; if (!objects[L].TryGetValue(ud.ObjectId, out obj)) { return(null); } return(obj); }
// garbage collection metamethod private static int gc_T(Lua.lua_State L) { byte[] d = (byte[])Lua.lua_touserdata(L, 1); if (d == null) { Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, 1, LunaTraits_LWF_Point.className); } Luna.userdataType ud = new Luna.userdataType(d); LWF.Point obj = null; if (!objects[L].TryGetValue(ud.ObjectId, out obj)) { return(0); } if (ud.Gc) { LunaTraits_LWF_Point._bind_dtor(obj); // call constructor for T objects Destroy(L, obj); } return(0); }
public static void _property_set_y(LWF.Point a, float b) { a.y = b; }
public static float _property_get_y(LWF.Point a) { return(a.y); }
public static void _bind_dtor(LWF.Point obj) { }