Luna_LWF_Button.push C# (CSharp) Method

push() public static method

public static push ( Lua L, LWF obj, bool gc, Lua metatable = null ) : void
L Lua
obj LWF
gc bool
metatable Lua
return void
    public static void push(Lua.lua_State L, LWF.Button 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_Button.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_Button.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);
    }

Usage Example

Beispiel #1
0
    public static int __index(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) == 2 && Luna.get_uniqueid(L, 1) ==
            LunaTraits_LWF_Movie.uniqueID)
        {
            LWF.Movie o =
                Luna_LWF_Movie.check(L, 1);
            string name = Lua.lua_tostring(L, 2).ToString();
            if (o.lwf.GetFieldLua(o, name))
            {
                return(1);
            }
            LWF.Movie movie = o.SearchMovieInstance(name, false);
            if (movie != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Movie.push(L, movie, false);
                return(1);
            }
            LWF.Button button = o.SearchButtonInstance(name, false);
            if (button != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Button.push(L, button, false);
                return(1);
            }
        }


        {
            Lua.lua_CFunction fnc = null;
            if (LunaTraits_LWF_Movie.properties.TryGetValue(Lua.lua_tostring(L, 2).ToString(), out fnc))
            {
                Lua.lua_pop(L, 1);                // remove self
                return(fnc(L));
            }
        }

        int mt = Lua.lua_getmetatable(L, 1);

        if (mt == 0)
        {
            Lua.luaL_error(L, "__index");             //end
        }
        Lua.lua_pushstring(L, Lua.lua_tostring(L, 2));
        Lua.lua_rawget(L, -2);
        return(1);
    }
All Usage Examples Of Luna_LWF_Button::push