This commit is contained in:
Birunthan Mohanathas
2013-01-27 12:14:37 +02:00
parent 654599d192
commit fdcd5a9757
12 changed files with 134 additions and 88 deletions

View File

@ -69,16 +69,19 @@ void LuaManager::ReportErrors(lua_State* L, const std::wstring& file)
}
std::wstring str(file, file.find_last_of(L'\\') + 1);
str += ConvertToWide(error);
str += StringUtil::Widen(error);
LogWithArgs(LOG_ERROR, L"Script: %s", str.c_str());
}
void LuaManager::PushWide(lua_State* L, const WCHAR* str)
{
lua_pushstring(L, ConvertToAscii(str).c_str());
const std::string tmpStr = StringUtil::Narrow(str);
lua_pushlstring(L, tmpStr.c_str(), tmpStr.length());
}
std::wstring LuaManager::ToWide(lua_State* L, int narg)
{
return ConvertToWide(lua_tostring(L, narg));
size_t strLen = 0;
const char* str = lua_tolstring(L, narg, &strLen);
return StringUtil::Widen(str, (int)strLen);
}

View File

@ -206,8 +206,9 @@ int LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std
}
else if (type == LUA_TSTRING)
{
const char* str = lua_tostring(L, -1);
strValue = ConvertToWide(str);
size_t strLen = 0;
const char* str = lua_tolstring(L, -1, &strLen);
strValue = StringUtil::Widen(str, (int)strLen);
numValue = strtod(str, NULL);
}

View File

@ -53,7 +53,7 @@ static int Print(lua_State* L)
lua_pop(L, 1);
}
Log(LOG_DEBUG, ConvertToWide(message.c_str()).c_str());
Log(LOG_DEBUG, StringUtil::Widen(message).c_str());
return 0;
}