From fc6017c0dd6da05a68fe442b8e03a0e34d47abd7 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 7 May 2014 11:38:11 +0200 Subject: [PATCH] reformat LuaUtil.h --- Util/LuaUtil.h | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/Util/LuaUtil.h b/Util/LuaUtil.h index d7891db55..dee20ee7b 100644 --- a/Util/LuaUtil.h +++ b/Util/LuaUtil.h @@ -25,13 +25,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LUAUTIL_H_ -#define LUAUTIL_H_ +#ifndef LUA_UTIL_H +#define LUA_UTIL_H extern "C" { - #include - #include - #include +#include +#include +#include } #include @@ -39,26 +39,27 @@ extern "C" { #include #include -template -void LUA_print(T number) { - std::cout << "[LUA] " << number << std::endl; -} +template void LUA_print(T output) { std::cout << "[LUA] " << output << std::endl; } // Check if the lua function is defined -inline bool lua_function_exists(lua_State* lua_state, const char* name) { - luabind::object g = luabind::globals(lua_state); - luabind::object func = g[name]; - return func && (luabind::type(func) == LUA_TFUNCTION); +inline bool lua_function_exists(lua_State *lua_state, const char *name) +{ + luabind::object globals_table = luabind::globals(lua_state); + luabind::object lua_function = globals_table[name]; + return lua_function && (luabind::type(lua_function) == LUA_TFUNCTION); } -// Add the folder contain the script to the lua load path, so script can easily require() other lua scripts inside that folder, or subfolders. +// Add the folder contain the script to the lua load path, so script can easily require() other lua +// scripts inside that folder, or subfolders. // See http://lua-users.org/wiki/PackagePath for details on the package.path syntax. -inline void luaAddScriptFolderToLoadPath(lua_State* myLuaState, const char* fileName) { - const boost::filesystem::path profilePath( fileName ); - std::string folder = profilePath.parent_path().string(); - //TODO: This code is most probably not Windows safe since it uses UNIX'ish path delimiters - const std::string luaCode = "package.path = \"" + folder + "/?.lua;profiles/?.lua;\" .. package.path"; - luaL_dostring( myLuaState, luaCode.c_str() ); +inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_name) +{ + const boost::filesystem::path profile_path(file_name); + std::string folder = profile_path.parent_path().string(); + // TODO: This code is most probably not Windows safe since it uses UNIX'ish path delimiters + const std::string lua_code = + "package.path = \"" + folder + "/?.lua;profiles/?.lua;\" .. package.path"; + luaL_dostring(lua_state, lua_code.c_str()); } -#endif /* LUAUTIL_H_ */ +#endif // LUA_UTIL_H