Last change
on this file since 319 was
319,
checked in by epyon, 11 years ago
|
- created core module and moved all free source files there
- took the opportunity to update all copyright lines and minor cleanup
- minor fixes
- not all examples are up to date
|
File size:
818 bytes
|
Line | |
---|
1 | // Copyright (C) 2012-2014 ChaosForge Ltd
|
---|
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/core/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 );
|
---|
22 | for ( int c = 0; c < static_cast< int >( count ); ++c )
|
---|
23 | {
|
---|
24 | int idx = c / 8;
|
---|
25 | int pos = c % 8;
|
---|
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.