Replace custom types with standard ones (#212)

Replace custom types with standard ones
This commit is contained in:
Michał Janiszewski
2019-03-26 22:30:46 +01:00
committed by Daniel Belcher
parent ef3f5e9cbb
commit 7a48f66807
32 changed files with 478 additions and 396 deletions

View File

@@ -22,6 +22,7 @@
#include "RadixType.h"
#include "History.h" // for History Collector
#include "CalcInput.h"
#include "CalcUtils.h"
#include "ICalcDisplay.h"
#include "Rational.h"
#include "RationalMath.h"
@@ -52,8 +53,8 @@ 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 DisplayError (DWORD nError);
void ProcessCommand(OpCode wID);
void DisplayError (uint32_t nError);
std::unique_ptr<CalcEngine::Rational> PersistedMemObject();
void PersistedMemObject(CalcEngine::Rational const& memObject);
bool FInErrorState() { return m_bError; }
@@ -116,7 +117,7 @@ private:
int m_nLastCom; // Last command entered.
ANGLE_TYPE m_angletype; // Current Angle type when in dec mode. one of deg, rad or grad
NUM_WIDTH m_numwidth; // one of qword, dword, word or byte mode.
LONG m_dwWordBitWidth; // # of bits in currently selected word size
int32_t m_dwWordBitWidth; // # of bits in currently selected word size
CHistoryCollector m_HistoryCollector; // Accumulator of each line of history as various commands are processed
@@ -127,8 +128,8 @@ private:
wchar_t m_groupSeparator;
private:
void ProcessCommandWorker(WPARAM wParam);
void HandleErrorCommand(WPARAM idc);
void ProcessCommandWorker(OpCode wParam);
void HandleErrorCommand(OpCode idc);
void HandleMaxDigitsReached();
void DisplayNum(void);
int IsNumberInvalid(const std::wstring& numberString, int iMaxExp, int iMaxMantissa, uint32_t radix) const;
@@ -136,13 +137,13 @@ private:
void SetPrimaryDisplay(const std::wstring& szText, bool isError = false);
void ClearTemporaryValues();
CalcEngine::Rational TruncateNumForIntMath(CalcEngine::Rational const& rat);
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, DWORD op);
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
void SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwidth);
LONG DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth);
int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth);
uint32_t NRadixFromRadixType( RADIX_TYPE radixtype);
bool TryToggleBit(CalcEngine::Rational& rat, DWORD wbitno);
bool TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno);
void CheckAndAddLastBinOpToHistory(bool addToHistory = true);
int IdcSetAngleTypeDecMode(int idc);

View File

@@ -47,7 +47,7 @@ namespace CalcEngine
void Clear();
bool TryToggleSign(bool isIntegerMode, std::wstring_view maxNumStr);
bool TryAddDigit(unsigned int value, uint32_t radix, bool isIntegerMode, std::wstring_view maxNumStr, long wordBitWidth, int maxDigits);
bool TryAddDigit(unsigned int value, uint32_t radix, bool isIntegerMode, std::wstring_view maxNumStr, int32_t wordBitWidth, int maxDigits);
bool TryAddDecimalPt();
bool HasDecimalPt();
bool TryBeginExponent();

View File

@@ -3,11 +3,13 @@
#pragma once
bool IsOpInRange(WPARAM op, uint32_t x, uint32_t y);
bool IsBinOpCode(WPARAM opCode);
using OpCode = uintptr_t;
bool IsOpInRange(OpCode op, uint32_t x, uint32_t y);
bool IsBinOpCode(OpCode 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(OpCode opCode);
bool IsDigitOpCode(OpCode opCode);
bool IsGuiSettingOpCode(OpCode opCode);