コード例 #1
0
ファイル: scope.cpp プロジェクト: Cosmotronic/hexahedra
    void module_::operator[](scope s)
    {
        if (m_name)
        {
            lua_pushstring(m_state, m_name);
            lua_gettable(m_state, LUA_GLOBALSINDEX);

            if (!lua_istable(m_state, -1))
            {
                lua_pop(m_state, 1);

                lua_newtable(m_state);
                lua_pushstring(m_state, m_name);
                lua_pushvalue(m_state, -2);
                lua_settable(m_state, LUA_GLOBALSINDEX);
            }
        }
        else
        {
            lua_pushvalue(m_state, LUA_GLOBALSINDEX);
        }

        lua_pop_stack guard(m_state);

        s.register_(m_state);
    }
コード例 #2
0
ファイル: scope.cpp プロジェクト: halmd-org/luaponte
void module_::operator[](scope s)
{
    lua_State* L = m_table.interpreter();

    m_table.push(L);

    lua_pop_stack guard(L);

    s.register_(L);
}
コード例 #3
0
ファイル: scope.cpp プロジェクト: 9thsector/Server
    void module_::operator[](scope s)
    {
        if (m_name)
        {
            lua_getglobal(m_state, m_name);

            if (!lua_istable(m_state, -1))
            {
                lua_pop(m_state, 1);

                lua_newtable(m_state);
                lua_pushvalue(m_state, -1);
                lua_setglobal(m_state, m_name);
            }
        }
        else
        {
            lua_pushglobaltable(m_state);
        }

        lua_pop_stack guard(m_state);

        s.register_(m_state);
    }