void CScriptEngine::init() { #ifdef USE_LUA_STUDIO bool lua_studio_connected = !!m_lua_studio_world; if (lua_studio_connected) m_lua_studio_world->remove (lua()); #endif // #ifdef USE_LUA_STUDIO CScriptStorage::reinit(); #ifdef USE_LUA_STUDIO if (m_lua_studio_world || strstr(Core.Params, "-lua_studio")) { if (!lua_studio_connected) try_connect_to_debugger (); else { #ifdef USE_LUAJIT_ONE jit_command (lua(), "debug=2"); jit_command (lua(), "off"); #else luaJIT_setmode(lua(), 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF); #endif m_lua_studio_world->add (lua()); } } #endif // #ifdef USE_LUA_STUDIO luabind::open(lua()); setup_callbacks(); export_classes(lua()); setup_auto_load(); #ifdef DEBUG m_stack_is_ready = true; #endif #ifndef USE_LUA_STUDIO # ifdef DEBUG # if defined(USE_DEBUGGER) && !defined(USE_LUA_STUDIO) if( !debugger() || !debugger()->Active() ) # endif // #if defined(USE_DEBUGGER) && !defined(USE_LUA_STUDIO) lua_sethook (lua(),lua_hook_call, LUA_MASKLINE|LUA_MASKCALL|LUA_MASKRET, 0); # endif // #ifdef DEBUG #endif // #ifndef USE_LUA_STUDIO // lua_sethook (lua(), lua_hook_call, LUA_MASKLINE|LUA_MASKCALL|LUA_MASKRET, 0); bool save = m_reload_modules; m_reload_modules = true; process_file_if_exists("_G", false); m_reload_modules = save; register_script_classes(); object_factory().register_script(); #ifdef XRGAME_EXPORTS load_common_scripts(); #endif m_stack_level = lua_gettop(lua()); }
static void initialize_lua_studio ( lua_State* state, cs::lua_studio::world*& world, lua_studio_engine*& engine) { engine = 0; world = 0; u32 const old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); s_script_debugger_handle = LoadLibrary(CS_LUA_STUDIO_BACKEND_FILE_NAME); SetErrorMode (old_error_mode); if (!s_script_debugger_handle) { Msg ("! cannot load %s dynamic library", CS_LUA_STUDIO_BACKEND_FILE_NAME); return; } R_ASSERT2 (s_script_debugger_handle, "can't load script debugger library"); s_create_world = (create_world_function_type) GetProcAddress( s_script_debugger_handle, "_cs_lua_studio_backend_create_world@12" ); R_ASSERT2 (s_create_world, "can't find function \"cs_lua_studio_backend_create_world\""); s_destroy_world = (destroy_world_function_type) GetProcAddress( s_script_debugger_handle, "_cs_lua_studio_backend_destroy_world@4" ); R_ASSERT2 (s_destroy_world, "can't find function \"cs_lua_studio_backend_destroy_world\" in the library"); engine = xr_new<lua_studio_engine>(); world = s_create_world( *engine, false, false ); VERIFY (world); s_old_log_callback = SetLogCB(&log_callback); #ifdef USE_LUAJIT_ONE jit_command (state, "debug=2"); jit_command (state, "off"); #else luaJIT_setmode(lua(), 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF); #endif world->add (state); }
static void initialize_lua_studio ( lua_State* state, cs::lua_debugger::world*& world, lua_studio_engine*& engine) { engine = 0; world = 0; u32 const old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); s_script_debugger_handle = LoadLibrary(CS_LUA_DEBUGGER_FILE_NAME); SetErrorMode (old_error_mode); if (!s_script_debugger_handle) { Msg ("! cannot load %s dynamic library", CS_LUA_DEBUGGER_FILE_NAME); return; } R_ASSERT2 (s_script_debugger_handle, "can't load script debugger library"); s_create_world = (create_world_function_type) GetProcAddress( s_script_debugger_handle, "_cs_script_debugger_create_world@4" ); R_ASSERT2 (s_create_world, "can't find function \"create_world\""); s_destroy_world = (destroy_world_function_type) GetProcAddress( s_script_debugger_handle, "_cs_script_debugger_destroy_world@4" ); R_ASSERT2 (s_destroy_world, "can't find function \"destroy_world\" in the library"); engine = new lua_studio_engine(); world = s_create_world(*engine); VERIFY (world); s_old_log_callback = SetLogCB(&log_callback); jit_command (state, "debug=2"); jit_command (state, "off"); world->add (state); }