Changeset 162
- Timestamp:
- 07/15/13 20:13:27 (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/array2d.hh
r141 r162 184 184 inline reference operator[] ( const ivec2& c ) 185 185 { 186 NV_ASSERT( x >= 0 && y >= 0 && x < m_size.x &&y < m_size.y, "Bad parameters passed to array2d[]" );186 NV_ASSERT( c.x >= 0 && c.y >= 0 && c.x < m_size.x && c.y < m_size.y, "Bad parameters passed to array2d[]" ); 187 187 return m_data[ c.y * m_size.x + c.x ]; 188 188 } -
trunk/nv/lua/lua_raw.hh
r121 r162 11 11 #include <istream> 12 12 #include <string> 13 #include <bitset>14 13 #include <map> 14 15 void nlua_toflags_flat( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); 16 void nlua_toflags_array( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); 17 void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count ); 15 18 16 19 std::string nlua_typecontent( lua_State* L, int idx ); -
trunk/nv/lua/lua_state.hh
r121 r162 11 11 #include <map> 12 12 #include <nv/common.hh> 13 #include <nv/flags.hh> 13 14 #include <string> 14 15 … … 52 53 double get_double( const std::string& element, double defval = 0.0 ); 53 54 bool get_boolean( const std::string& element, bool defval = false ); 54 public: 55 56 template< uint32 SIZE, typename T > 57 flags< SIZE, T > get_flags( const std::string& element ) 58 { 59 flags< SIZE, T > result; 60 get_raw_flags( element, result.data(), result.size() ); 61 return result; 62 } 63 64 template< uint32 SIZE, typename T > 65 void load_flags( const std::string& element, flags< SIZE, T >& flags ) 66 { 67 get_raw_flags( element, flags.data(), flags.size() ); 68 } 69 private: 70 void get_raw_flags( const std::string& element, uint8* data, uint32 count ); 71 55 72 state* L; 56 73 stack_guard m_guard; -
trunk/src/lua/lua_raw.cc
r121 r162 188 188 lua_pop( L, 1 ); 189 189 } 190 191 void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count ) 192 { 193 index = lua_absindex( L, index ); 194 nv::uint32 flag; 195 if ( lua_istable( L, index ) ) 196 { 197 lua_pushnil( L ); 198 while ( lua_next( L, index ) != 0 ) 199 { 200 if ( lua_type( L, -1 ) == LUA_TBOOLEAN ) 201 flag = static_cast< nv::uint32 >( lua_tointeger( L ,-2 ) ); 202 else 203 flag = static_cast< nv::uint32 >( lua_tointeger( L ,-1 ) ); 204 lua_pop( L, 1 ); 205 if ( flag < count ) 206 { 207 data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) ); 208 } 209 } 210 } 211 } 212 213 void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count ) 214 { 215 index = lua_absindex( L, index ); 216 nv::uint32 flag; 217 if ( lua_istable( L, index ) ) 218 { 219 lua_pushnil( L ); 220 while ( lua_next( L, index ) != 0 ) 221 { 222 flag = static_cast< nv::uint32 >( lua_tointeger( L ,-2 ) ); 223 lua_pop( L, 1 ); 224 if ( flag < count ) 225 { 226 data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) ); 227 } 228 } 229 } 230 } 231 232 void nlua_toflags_array( lua_State *L, int index, nv::uint8* data, nv::uint32 count ) 233 { 234 index = lua_absindex( L, index ); 235 nv::uint32 flag; 236 if ( lua_istable( L, index ) ) 237 { 238 lua_pushnil( L ); 239 while ( lua_next( L, index ) != 0 ) 240 { 241 flag = static_cast< nv::uint32 >( lua_tointeger( L ,-1 ) ); 242 lua_pop( L, 1 ); 243 if ( flag < count ) 244 { 245 data[ flag / 8 ] |= ( 1 << static_cast< nv::uint8 >( flag % 8 ) ); 246 } 247 } 248 } 249 } -
trunk/src/lua/lua_state.cc
r121 r162 279 279 } 280 280 281 void lua::table_guard::get_raw_flags( const std::string& element, uint8* data, uint32 count ) 282 { 283 lua_getfield( L->L, -1, element.c_str() ); 284 if ( lua_type( L->L, -1 ) != LUA_TTABLE ) 285 { 286 lua_pop( L->L, 1 ); 287 return; 288 } 289 nlua_toflags( L->L, -1, data, count ); 290 lua_pop( L->L, 1 ); 291 } 292 293 281 294 void lua::state::log_stack() 282 295 {
Note: See TracChangeset
for help on using the changeset viewer.