Replace WPARAM -> uintptr_t

This commit is contained in:
Michał Janiszewski 2019-03-08 22:03:46 +01:00
commit 6ac7677878
5 changed files with 33 additions and 33 deletions

View file

@ -5,24 +5,24 @@
#include "Header Files/CalcEngine.h"
#include "Header Files/CalcUtils.h"
bool IsOpInRange(WPARAM op, uint32_t x, uint32_t y)
bool IsOpInRange(uintptr_t op, uint32_t x, uint32_t y)
{
return ((op >= x) && (op <= y));
}
bool IsBinOpCode(WPARAM opCode)
bool IsBinOpCode(uintptr_t opCode)
{
return IsOpInRange(opCode, IDC_AND, IDC_PWR);
}
// WARNING: IDC_SIGN is a special unary op but still this doesn't catch this. Caller has to be aware
// of it and catch it themselves or not needing this
bool IsUnaryOpCode(WPARAM opCode)
bool IsUnaryOpCode(uintptr_t opCode)
{
return IsOpInRange(opCode, IDC_UNARYFIRST, IDC_UNARYLAST);
}
bool IsDigitOpCode(WPARAM opCode)
bool IsDigitOpCode(uintptr_t opCode)
{
return IsOpInRange(opCode, IDC_0, IDC_F);
}
@ -32,7 +32,7 @@ bool IsDigitOpCode(WPARAM opCode)
// so we abstract this as a separate routine. Note: There is another side to this. Some commands are not
// gui mode setting to begin with, but once it is discovered it is invalid and we want to behave as though it
// was never inout, we need to revert the state changes made as a result of this test
bool IsGuiSettingOpCode(WPARAM opCode)
bool IsGuiSettingOpCode(uintptr_t opCode)
{
if (IsOpInRange(opCode, IDM_HEX, IDM_BIN) ||
IsOpInRange(opCode, IDM_QWORD, IDM_BYTE) ||

View file

@ -56,7 +56,7 @@ namespace {
//
// When it is discovered by the state machine that at this point the input is not valid (eg. "1+)"), we want to proceed as though this input never
// occurred and may be some feedback to user like Beep. The rest of input can then continue by just ignoring this command.
void CCalcEngine::HandleErrorCommand(WPARAM idc)
void CCalcEngine::HandleErrorCommand(uintptr_t idc)
{
if (!IsGuiSettingOpCode(idc))
{
@ -83,7 +83,7 @@ void CCalcEngine::ClearTemporaryValues()
m_bError = false;
}
void CCalcEngine::ProcessCommand(WPARAM wParam)
void CCalcEngine::ProcessCommand(uintptr_t wParam)
{
if (wParam == IDC_SET_RESULT)
{
@ -94,7 +94,7 @@ void CCalcEngine::ProcessCommand(WPARAM wParam)
ProcessCommandWorker(wParam);
}
void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
void CCalcEngine::ProcessCommandWorker(uintptr_t wParam)
{
int nx, ni;

View file

@ -212,7 +212,7 @@ namespace CalculationManager
/// <summary>
/// Send command to the Calc Engine
/// Cast Command Enum to WPARAM.
/// Cast Command Enum to uintptr_t.
/// Handle special commands such as mode change and combination of two commands.
/// </summary>
/// <param name="command">Enum Command</command>
@ -235,7 +235,7 @@ namespace CalculationManager
this->SetProgrammerMode();
break;
default:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(command));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(command));
}
m_savedCommands.clear(); // Clear the previous command history
@ -263,38 +263,38 @@ namespace CalculationManager
switch (command)
{
case Command::CommandASIN:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandSIN));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandSIN));
break;
case Command::CommandACOS:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandCOS));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandCOS));
break;
case Command::CommandATAN:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandTAN));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandTAN));
break;
case Command::CommandPOWE:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandLN));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandLN));
break;
case Command::CommandASINH:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandSINH));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandSINH));
break;
case Command::CommandACOSH:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandCOSH));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandCOSH));
break;
case Command::CommandATANH:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(Command::CommandTANH));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandINV));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(Command::CommandTANH));
break;
case Command::CommandFE:
m_isExponentialFormat = !m_isExponentialFormat;
[[fallthrough]];
default:
m_currentCalculatorEngine->ProcessCommand(static_cast<WPARAM>(command));
m_currentCalculatorEngine->ProcessCommand(static_cast<uintptr_t>(command));
break;
}
}

View file

@ -52,7 +52,7 @@ namespace CalculatorUnitTests
class CCalcEngine {
public:
CCalcEngine(bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider, __in_opt ICalcDisplay *pCalcDisplay, __in_opt std::shared_ptr<IHistoryDisplay> pHistoryDisplay);
void ProcessCommand(WPARAM wID);
void ProcessCommand(uintptr_t wID);
void DisplayError (uint32_t nError);
std::unique_ptr<CalcEngine::Rational> PersistedMemObject();
void PersistedMemObject(CalcEngine::Rational const& memObject);
@ -127,8 +127,8 @@ private:
wchar_t m_groupSeparator;
private:
void ProcessCommandWorker(WPARAM wParam);
void HandleErrorCommand(WPARAM idc);
void ProcessCommandWorker(uintptr_t wParam);
void HandleErrorCommand(uintptr_t idc);
void HandleMaxDigitsReached();
void DisplayNum(void);
int IsNumberInvalid(const std::wstring& numberString, int iMaxExp, int iMaxMantissa, uint32_t radix) const;

View file

@ -3,11 +3,11 @@
#pragma once
bool IsOpInRange(WPARAM op, uint32_t x, uint32_t y);
bool IsBinOpCode(WPARAM opCode);
bool IsOpInRange(uintptr_t op, uint32_t x, uint32_t y);
bool IsBinOpCode(uintptr_t opCode);
// WARNING: IDC_SIGN is a special unary op but still this doesn't catch this. Caller has to be aware
// of it and catch it themselves or not needing this
bool IsUnaryOpCode(WPARAM opCode);
bool IsDigitOpCode(WPARAM opCode);
bool IsGuiSettingOpCode(WPARAM opCode);
bool IsUnaryOpCode(uintptr_t opCode);
bool IsDigitOpCode(uintptr_t opCode);
bool IsGuiSettingOpCode(uintptr_t opCode);