Exemplo n.º 1
0
static int l_layers_persist(lua_State *L)
{
    THLayers_t* pLayers = luaT_testuserdata<THLayers_t>(L);
    lua_settop(L, 2);
    lua_insert(L, 1);
    LuaPersistWriter* pWriter = (LuaPersistWriter*)lua_touserdata(L, 1);

    int iNumLayers = 13;
    for( ; iNumLayers >= 1; --iNumLayers)
    {
        if(pLayers->iLayerContents[iNumLayers - 1] != 0)
            break;
    }
    pWriter->writeVUInt(iNumLayers);
    pWriter->writeByteStream(pLayers->iLayerContents, iNumLayers);
    return 0;
}
Exemplo n.º 2
0
static int l_anim_persist(lua_State *L)
{
    T* pAnimation;
    if(lua_gettop(L) == 2)
    {
        pAnimation = luaT_testuserdata<T>(L, 1, luaT_environindex, false);
        lua_insert(L, 1);
    }
    else
    {
        // Fast __persist call
        pAnimation = (T*)lua_touserdata(L, -1);
    }
    LuaPersistWriter* pWriter = (LuaPersistWriter*)lua_touserdata(L, 1);

    pAnimation->persist(pWriter);
    lua_rawgeti(L, luaT_environindex, 1);
    lua_pushlightuserdata(L, pAnimation);
    lua_gettable(L, -2);
    pWriter->writeStackObject(-1);
    lua_pop(L, 2);
    return 0;
}
Exemplo n.º 3
0
// __persist metamethod handler
static int l_str_persist(lua_State *L)
{
    lua_settop(L, 2);
    lua_insert(L, 1);
    LuaPersistWriter *pWriter = (LuaPersistWriter*)lua_touserdata(L, 1);

    // Recreation instructions are stored in the environment, which is written
    // automatically. For compatibility, we write a simple boolean.
    lua_pushboolean(L, 1);
    pWriter->writeStackObject(3);
    lua_getfenv(L, 2);

    // If there were no instructions (i.e. for the root object) then write the
    // value as well.
    if(lua_objlen(L, -1) == 0)
    {
        lua_pop(L, 2);
        aux_push_weak_table(L, 0);
        lua_pushvalue(L, 2);
        lua_rawget(L, 3);
        pWriter->writeStackObject(4);
    }
    return 0;
}