From ad2a986e88f6565c6a2ae8a199f4c0266e7ef163 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Fri, 9 Mar 2012 10:41:46 +0000 Subject: [PATCH] Cosmetics. --- Library/ConfigParser.cpp | 9 ++++----- Library/ConfigParser.h | 2 +- Library/MeterWindow.cpp | 4 ++-- Library/lua/glue/LuaMeasure.cpp | 18 ++++++------------ Library/lua/glue/LuaMeter.cpp | 4 +--- Library/lua/glue/LuaMeterWindow.cpp | 2 +- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index f08467c3..c6a80ad1 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -746,19 +746,18 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue) } // Returns true if the formula was read successfully, false for failure. -// Pass a pointer to a double. -bool CConfigParser::ParseFormula(const std::wstring& result, double* resultValue) +bool CConfigParser::ParseFormula(const std::wstring& formula, double* resultValue) { // Formulas must be surrounded by parenthesis - if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')') + if (!formula.empty() && formula.front() == L'(' && formula.back() == L')') { - const WCHAR* errMsg = MathParser::CheckedParse(result.c_str(), resultValue); + const WCHAR* errMsg = MathParser::CheckedParse(formula.c_str(), resultValue); if (errMsg != NULL) { std::wstring error = L"ParseFormula: "; error += errMsg; error += L": "; - error += result; + error += formula; Log(LOG_ERROR, error.c_str()); return false; } diff --git a/Library/ConfigParser.h b/Library/ConfigParser.h index 527ec24f..28262c42 100644 --- a/Library/ConfigParser.h +++ b/Library/ConfigParser.h @@ -79,7 +79,7 @@ public: RECT ReadRECT(LPCTSTR section, LPCTSTR key, const RECT& defValue); std::vector ReadFloats(LPCTSTR section, LPCTSTR key); - bool ParseFormula(const std::wstring& result, double* resultValue); + bool ParseFormula(const std::wstring& formula, double* resultValue); const std::wstring& GetFilename() { return m_Filename; } const std::list& GetSections() { return m_Sections; } diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 52b9b4d8..6e409e8e 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -839,8 +839,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const std::vector& ar int y = m_Parser.ParseFormula(args[1], &value) ? (int)value : _wtoi(args[1].c_str()); MoveWindow(x, y); - break; } + break; case BANG_ZPOS: SetWindowZPosition((ZPOSITION)_wtoi(args[0].c_str())); @@ -891,8 +891,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const std::vector& ar int y = m_Parser.ParseFormula(args[1], &value) ? (int)value : _wtoi(args[1].c_str()); MoveMeter(args[2], x, y); - break; } + break; case BANG_COMMANDMEASURE: { diff --git a/Library/lua/glue/LuaMeasure.cpp b/Library/lua/glue/LuaMeasure.cpp index e6529c11..8b427947 100644 --- a/Library/lua/glue/LuaMeasure.cpp +++ b/Library/lua/glue/LuaMeasure.cpp @@ -29,8 +29,7 @@ inline CMeasure* GetSelf(lua_State* L) static int GetName(lua_State* L) { CMeasure* self = GetSelf(L); - const WCHAR* val = (const WCHAR*)self->GetName(); - LuaManager::PushWide(L, val); + LuaManager::PushWide(L, self->GetName()); return 1; } @@ -93,8 +92,7 @@ static int Enable(lua_State* L) static int GetValue(lua_State* L) { CMeasure* self = GetSelf(L); - double val = (double)self->GetValue(); - lua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, self->GetValue()); return 1; } @@ -102,8 +100,7 @@ static int GetValue(lua_State* L) static int GetRelativeValue(lua_State* L) { CMeasure* self = GetSelf(L); - double val = (double)self->GetRelativeValue(); - lua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, self->GetRelativeValue()); return 1; } @@ -111,8 +108,7 @@ static int GetRelativeValue(lua_State* L) static int GetValueRange(lua_State* L) { CMeasure* self = GetSelf(L); - double val = (double)self->GetValueRange(); - lua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, self->GetValueRange()); return 1; } @@ -120,8 +116,7 @@ static int GetValueRange(lua_State* L) static int GetMinValue(lua_State* L) { CMeasure* self = GetSelf(L); - double val = (double)self->GetMinValue(); - lua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, self->GetMinValue()); return 1; } @@ -129,8 +124,7 @@ static int GetMinValue(lua_State* L) static int GetMaxValue(lua_State* L) { CMeasure* self = GetSelf(L); - double val = (double)self->GetMaxValue(); - lua_pushnumber(L, (lua_Number)val); + lua_pushnumber(L, self->GetMaxValue()); return 1; } diff --git a/Library/lua/glue/LuaMeter.cpp b/Library/lua/glue/LuaMeter.cpp index 4d566399..c5ada44b 100644 --- a/Library/lua/glue/LuaMeter.cpp +++ b/Library/lua/glue/LuaMeter.cpp @@ -29,8 +29,7 @@ inline CMeter* GetSelf(lua_State* L) static int GetName(lua_State* L) { CMeter* self = GetSelf(L); - const WCHAR* val = (const WCHAR*)self->GetName(); - LuaManager::PushWide(L, val); + LuaManager::PushWide(L, self->GetName()); return 1; } @@ -138,7 +137,6 @@ static int Show(lua_State* L) static int SetText(lua_State* L) { CMeter* self = GetSelf(L); - if (CMeterString* stringMeter = dynamic_cast(self)) { std::wstring str = LuaManager::ToWide(L, 2); diff --git a/Library/lua/glue/LuaMeterWindow.cpp b/Library/lua/glue/LuaMeterWindow.cpp index 4bb6ee39..1778b006 100644 --- a/Library/lua/glue/LuaMeterWindow.cpp +++ b/Library/lua/glue/LuaMeterWindow.cpp @@ -169,7 +169,7 @@ static int GetY(lua_State* L) static int MakePathAbsolute(lua_State* L) { - CMeterWindow* self = *(CMeterWindow**)lua_touserdata(L, 1); + CMeterWindow* self = GetSelf(L); std::wstring path = LuaManager::ToWide(L, 2); self->MakePathAbsolute(path); LuaManager::PushWide(L, path.c_str());