Changeset 215 for trunk/src/lua


Ignore:
Timestamp:
09/09/13 21:14:19 (12 years ago)
Author:
epyon
Message:
  • 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
Location:
trunk/src/lua
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_flags.cc

    r209 r215  
    2020        // TODO : this can be optimized
    2121        lua_createtable( L, 0, 0 );
    22         for ( uint32 c = 0; c < count; ++c )
     22        for ( int c = 0; c < static_cast< int >( count ); ++c )
    2323        {
    24                 uint32 idx = c / 8;
    25                 uint32 pos = c % 8;
     24                int idx = c / 8;
     25                int pos = c % 8;
    2626                if ( ( data[ idx ] & ( 1 << static_cast< uint8 >( pos ) ) ) != 0 )
    2727                {
  • trunk/src/lua/lua_state.cc

    r213 r215  
    3232}
    3333
    34 lua::state::state( lua_State* state ) : state_wrapper( state, false )
    35 {
    36 
    37 }
    38 
    39 lua::state::state( bool load_libs /*= false*/ ) : state_wrapper( nullptr, true )
     34lua::state::state( lua_State* state ) : state_wrapper( state, false ), m_type_database( nullptr )
     35{
     36
     37}
     38
     39lua::state::state( bool load_libs /*= false*/ ) : state_wrapper( nullptr, true ), m_type_database( nullptr )
    4040{
    4141        load_lua_library();
     
    4949        if ( load_libs )
    5050        {
     51                m_type_database = new type_database();
    5152                stack_guard guard( this );
    5253                static const luaL_Reg lualibs[] =
     
    290291lua::reference lua::state::register_object( object * o )
    291292{
    292         if ( o == nullptr ) return ref_none;
    293         type_database *db = o->get_root()->get_type_database();
    294         if ( db == nullptr ) return ref_none;
    295         type_entry* t = db->get_type(typeid(*o));
     293        if ( o == nullptr || m_type_database == nullptr ) return ref_none;
     294        type_entry* t = m_type_database->get_type(typeid(*o));
    296295        if ( t == nullptr ) return ref_none;
    297296        return register_object( o, t->name.c_str() );
     
    359358}
    360359
    361 void lua::state::register_enum( type_database* db, const std::string& name, const std::string& prefix /*= std::string() */ )
    362 {
    363         type_entry* et = db->get_type( name );
     360void lua::state::register_enum_values( const std::string& name, const std::string& prefix /*= std::string() */ )
     361{
     362        type_entry* et = m_type_database->get_type( name );
    364363
    365364        for ( const auto& entry : et->enum_list )
     
    388387}
    389388
     389nv::lua::state::~state()
     390{
     391        if (m_type_database != nullptr )
     392        {
     393                delete m_type_database;
     394        }
     395}
     396
    390397bool nv::lua::state_wrapper::is_defined( const path& p, bool global )
    391398{
Note: See TracChangeset for help on using the changeset viewer.