Clang-format most of the sources (#1467)

This commit is contained in:
Michał Janiszewski
2021-05-10 19:18:39 +02:00
committed by GitHub
parent f7d0118064
commit f30e9494ce
54 changed files with 826 additions and 896 deletions

View File

@@ -52,8 +52,8 @@ namespace CalcEngine
Rational::Rational(uint64_t ui)
{
uint32_t hi = (uint32_t) (((ui) >> 32) & 0xffffffff);
uint32_t lo = (uint32_t) ui;
uint32_t hi = (uint32_t)(((ui) >> 32) & 0xffffffff);
uint32_t lo = (uint32_t)ui;
Rational temp = (Rational{ hi } << 32) | lo;

View File

@@ -31,17 +31,12 @@ namespace
// 0 is returned. Higher the number, higher the precedence of the operator.
int NPrecedenceOfOp(int nopCode)
{
static uint16_t rgbPrec[] = {
0,0, IDC_OR,0, IDC_XOR,0,
IDC_AND,1, IDC_NAND,1, IDC_NOR,1,
IDC_ADD,2, IDC_SUB,2,
IDC_RSHF,3, IDC_LSHF,3, IDC_RSHFL,3,
IDC_MOD,3, IDC_DIV,3, IDC_MUL,3,
IDC_PWR,4, IDC_ROOT,4, IDC_LOGBASEY,4 };
static uint16_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_NAND, 1, IDC_NOR, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF, 3,
IDC_LSHF, 3, IDC_RSHFL, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4, IDC_LOGBASEY, 4 };
for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2)
{
if (nopCode == rgbPrec[iPrec])
if (nopCode == rgbPrec[iPrec])
{
return rgbPrec[iPrec + 1];
}
@@ -85,8 +80,7 @@ void CCalcEngine::ClearDisplay()
{
if (nullptr != m_pCalcDisplay)
{
m_pCalcDisplay->SetExpressionDisplay(
make_shared<vector<pair<wstring, int>>>(), make_shared<vector<shared_ptr<IExpressionCommand>>>());
m_pCalcDisplay->SetExpressionDisplay(make_shared<vector<pair<wstring, int>>>(), make_shared<vector<shared_ptr<IExpressionCommand>>>());
}
}
@@ -142,18 +136,10 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
// Toggle Record/Display mode if appropriate.
if (m_bRecord)
{
if (IsBinOpCode(wParam) ||
IsUnaryOpCode(wParam) ||
IsOpInRange(wParam, IDC_FE, IDC_MMINUS) ||
IsOpInRange(wParam, IDC_OPENP, IDC_CLOSEP) ||
IsOpInRange(wParam, IDM_HEX, IDM_BIN) ||
IsOpInRange(wParam, IDM_QWORD, IDM_BYTE) ||
IsOpInRange(wParam, IDM_DEG, IDM_GRAD) ||
IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITEND) ||
(IDC_INV == wParam) ||
(IDC_SIGN == wParam && 10 != m_radix) ||
(IDC_RAND == wParam) ||
(IDC_EULER == wParam))
if (IsBinOpCode(wParam) || IsUnaryOpCode(wParam) || IsOpInRange(wParam, IDC_FE, IDC_MMINUS) || IsOpInRange(wParam, IDC_OPENP, IDC_CLOSEP)
|| IsOpInRange(wParam, IDM_HEX, IDM_BIN) || IsOpInRange(wParam, IDM_QWORD, IDM_BYTE) || IsOpInRange(wParam, IDM_DEG, IDM_GRAD)
|| IsOpInRange(wParam, IDC_BINEDITSTART, IDC_BINEDITEND) || (IDC_INV == wParam) || (IDC_SIGN == wParam && 10 != m_radix) || (IDC_RAND == wParam)
|| (IDC_EULER == wParam))
{
m_bRecord = false;
m_currentVal = m_input.ToRational(m_radix, m_precision);
@@ -269,7 +255,6 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
DisplayNum();
if (!m_fPrecedence)
{
wstring groupedString = GroupDigitsPerRadix(m_numberString, m_radix);
m_HistoryCollector.CompleteEquation(groupedString);
m_HistoryCollector.AddOpndToHistory(m_numberString, m_currentVal);
@@ -360,13 +345,10 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
/* reset the m_bInv flag and indicators if it is set
and have been used */
if (m_bInv &&
((wParam == IDC_CHOP) || (wParam == IDC_SIN) || (wParam == IDC_COS) ||
(wParam == IDC_TAN) || (wParam == IDC_LN) || (wParam == IDC_DMS) ||
(wParam == IDC_DEGREES) || (wParam == IDC_SINH) || (wParam == IDC_COSH) ||
(wParam == IDC_TANH) || (wParam == IDC_SEC) || (wParam == IDC_CSC) ||
(wParam == IDC_COT) || (wParam == IDC_SECH) || (wParam == IDC_CSCH) ||
(wParam == IDC_COTH)))
if (m_bInv
&& ((wParam == IDC_CHOP) || (wParam == IDC_SIN) || (wParam == IDC_COS) || (wParam == IDC_TAN) || (wParam == IDC_LN) || (wParam == IDC_DMS)
|| (wParam == IDC_DEGREES) || (wParam == IDC_SINH) || (wParam == IDC_COSH) || (wParam == IDC_TANH) || (wParam == IDC_SEC) || (wParam == IDC_CSC)
|| (wParam == IDC_COT) || (wParam == IDC_SECH) || (wParam == IDC_CSCH) || (wParam == IDC_COTH)))
{
m_bInv = false;
}
@@ -928,8 +910,7 @@ struct FunctionNameElement
};
// Table for each unary operator
static const std::unordered_map<int, FunctionNameElement> operatorStringTable =
{
static const std::unordered_map<int, FunctionNameElement> operatorStringTable = {
{ IDC_CHOP, { L"", SIDS_FRAC } },
{ IDC_SIN, { SIDS_SIND, SIDS_ASIND, SIDS_SINR, SIDS_ASINR, SIDS_SING, SIDS_ASING } },

View File

@@ -55,7 +55,7 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
uint64_t w64Bits = result.ToUInt64_t();
uint64_t msb = (w64Bits >> (m_dwWordBitWidth - 1)) & 1;
w64Bits <<= 1; // LShift by 1
w64Bits <<= 1; // LShift by 1
if (op == IDC_ROL)
{
@@ -64,7 +64,7 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
else
{
w64Bits |= m_carryBit; // Set the carry bit as the LSB
m_carryBit = msb; // Store the msb as the next carry bit
m_carryBit = msb; // Store the msb as the next carry bit
}
result = w64Bits;
@@ -272,7 +272,7 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
break;
case IDC_FLOOR:
result = (Frac(rat) < 0) ? Integer(rat - 1 ) : Integer(rat);
result = (Frac(rat) < 0) ? Integer(rat - 1) : Integer(rat);
break;
case IDC_ABS:

View File

@@ -7,8 +7,8 @@
#include <vector>
#include "winerror_cross_platform.h"
#include "Ratpack/CalcErr.h"
#include <stdexcept> // for std::out_of_range
#include "sal_cross_platform.h" // for SAL
#include <stdexcept> // for std::out_of_range
#include "sal_cross_platform.h" // for SAL
template <typename TType>
class CalculatorVector
@@ -118,7 +118,6 @@ public:
ResultCode hr = this->GetSize(&nTokens);
if (SUCCEEDED(hr))
{
std::pair<std::wstring, int> currentPair;
for (unsigned int i = 0; i < nTokens; i++)
{

View File

@@ -162,7 +162,7 @@ namespace CalculationManager
CommandCOTH = 410,
CommandACOTH = 411,
CommandPOW2 = 412, // 2 ^ x
CommandPOW2 = 412, // 2 ^ x
CommandAbs = 413,
CommandFloor = 414,
CommandCeil = 415,

View File

@@ -137,44 +137,44 @@
#define IDC_INV 146
#define IDC_SET_RESULT 147
#define IDC_STRING_MAPPED_VALUES 400
#define IDC_UNARYEXTENDEDFIRST IDC_STRING_MAPPED_VALUES
#define IDC_SEC 400 // Secant
#define IDC_STRING_MAPPED_VALUES 400
#define IDC_UNARYEXTENDEDFIRST IDC_STRING_MAPPED_VALUES
#define IDC_SEC 400 // Secant
// 401 reserved for inverse
#define IDC_CSC 402 // Cosecant
#define IDC_CSC 402 // Cosecant
// 403 reserved for inverse
#define IDC_COT 404 // Cotangent
#define IDC_COT 404 // Cotangent
// 405 reserved for inverse
#define IDC_SECH 406 //Hyperbolic Secant
#define IDC_SECH 406 // Hyperbolic Secant
// 407 reserved for inverse
#define IDC_CSCH 408 //Hyperbolic Cosecant
#define IDC_CSCH 408 // Hyperbolic Cosecant
// 409 reserved for inverse
#define IDC_COTH 410 //Hyperbolic Cotangent
#define IDC_COTH 410 // Hyperbolic Cotangent
// 411 reserved for inverse
#define IDC_POW2 412 // 2 ^ x
#define IDC_ABS 413 // Absolute Value
#define IDC_FLOOR 414 // Floor
#define IDC_CEIL 415 // Ceiling
#define IDC_POW2 412 // 2 ^ x
#define IDC_ABS 413 // Absolute Value
#define IDC_FLOOR 414 // Floor
#define IDC_CEIL 415 // Ceiling
#define IDC_ROLC 416 // Rotate Left Circular
#define IDC_RORC 417 // Rotate Right Circular
#define IDC_ROLC 416 // Rotate Left Circular
#define IDC_RORC 417 // Rotate Right Circular
#define IDC_UNARYEXTENDEDLAST IDC_RORC
#define IDC_UNARYEXTENDEDLAST IDC_RORC
#define IDC_LASTCONTROL IDC_CEIL
#define IDC_BINARYEXTENDEDFIRST 500
#define IDC_LOGBASEY 500 // logy(x)
#define IDC_NAND 501 // Nand
#define IDC_NOR 502 // Nor
#define IDC_LOGBASEY 500 // logy(x)
#define IDC_NAND 501 // Nand
#define IDC_NOR 502 // Nor
#define IDC_RSHFL 505 //Right Shift Logical
#define IDC_BINARYEXTENDEDLAST IDC_RSHFL
#define IDC_RSHFL 505 // Right Shift Logical
#define IDC_BINARYEXTENDEDLAST IDC_RSHFL
#define IDC_RAND 600 // Random
#define IDC_EULER 601 // e Constant
#define IDC_RAND 600 // Random
#define IDC_EULER 601 // e Constant
#define IDC_BINEDITSTART 700
#define IDC_BINPOS0 700

View File

@@ -120,7 +120,7 @@ private:
bool m_bRecord; // Global mode: recording or displaying
bool m_bSetCalcState; // Flag for setting the engine result state
CalcEngine::CalcInput m_input; // Global calc input object for decimal strings
NumberFormat m_nFE; // Scientific notation conversion flag
NumberFormat m_nFE; // Scientific notation conversion flag
CalcEngine::Rational m_maxTrigonometricNum;
std::unique_ptr<CalcEngine::Rational> m_memoryValue; // Current memory value.
@@ -147,7 +147,7 @@ private:
std::array<int, MAXPRECDEPTH> m_nPrecOp; /* Holding array for precedence operations. */
size_t m_precedenceOpCount; /* Current number of precedence ops in holding. */
int m_nLastCom; // Last command entered.
AngleType m_angletype; // Current Angle type when in dec mode. one of deg, rad or grad
AngleType 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.
int32_t m_dwWordBitWidth; // # of bits in currently selected word size
@@ -158,8 +158,8 @@ private:
CHistoryCollector m_HistoryCollector; // Accumulator of each line of history as various commands are processed
std::array<CalcEngine::Rational, NUM_WIDTH_LENGTH> m_chopNumbers; // word size enforcement
std::array<std::wstring, NUM_WIDTH_LENGTH> m_maxDecimalValueStrings; // maximum values represented by a given word width based off m_chopNumbers
std::array<CalcEngine::Rational, NUM_WIDTH_LENGTH> m_chopNumbers; // word size enforcement
std::array<std::wstring, NUM_WIDTH_LENGTH> m_maxDecimalValueStrings; // maximum values represented by a given word width based off m_chopNumbers
static std::unordered_map<std::wstring_view, std::wstring> s_engineStrings; // the string table shared across all instances
wchar_t m_decimalSeparator;
wchar_t m_groupSeparator;

View File

@@ -206,8 +206,7 @@ inline constexpr auto SIDS_CUBEROOT = L"CubeRoot";
inline constexpr auto SIDS_PROGRAMMER_MOD = L"ProgrammerMod";
// Include the resource key ID from above into this vector to load it into memory for the engine to use
inline constexpr std::array<std::wstring_view, 152> g_sids =
{
inline constexpr std::array<std::wstring_view, 152> g_sids = {
SIDS_PLUS_MINUS,
SIDS_C,
SIDS_CE,

View File

@@ -20,8 +20,8 @@
#include <algorithm>
#include <string>
#include "CalcErr.h"
#include <cstring> // for memmove
#include "sal_cross_platform.h" // for SAL
#include <cstring> // for memmove
#include "sal_cross_platform.h" // for SAL
static constexpr uint32_t BASEXPWR = 31L; // Internal log2(BASEX)
static constexpr uint32_t BASEX = 0x80000000; // Internal radix used in calculations, hope to raise

View File

@@ -162,8 +162,7 @@ namespace UnitConversionManager
std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>,
UnitConversionManager::UnitHash>
UnitToUnitToConversionDataMap;
typedef std::unordered_map<int, std::vector<UnitConversionManager::Unit>>
CategoryToUnitVectorMap;
typedef std::unordered_map<int, std::vector<UnitConversionManager::Unit>> CategoryToUnitVectorMap;
class IViewModelCurrencyCallback
{

View File

@@ -20,6 +20,6 @@
#define SUCCEEDED(hr) (((ResultCode)(hr)) >= 0)
#define FAILED(hr) (((ResultCode)(hr)) < 0)
#define SCODE_CODE(sc) ((sc) & 0xFFFF)
#define SCODE_CODE(sc) ((sc)&0xFFFF)
#endif