Changeset 187 for trunk/src/lua/lua_state.cc
- Timestamp:
- 08/03/13 12:07:12 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r185 r187 303 303 } 304 304 305 lua::reference lua::state::register_object( object * o, const char* lua_name ) 306 { 307 if ( o == nullptr ) return ref_none; 308 stack_guard guard( this ); 309 lua_getglobal( L, lua_name ); 310 if ( lua_isnil( L, -1 ) ) 311 { 312 NV_THROW( runtime_error, std::string( lua_name ) + " type not registered!" ); 313 } 314 deep_pointer_copy( -1, o ); 315 return luaL_ref( L, LUA_REGISTRYINDEX ); 316 } 317 305 318 lua::reference lua::state::register_object( object * o ) 306 319 { 307 if ( !o) return ref_none;320 if ( o == nullptr ) return ref_none; 308 321 type_database *db = o->get_root()->get_type_database(); 309 if (!db) return ref_none; 310 type_entry* t = db->get_type(typeid(o)); 311 if (!t) return ref_none; 312 stack_guard guard( this ); 313 lua_getglobal( L, t->name.c_str() ); 314 if ( lua_isnil( L, -1 ) ) 315 { 316 NV_THROW( runtime_error, std::string( t->name ) + " type not registered!" ); 317 } 318 deep_pointer_copy( -1, o ); 319 return luaL_ref( L, LUA_REGISTRYINDEX ); 322 if ( db == nullptr ) return ref_none; 323 type_entry* t = db->get_type(typeid(*o)); 324 if ( t == nullptr ) return ref_none; 325 return register_object( o, t->name.c_str() ); 320 326 } 321 327 … … 403 409 if ( !p.resolve( L, global ) ) 404 410 { 405 lua_pop( L, 1 );406 411 NV_LOG( LOG_ERROR, "Lua error : not a valid path - " + p.to_string() ); 407 412 return false; … … 416 421 return true; 417 422 } 423
Note: See TracChangeset
for help on using the changeset viewer.