- Timestamp:
- 09/10/13 18:11:39 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r216 r217 8 8 9 9 #include "nv/lua/lua_raw.hh" 10 #include "nv/lua/lua_nova.hh" 10 11 #include "nv/logging.hh" 11 12 #include "nv/string.hh" … … 235 236 lib->func( m_state ); 236 237 } 238 register_nova( this ); 237 239 } 238 240 … … 337 339 } 338 340 deep_pointer_copy( -1, o ); 341 return luaL_ref( m_state, LUA_REGISTRYINDEX ); 342 } 343 344 lua::reference lua::state::register_proto( object * o, const char* storage ) 345 { 346 stack_guard guard( this ); 347 lua_getglobal( m_state, storage ); 348 if ( lua_isnil( m_state, -1 ) ) 349 { 350 NV_THROW( runtime_error, std::string( storage ) + " storage not registered!" ); 351 } 352 lua_getfield( m_state, -1, o->get_id().c_str() ); 353 if ( lua_isnil( m_state, -1 ) ) 354 { 355 NV_THROW( runtime_error, std::string( o->get_id() ) + " not found in " + std::string( storage ) + " storage!" ); 356 } 339 357 return luaL_ref( m_state, LUA_REGISTRYINDEX ); 340 358 } -
trunk/src/object.cc
r187 r217 16 16 17 17 object::object() 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) 18 : m_root( nullptr ) 19 , m_id() 20 , m_name() 21 , m_uid(0) 22 , m_lua_index(lua::ref_none) 23 , m_lua_proto_index(lua::ref_none) 24 , m_parent( nullptr ) 25 , m_children() 26 , m_child_count(0) 19 27 { 20 28 } 21 29 22 30 object::object( root* aroot, const string& aid ) 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) 31 : m_root( aroot ) 32 , m_id( aid ) 33 , m_name() 34 , m_uid(0) 35 , m_lua_index(lua::ref_none) 36 , m_lua_proto_index(lua::ref_none) 37 , m_parent( nullptr ) 38 , m_children() 39 , m_child_count(0) 24 40 { 25 41 if ( m_root ) … … 191 207 } 192 208 193 void nv::object::register_with_lua( const char* lua_name /*= nullptr*/)209 void nv::object::register_with_lua( const char* lua_name, const char* storage ) 194 210 { 195 211 lua::state* state = get_root()->get_lua_state(); … … 198 214 if ( lua_name != nullptr ) 199 215 { 200 m_lua_index = state->register_object( this, lua_name );201 } 202 else203 { 204 m_lua_ index = state->register_object( this);205 } 206 } 207 } 216 m_lua_index = state->register_object( this, lua_name ); 217 } 218 if ( storage != nullptr ) 219 { 220 m_lua_proto_index = state->register_proto( this, storage ); 221 } 222 } 223 }
Note: See TracChangeset
for help on using the changeset viewer.