Last change
on this file since 531 was
395,
checked in by epyon, 10 years ago
|
- bulk update
copyright update
include guards cleanup
core/common.hh -> common.hh
minor cleanups
|
File size:
827 bytes
|
Rev | Line | |
---|
[395] | 1 | // Copyright (C) 2012-2015 ChaosForge Ltd
|
---|
[209] | 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
[395] | 4 | // This file is part of Nova libraries.
|
---|
| 5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
[209] | 6 |
|
---|
| 7 | #include "nv/lua/lua_flags.hh"
|
---|
| 8 |
|
---|
| 9 | #include "nv/lua/lua_raw.hh"
|
---|
[368] | 10 | #include "nv/stl/string.hh"
|
---|
[209] | 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.