Changeset 187 for trunk/src/object.cc


Ignore:
Timestamp:
08/03/13 12:07:12 (12 years ago)
Author:
epyon
Message:
  • object - lua registration will now be manual, with an option to be separate from the type system
  • lua/state - explicit object registration
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/object.cc

    r120 r187  
    1616
    1717object::object()
    18         : m_root( nullptr ), m_id(), m_name(), m_uid(0), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
     18        : m_root( nullptr ), m_id(), m_name(), m_uid(0), m_lua_index(lua::ref_none), m_parent( nullptr ), m_children(), m_child_count(0)
    1919{
    2020}
    2121
    2222object::object( root* aroot, const string& aid )
    23         : m_root( aroot ), m_id(aid), m_name(), m_uid( 0 ), m_lua_index(-2), m_parent( nullptr ), m_children(), m_child_count(0)
     23        : m_root( aroot ), m_id(aid), m_name(), m_uid( 0 ), m_lua_index(lua::ref_none), m_parent( nullptr ), m_children(), m_child_count(0)
    2424{
    2525        if ( m_root )
    2626        {
    2727                uid_store*  store = get_root()->get_uid_store();
    28                 lua::state* state = get_root()->get_lua_state();
    2928                if (store)
    3029                {
    3130                        m_uid = store->insert( this );
    32                 }
    33                 if (state)
    34                 {
    35                         m_lua_index = state->register_object( this );
    3631                }
    3732        }
     
    195190        db->create_type<object>("object").fields(fields);
    196191}
     192
     193void nv::object::register_with_lua( const char* lua_name /*= nullptr*/ )
     194{
     195        lua::state* state = get_root()->get_lua_state();
     196        if (state)
     197        {
     198                if ( lua_name != nullptr )
     199                {
     200                        m_lua_index = state->register_object( this, lua_name );
     201                }
     202                else
     203                {
     204                        m_lua_index = state->register_object( this );
     205                }
     206        }
     207}
Note: See TracChangeset for help on using the changeset viewer.