Changeset 74 for trunk/src/lua/lua_state.cc
- Timestamp:
- 06/01/13 17:07:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r51 r74 24 24 } 25 25 26 lua::state::state( bool is_main /*= false*/ ) 27 { 26 lua::state::state( bool load_libs /*= false*/ ) 27 { 28 load_lua_library(); 28 29 m_owner = true; 29 30 L = luaL_newstate( ); … … 33 34 lua_call(L, 1, 0); 34 35 35 if (is_main) 36 { 37 NV_ASSERT( this == get(), "lua_state : another main state created!" ); 36 if ( load_libs ) 37 { 38 38 stack_guard guard( this ); 39 luaopen_base( L ); 40 luaopen_string( L ); 41 luaopen_table( L ); 42 luaopen_math( L ); 43 } 44 45 NV_LOG( nv::LOG_TRACE, is_main ? "Main Lua state created" : "Secondary Lua state created"); 39 static const luaL_Reg lualibs[] = 40 { 41 { "string", luaopen_string }, 42 { "table", luaopen_table }, 43 { "math", luaopen_math }, 44 { NULL, NULL} 45 }; 46 const luaL_Reg *lib = lualibs; 47 for(; lib->func != NULL; lib++) 48 { 49 lib->func( L ); 50 } 51 } 52 53 NV_LOG( nv::LOG_TRACE, "Lua state created" ); 46 54 } 47 55 … … 121 129 } 122 130 123 lua::state* lua::state::get()124 {125 static lua::state main_state(true);126 return &main_state;127 }128 129 131 bool lua::state::push( const std::string& path, bool global ) 130 132 { … … 275 277 for ( int i = 0; i < top; ++i ) 276 278 { 277 NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, i+1) << " = " << nlua_typecontent(L, i+1) );279 NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, lua_type(L, i+1) ) << " = " << nlua_typecontent(L, i+1) ); 278 280 } 279 281 }
Note: See TracChangeset
for help on using the changeset viewer.