Skip to content

Commit

Permalink
Clang-format most of the sources (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
janisozaur authored May 10, 2021
1 parent f7d0118 commit f30e949
Show file tree
Hide file tree
Showing 54 changed files with 760 additions and 830 deletions.
4 changes: 2 additions & 2 deletions src/CalcManager/CEngine/Rational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
45 changes: 13 additions & 32 deletions src/CalcManager/CEngine/scicomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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>>>());
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 } },
Expand Down
6 changes: 3 additions & 3 deletions src/CalcManager/CEngine/scifunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/CalcManager/CalculatorVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,7 +118,6 @@ class CalculatorVector
ResultCode hr = this->GetSize(&nTokens);
if (SUCCEEDED(hr))
{

std::pair<std::wstring, int> currentPair;
for (unsigned int i = 0; i < nTokens; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace CalculationManager
CommandCOTH = 410,
CommandACOTH = 411,

CommandPOW2 = 412, // 2 ^ x
CommandPOW2 = 412, // 2 ^ x
CommandAbs = 413,
CommandFloor = 414,
CommandCeil = 415,
Expand Down
44 changes: 22 additions & 22 deletions src/CalcManager/Header Files/CCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/CalcManager/Header Files/CalcEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class CCalcEngine
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.

Expand All @@ -147,7 +147,7 @@ class CCalcEngine
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

Expand All @@ -158,8 +158,8 @@ class CCalcEngine

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;
Expand Down
3 changes: 1 addition & 2 deletions src/CalcManager/Header Files/EngineStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/CalcManager/Ratpack/ratpak.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/CalcManager/UnitConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/winerror_cross_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/CalcViewModel/ApplicationViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace
ApplicationViewModel::ApplicationViewModel()
: m_CalculatorViewModel(nullptr)
, m_DateCalcViewModel(nullptr)
, m_GraphingCalcViewModel(nullptr)
, m_GraphingCalcViewModel(nullptr)
, m_ConverterViewModel(nullptr)
, m_PreviousMode(ViewMode::None)
, m_mode(ViewMode::None)
Expand Down
1 change: 0 additions & 1 deletion src/CalcViewModel/Common/Automation/NarratorAnnouncement.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ public
static NarratorAnnouncement ^ GetAlwaysOnTopChangedAnnouncement(Platform::String ^ announcement);

static NarratorAnnouncement ^ GetBitShiftRadioButtonCheckedAnnouncement(Platform::String ^ announcement);

};
}
48 changes: 24 additions & 24 deletions src/CalcViewModel/Common/CalculatorButtonUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,33 +94,33 @@ public
Byte = (int)CM::Command::CommandByte,
Cube = (int)CM::Command::CommandCUB,
DMS = (int)CM::Command::CommandDMS,
Hyp = (int) CM::Command::CommandHYP,
Sec = (int) CM::Command::CommandSEC,
Csc = (int) CM::Command::CommandCSC,
Cot = (int) CM::Command::CommandCOT,
InvSec = (int) CM::Command::CommandASEC,
InvCsc = (int) CM::Command::CommandACSC,
InvCot = (int) CM::Command::CommandACOT,
Sech = (int) CM::Command::CommandSECH,
Csch = (int) CM::Command::CommandCSCH,
Coth = (int) CM::Command::CommandCOTH,
InvSech = (int) CM::Command::CommandASECH,
InvCsch = (int) CM::Command::CommandACSCH,
InvCoth = (int) CM::Command::CommandACOTH,
CubeRoot = (int) CM::Command::CommandCUBEROOT,
TwoPowerX = (int) CM::Command::CommandPOW2,
LogBaseY = (int) CM::Command::CommandLogBaseY,
Nand = (int) CM::Command::CommandNand,
Nor = (int) CM::Command::CommandNor,
Abs = (int) CM::Command::CommandAbs,
Floor = (int) CM::Command::CommandFloor,
Ceil = (int) CM::Command::CommandCeil,
Rand = (int) CM::Command::CommandRand,
Euler = (int) CM::Command::CommandEuler,
Hyp = (int)CM::Command::CommandHYP,
Sec = (int)CM::Command::CommandSEC,
Csc = (int)CM::Command::CommandCSC,
Cot = (int)CM::Command::CommandCOT,
InvSec = (int)CM::Command::CommandASEC,
InvCsc = (int)CM::Command::CommandACSC,
InvCot = (int)CM::Command::CommandACOT,
Sech = (int)CM::Command::CommandSECH,
Csch = (int)CM::Command::CommandCSCH,
Coth = (int)CM::Command::CommandCOTH,
InvSech = (int)CM::Command::CommandASECH,
InvCsch = (int)CM::Command::CommandACSCH,
InvCoth = (int)CM::Command::CommandACOTH,
CubeRoot = (int)CM::Command::CommandCUBEROOT,
TwoPowerX = (int)CM::Command::CommandPOW2,
LogBaseY = (int)CM::Command::CommandLogBaseY,
Nand = (int)CM::Command::CommandNand,
Nor = (int)CM::Command::CommandNor,
Abs = (int)CM::Command::CommandAbs,
Floor = (int)CM::Command::CommandFloor,
Ceil = (int)CM::Command::CommandCeil,
Rand = (int)CM::Command::CommandRand,
Euler = (int)CM::Command::CommandEuler,
RshL = (int)CM::Command::CommandRSHFL,
RolC = (int)CM::Command::CommandROLC,
RorC = (int)CM::Command::CommandRORC,

BINSTART = (int)CM::Command::CommandBINEDITSTART,
BINPOS0 = (int)CM::Command::CommandBINPOS0,
BINPOS1 = (int)CM::Command::CommandBINPOS1,
Expand Down
2 changes: 1 addition & 1 deletion src/CalcViewModel/Common/CopyPasteManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public
Platform::String ^ operand,
CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
CalculatorApp::Common::NumberBase programmerNumberBase);
CalculatorApp::Common::NumberBase programmerNumberBase);
static ULONG32 ProgrammerOperandLength(Platform::String ^ operand, CalculatorApp::Common::NumberBase numberBase);

private:
Expand Down
2 changes: 1 addition & 1 deletion src/CalcViewModel/Common/LocalizationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ LocalizationService ^ LocalizationService::GetInstance()
/// <remarks>
/// Should only be used for test purpose
/// </remarks>
void LocalizationService::OverrideWithLanguage(_In_ const wchar_t * const language)
void LocalizationService::OverrideWithLanguage(_In_ const wchar_t* const language)
{
s_singletonInstance = ref new LocalizationService(language);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CalcViewModel/Common/LocalizationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ namespace CalculatorApp
std::wstring destination;
std::copy_if(
begin(source), end(source), std::back_inserter(destination), [this](auto const c) { return c != L' ' && c != m_numberGroupSeparator; });

return ref new Platform::String(destination.c_str());
}

Expand Down
Loading

0 comments on commit f30e949

Please sign in to comment.