Changeset 265 for trunk/src/lua/lua_state.cc
- Timestamp:
- 06/19/14 02:22:56 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r263 r265 328 328 } 329 329 330 lua::ref erencelua::state::register_object( void* o, const char* lua_name )331 { 332 if ( o == nullptr ) return ref_none;330 lua::ref lua::state::register_object( void* o, const char* lua_name ) 331 { 332 if ( o == nullptr ) return lua::ref( lua::ref::none ); 333 333 stack_guard guard( this ); 334 334 lua_getglobal( m_state, lua_name ); … … 338 338 } 339 339 deep_pointer_copy( -1, o ); 340 return lua L_ref( m_state, LUA_REGISTRYINDEX);341 } 342 343 lua::ref erencelua::state::register_proto( const char* id, const char* storage )340 return lua::ref( luaL_ref( m_state, LUA_REGISTRYINDEX ) ); 341 } 342 343 lua::ref lua::state::register_proto( const char* id, const char* storage ) 344 344 { 345 345 stack_guard guard( this ); … … 354 354 NV_THROW( runtime_error, std::string( id ) + " not found in " + std::string( storage ) + " storage!" ); 355 355 } 356 return lua L_ref( m_state, LUA_REGISTRYINDEX);356 return lua::ref( luaL_ref( m_state, LUA_REGISTRYINDEX ) ); 357 357 } 358 358 … … 369 369 } 370 370 371 void lua::state::unregister_object( ref erenceobject_index )372 { 373 if ( object_index == ref_nil) return;371 void lua::state::unregister_object( ref object_index ) 372 { 373 if ( !object_index.is_valid() ) return; 374 374 stack_guard guard( this ); 375 lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index );375 lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() ); 376 376 lua_pushstring( m_state, "__ptr" ); 377 377 lua_pushboolean( m_state, false ); 378 378 lua_rawset( m_state, -3 ); 379 379 lua_pop( m_state, 1 ); 380 luaL_unref( m_state, LUA_REGISTRYINDEX, object_index );380 luaL_unref( m_state, LUA_REGISTRYINDEX, object_index.get() ); 381 381 } 382 382 … … 419 419 } 420 420 421 void nv::lua::state::store_metadata( ref erenceobject_index, const std::string& metaname, void* pointer )422 { 423 if ( object_index == ref_nil) return;424 lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index );421 void nv::lua::state::store_metadata( ref object_index, const std::string& metaname, void* pointer ) 422 { 423 if ( !object_index.is_valid() ) return; 424 lua_rawgeti( m_state, LUA_REGISTRYINDEX, object_index.get() ); 425 425 lua_pushstring( m_state, metaname.c_str() ); 426 426 lua_pushlightuserdata( m_state, pointer );
Note: See TracChangeset
for help on using the changeset viewer.