From 15e7e8d0aa628329588171cd9514ee6a689d0f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Sat, 9 Mar 2019 00:05:36 +0100 Subject: [PATCH] Replace HRESULT -> ResultCode(int32_t) --- src/CalcManager/CEngine/History.cpp | 2 +- src/CalcManager/CalculatorVector.h | 36 ++++++++++++++--------------- src/CalcManager/Ratpack/CalcErr.h | 4 +++- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/CalcManager/CEngine/History.cpp b/src/CalcManager/CEngine/History.cpp index e5bb746b..ca276a41 100644 --- a/src/CalcManager/CEngine/History.cpp +++ b/src/CalcManager/CEngine/History.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace CalcEngine; namespace { - void IFT(HRESULT hr) + void IFT(ResultCode hr) { if (FAILED(hr)) { diff --git a/src/CalcManager/CalculatorVector.h b/src/CalcManager/CalculatorVector.h index 7fad7e7d..eb313336 100644 --- a/src/CalcManager/CalculatorVector.h +++ b/src/CalcManager/CalculatorVector.h @@ -7,9 +7,9 @@ template class CalculatorVector { public: - HRESULT GetAt(_In_opt_ unsigned int index, _Out_ TType *item) + ResultCode GetAt(_In_opt_ unsigned int index, _Out_ TType *item) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; try { *item = m_vector.at(index); @@ -21,15 +21,15 @@ public: return hr; } - HRESULT GetSize(_Out_ unsigned int *size) + ResultCode GetSize(_Out_ unsigned int *size) { *size = static_cast(m_vector.size()); return S_OK; } - HRESULT SetAt(_In_ unsigned int index, _In_opt_ TType item) + ResultCode SetAt(_In_ unsigned int index, _In_opt_ TType item) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; try { m_vector[index] = item; @@ -41,9 +41,9 @@ public: return hr; } - HRESULT RemoveAt(_In_ unsigned int index) + ResultCode RemoveAt(_In_ unsigned int index) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; if (index < m_vector.size()) { m_vector.erase(m_vector.begin() + index); @@ -55,9 +55,9 @@ public: return hr; } - HRESULT InsertAt(_In_ unsigned int index, _In_ TType item) + ResultCode InsertAt(_In_ unsigned int index, _In_ TType item) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; try { auto iter = m_vector.begin() + index; @@ -70,9 +70,9 @@ public: return hr; } - HRESULT Truncate(_In_ unsigned int index) + ResultCode Truncate(_In_ unsigned int index) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; if (index < m_vector.size()) { auto startIter = m_vector.begin() + index; @@ -85,9 +85,9 @@ public: return hr; } - HRESULT Append(_In_opt_ TType item) + ResultCode Append(_In_opt_ TType item) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; try { m_vector.push_back(item); @@ -99,21 +99,21 @@ public: return hr; } - HRESULT RemoveAtEnd() + ResultCode RemoveAtEnd() { m_vector.erase(--(m_vector.end())); return S_OK; } - HRESULT Clear() + ResultCode Clear() { m_vector.clear(); return S_OK; } - HRESULT GetString(_Out_ std::wstring* expression) + ResultCode GetString(_Out_ std::wstring* expression) { - HRESULT hr = S_OK; + ResultCode hr = S_OK; unsigned int nTokens = 0; std::pair currentPair; hr = this->GetSize(&nTokens); @@ -144,7 +144,7 @@ public: return hr; } - HRESULT GetExpressionSuffix(_Out_ std::wstring* suffix) + ResultCode GetExpressionSuffix(_Out_ std::wstring* suffix) { *suffix = L" ="; return S_OK; diff --git a/src/CalcManager/Ratpack/CalcErr.h b/src/CalcManager/Ratpack/CalcErr.h index 30f5471a..80b7229c 100644 --- a/src/CalcManager/Ratpack/CalcErr.h +++ b/src/CalcManager/Ratpack/CalcErr.h @@ -24,7 +24,7 @@ // R - Reserved - not currently used for anything // // r - reserved portion of the facility code. Reserved for internal -// use. Used to indicate HRESULT values that are not status +// use. Used to indicate int32_t values that are not status // values, but are instead message ids for display strings. // // Facility - is the facility code @@ -34,6 +34,8 @@ // This format is based loosely on an OLE HRESULT and is compatible with the // SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro +typedef int32_t ResultCode; + // CALC_E_DIVIDEBYZERO // // The current operation would require a divide by zero to complete