Last change
on this file since 215 was
215,
checked in by epyon, 12 years ago
|
- root - no longer holds a type_database
- lua - lua::state has it's own type_database
- lua - convinience function for registering enums
- cleanup of clang errors and warnings
|
File size:
830 bytes
|
Rev | Line | |
---|
[209] | 1 | // Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of NV Libraries.
|
---|
| 5 | // For conditions of distribution and use, see copyright notice in nv.hh
|
---|
| 6 |
|
---|
| 7 | #include "nv/lua/lua_flags.hh"
|
---|
| 8 |
|
---|
| 9 | #include "nv/lua/lua_raw.hh"
|
---|
| 10 | #include "nv/string.hh"
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | void nv::lua::detail::read_flags( lua_State* L, int index, uint8* data, uint32 count )
|
---|
| 14 | {
|
---|
| 15 | nlua_toflags( L, index, data, count );
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | void nv::lua::detail::push_flags( lua_State* L, uint8* data, uint32 count )
|
---|
| 19 | {
|
---|
| 20 | // TODO : this can be optimized
|
---|
| 21 | lua_createtable( L, 0, 0 );
|
---|
[215] | 22 | for ( int c = 0; c < static_cast< int >( count ); ++c )
|
---|
[209] | 23 | {
|
---|
[215] | 24 | int idx = c / 8;
|
---|
| 25 | int pos = c % 8;
|
---|
[209] | 26 | if ( ( data[ idx ] & ( 1 << static_cast< uint8 >( pos ) ) ) != 0 )
|
---|
| 27 | {
|
---|
| 28 | lua_pushboolean( L, true );
|
---|
| 29 | lua_rawseti( L, -2, c );
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.