- Timestamp:
- 07/15/13 20:13:27 (12 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.