From ccd3872bf1218282731dac0ac04669f437c3876f Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Mon, 4 Jan 2016 11:44:23 +0100 Subject: [PATCH] Fix naming in ScriptingEnvironment --- include/extractor/scripting_environment.hpp | 4 ++-- src/extractor/extractor.cpp | 6 +++--- src/extractor/restriction_parser.cpp | 7 +++---- src/extractor/scripting_environment.cpp | 14 +++++++------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/extractor/scripting_environment.hpp b/include/extractor/scripting_environment.hpp index 33d672340..3b1ff785a 100644 --- a/include/extractor/scripting_environment.hpp +++ b/include/extractor/scripting_environment.hpp @@ -21,10 +21,10 @@ class ScriptingEnvironment ScriptingEnvironment() = delete; explicit ScriptingEnvironment(const std::string &file_name); - lua_State *get_lua_state(); + lua_State *GetLuaState(); private: - void init_lua_state(lua_State *lua_state); + void InitLuaState(lua_State *lua_state); std::mutex init_mutex; std::string file_name; tbb::enumerable_thread_specific> script_contexts; diff --git a/src/extractor/extractor.cpp b/src/extractor/extractor.cpp index 40ac02f3c..4038b3ec9 100644 --- a/src/extractor/extractor.cpp +++ b/src/extractor/extractor.cpp @@ -99,7 +99,7 @@ int extractor::run() SimpleLogger().Write() << "Parsing in progress.."; TIMER_START(parsing); - lua_State *segment_state = scripting_environment.get_lua_state(); + lua_State *segment_state = scripting_environment.GetLuaState(); if (lua_function_exists(segment_state, "source_function")) { @@ -135,7 +135,7 @@ int extractor::run() tbb::concurrent_vector> resulting_restrictions; // setup restriction parser - const RestrictionParser restriction_parser(scripting_environment.get_lua_state()); + const RestrictionParser restriction_parser(scripting_environment.GetLuaState()); while (const osmium::memory::Buffer buffer = reader.read()) { @@ -158,7 +158,7 @@ int extractor::run() { ExtractionNode result_node; ExtractionWay result_way; - lua_State *local_state = scripting_environment.get_lua_state(); + lua_State *local_state = scripting_environment.GetLuaState(); for (auto x = range.begin(), end = range.end(); x != end; ++x) { diff --git a/src/extractor/restriction_parser.cpp b/src/extractor/restriction_parser.cpp index 6aa5bd0c6..bb631894c 100644 --- a/src/extractor/restriction_parser.cpp +++ b/src/extractor/restriction_parser.cpp @@ -19,9 +19,8 @@ #include #include -namespace -{ -int lua_error_callback(lua_State *lua_state) +namespace { +int luaErrorCallback(lua_State *lua_state) { std::string error_msg = lua_tostring(lua_state, -1); throw osrm::exception("ERROR occurred in profile script:\n" + error_msg); @@ -60,7 +59,7 @@ void RestrictionParser::ReadRestrictionExceptions(lua_State *lua_state) { if (lua_function_exists(lua_state, "get_exceptions")) { - luabind::set_pcall_callback(&lua_error_callback); + luabind::set_pcall_callback(&luaErrorCallback); // get list of turn restriction exceptions luabind::call_function(lua_state, "get_exceptions", boost::ref(restriction_exceptions)); diff --git a/src/extractor/scripting_environment.cpp b/src/extractor/scripting_environment.cpp index 14198d8ae..f4fae0da3 100644 --- a/src/extractor/scripting_environment.cpp +++ b/src/extractor/scripting_environment.cpp @@ -26,10 +26,10 @@ auto get_value_by_key(T const &object, const char *key) -> decltype(object.get_v return object.get_value_by_key(key, ""); } -int lua_error_callback(lua_State *L) // This is so I can use my own function as an -// exception handler, pcall_log() +// Error handler +int luaErrorCallback(lua_State *state) { - std::string error_msg = lua_tostring(L, -1); + std::string error_msg = lua_tostring(state, -1); std::ostringstream error_stream; error_stream << error_msg; throw osrm::exception("ERROR occurred in profile script:\n" + error_stream.str()); @@ -41,7 +41,7 @@ ScriptingEnvironment::ScriptingEnvironment(const std::string &file_name) : file_ SimpleLogger().Write() << "Using script " << file_name; } -void ScriptingEnvironment::init_lua_state(lua_State *lua_state) +void ScriptingEnvironment::InitLuaState(lua_State *lua_state) { typedef double (osmium::Location::*location_member_ptr_type)() const; @@ -126,7 +126,7 @@ void ScriptingEnvironment::init_lua_state(lua_State *lua_state) } } -lua_State *ScriptingEnvironment::get_lua_state() +lua_State *ScriptingEnvironment::GetLuaState() { std::lock_guard lock(init_mutex); bool initialized = false; @@ -135,9 +135,9 @@ lua_State *ScriptingEnvironment::get_lua_state() { std::shared_ptr state(luaL_newstate(), lua_close); ref = state; - init_lua_state(ref.get()); + InitLuaState(ref.get()); } - luabind::set_pcall_callback(&lua_error_callback); + luabind::set_pcall_callback(&luaErrorCallback); return ref.get(); }