Changeset 220 for trunk


Ignore:
Timestamp:
12/17/13 23:57:51 (12 years ago)
Author:
epyon
Message:
  • nv::lua - lua_raw byte array function (probably should be templated or other versions added)
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/lua/lua_raw.hh

    r198 r220  
    1111#include <istream>
    1212#include <string>
     13#include <vector>
    1314#include <map>
    1415
     
    2627void nlua_tokeyset( lua_State *L, int index );
    2728
     29std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index );
     30
    2831void nlua_register( lua_State *L, const char* fname, lua_CFunction func, int index );
    2932void nlua_register( lua_State *L, const luaL_Reg *l, int index );
  • trunk/src/lua/lua_raw.cc

    r162 r220  
    248248        }
    249249}
     250
     251std::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index )
     252{
     253        index = lua_absindex( L, index );
     254        std::vector<nv::uint8> result;
     255        if ( lua_istable( L, index ) )
     256        {
     257                lua_pushnil( L );
     258                while ( lua_next( L, index ) != 0 )
     259                {
     260                        result.push_back( (nv::uint8) lua_tointeger( L, -1 ) );
     261                        lua_pop( L, 1 );
     262                }
     263        }
     264        return result;
     265}
Note: See TracChangeset for help on using the changeset viewer.