Cosmetics

This commit is contained in:
Birunthan Mohanathas 2013-08-06 22:03:20 +03:00
parent f8c386793a
commit bbb101cbd5
2 changed files with 7 additions and 7 deletions

View File

@ -24,7 +24,7 @@
int LuaManager::c_RefCount = 0; int LuaManager::c_RefCount = 0;
lua_State* LuaManager::c_State = 0; lua_State* LuaManager::c_State = 0;
bool LuaManager::s_UnicodeState = false; bool LuaManager::c_UnicodeState = false;
void LuaManager::Initialize() void LuaManager::Initialize()
{ {
@ -73,14 +73,14 @@ void LuaManager::ReportErrors(const std::wstring& file)
} }
std::wstring str(file, file.find_last_of(L'\\') + 1); std::wstring str(file, file.find_last_of(L'\\') + 1);
str += s_UnicodeState ? StringUtil::WidenUTF8(error) : StringUtil::Widen(error); str += c_UnicodeState ? StringUtil::WidenUTF8(error) : StringUtil::Widen(error);
LogErrorF(L"Script: %s", str.c_str()); LogErrorF(L"Script: %s", str.c_str());
} }
void LuaManager::PushWide(const WCHAR* str) void LuaManager::PushWide(const WCHAR* str)
{ {
lua_State* L = c_State; lua_State* L = c_State;
const std::string narrowStr = s_UnicodeState ? const std::string narrowStr = c_UnicodeState ?
StringUtil::NarrowUTF8(str) : StringUtil::Narrow(str); StringUtil::NarrowUTF8(str) : StringUtil::Narrow(str);
lua_pushlstring(L, narrowStr.c_str(), narrowStr.length()); lua_pushlstring(L, narrowStr.c_str(), narrowStr.length());
} }
@ -88,7 +88,7 @@ void LuaManager::PushWide(const WCHAR* str)
void LuaManager::PushWide(const std::wstring& str) void LuaManager::PushWide(const std::wstring& str)
{ {
lua_State* L = c_State; lua_State* L = c_State;
const std::string narrowStr = s_UnicodeState ? const std::string narrowStr = c_UnicodeState ?
StringUtil::NarrowUTF8(str) : StringUtil::Narrow(str); StringUtil::NarrowUTF8(str) : StringUtil::Narrow(str);
lua_pushlstring(L, narrowStr.c_str(), narrowStr.length()); lua_pushlstring(L, narrowStr.c_str(), narrowStr.length());
} }
@ -98,6 +98,6 @@ std::wstring LuaManager::ToWide(int narg)
lua_State* L = c_State; lua_State* L = c_State;
size_t strLen = 0; size_t strLen = 0;
const char* str = lua_tolstring(L, narg, &strLen); const char* str = lua_tolstring(L, narg, &strLen);
return s_UnicodeState ? return c_UnicodeState ?
StringUtil::WidenUTF8(str, (int)strLen) : StringUtil::Widen(str, (int)strLen); StringUtil::WidenUTF8(str, (int)strLen) : StringUtil::Widen(str, (int)strLen);
} }

View File

@ -32,7 +32,7 @@ public:
static void Initialize(); static void Initialize();
static void Finalize(); static void Finalize();
static lua_State* GetState(bool unicode) { s_UnicodeState = unicode; return c_State; } static lua_State* GetState(bool unicode) { c_UnicodeState = unicode; return c_State; }
static void ReportErrors(const std::wstring& file); static void ReportErrors(const std::wstring& file);
@ -53,7 +53,7 @@ private:
// If set true |true|, Lua strings converted to/from as if they were encoded in UTF-8. Otherwise // If set true |true|, Lua strings converted to/from as if they were encoded in UTF-8. Otherwise
// Lua strings are treated as if they are encoded in the default system encoding. // Lua strings are treated as if they are encoded in the default system encoding.
static bool s_UnicodeState; static bool c_UnicodeState;
}; };
#endif #endif