示例#1
0
        internal void push(IntPtr l, object o)
        {
            if (o == null)
            {
                LuaDLL.lua_pushnil(l);
                return;
            }
            int index = -1;

            bool gco   = isGcObject(o);
            bool found = gco && objMap.TryGetValue(o, out index);

            if (found)
            {
                if (getUDCache(l, index))
                {
                    return;
                }
            }


            index = add(o);
            LuaDLL.luaS_newuserdata(l, index);
            if (gco)
            {
                cacheUD(l, index);
            }


            LuaDLL.luaL_getmetatable(l, getAQName(o));
            if (LuaDLL.lua_isnil(l, -1))
            {
                LuaDLL.lua_pop(l, 1);
                LuaDLL.luaL_getmetatable(l, "LuaVarObject");
            }

            LuaDLL.lua_setmetatable(l, -2);
        }