Skip to content

Commit

Permalink
Updating comments per the C++ core guidelines and removing trailing w…
Browse files Browse the repository at this point in the history
…hitespace (microsoft#194)

Fixed comments that were inconsistent with the style guidelines described in C++ core guidelines and the modern C++/WinRT language projections and removed trailing whitespace.

Inserted a space after the beginning of the comment so the text wasn't touching the // on all occurrences.

Removed all occurrences of trailing whitespace
  • Loading branch information
WilliamWelsh authored and HowardWolosky committed Mar 15, 2019
1 parent 62317fd commit 1113ff4
Show file tree
Hide file tree
Showing 82 changed files with 509 additions and 510 deletions.
4 changes: 2 additions & 2 deletions src/CalcManager/CEngine/History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ int CHistoryCollector::AddCommand(_In_ const std::shared_ptr<IExpressionCommand>
return nCommands - 1;
}

//To Update the operands in the Expression according to the current Radix
// To Update the operands in the Expression according to the current Radix
void CHistoryCollector::UpdateHistoryExpression(uint32_t radix, int32_t precision)
{
if (m_spTokens != nullptr)
Expand Down Expand Up @@ -451,7 +451,7 @@ void CHistoryCollector::SetDecimalSymbol(wchar_t decimalSymbol)
m_decimalSymbol = decimalSymbol;
}

//Update the commands corresponding to the passed string Number
// Update the commands corresponding to the passed string Number
std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFromString(wstring_view numStr)
{
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
Expand Down
18 changes: 9 additions & 9 deletions src/CalcManager/CEngine/scicomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace CalcEngine;
namespace {
// NPrecedenceOfOp
//
// returns a virtual number for precedence for the operator. We expect binary operator only, otherwise the lowest number
// returns a virtual number for precedence for the operator. We expect binary operator only, otherwise the lowest number
// 0 is returned. Higher the number, higher the precedence of the operator.
INT NPrecedenceOfOp(int nopCode)
{
Expand All @@ -54,13 +54,13 @@ namespace {

// HandleErrorCommand
//
// 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
// 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)
{
if (!IsGuiSettingOpCode(idc))
{
// we would have saved the prev command. Need to forget this state
// We would have saved the prev command. Need to forget this state
m_nTempCom = m_nLastCom;
}
}
Expand Down Expand Up @@ -128,7 +128,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
}
}

// Toggle Record/Display mode if appropriate.
// Toggle Record/Display mode if appropriate.
if (m_bRecord)
{
if (IsOpInRange(wParam, IDC_AND, IDC_MMINUS) ||
Expand Down Expand Up @@ -182,7 +182,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
// BINARY OPERATORS:
if (IsBinOpCode(wParam))
{
/* Change the operation if last input was operation. */
// Change the operation if last input was operation.
if (IsBinOpCode(m_nLastCom))
{
INT nPrev;
Expand Down Expand Up @@ -574,7 +574,7 @@ void CCalcEngine::ProcessCommandWorker(WPARAM wParam)
m_lastVal = 0;
if (IsBinOpCode(m_nLastCom))
{
// We want 1 + ( to start as 1 + (0. Any number you type replaces 0. But if it is 1 + 3 (, it is
// We want 1 + ( to start as 1 + (0. Any number you type replaces 0. But if it is 1 + 3 (, it is
// treated as 1 + (3
m_currentVal = 0;
}
Expand Down Expand Up @@ -803,7 +803,7 @@ void CCalcEngine::CheckAndAddLastBinOpToHistory(bool addToHistory)
{
if (m_HistoryCollector.FOpndAddedToHistory())
{
// if last time opnd was added but the last command was not a binary operator, then it must have come
// if last time opnd was added but the last command was not a binary operator, then it must have come
// from commands which add the operand, like unary operator. So history at this is showing 1 + sqrt(4)
// but in reality the sqrt(4) is getting replaced by new number (may be unary op, or MR or SUM etc.)
// So erase the last operand
Expand Down Expand Up @@ -855,7 +855,7 @@ void CCalcEngine::DisplayAnnounceBinaryOperator()
}

// Unary operator Function Name table Element
// since unary operators button names aren't exactly friendly for history purpose,
// since unary operators button names aren't exactly friendly for history purpose,
// we have this separate table to get its localized name and for its Inv function if it exists.
typedef struct
{
Expand Down Expand Up @@ -1027,7 +1027,7 @@ wstring CCalcEngine::GetCurrentResultForRadix(uint32_t radix, int32_t precision)
wstring numberString = GetStringForDisplay(rat, radix);
if (!numberString.empty())
{
//revert the precision to previously stored precision
// Revert the precision to previously stored precision
ChangeConstants(m_radix, m_precision);
}

Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/CEngine/scifunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r

uint64_t w64Bits = result.ToUInt64_t();
uint64_t lsb = ((w64Bits & 0x01) == 1) ? 1 : 0;
w64Bits >>= 1; //RShift by 1
w64Bits >>= 1; // RShift by 1
w64Bits |= (lsb << (m_dwWordBitWidth - 1));

result = w64Bits;
Expand Down
18 changes: 9 additions & 9 deletions src/CalcManager/CEngine/sciset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ using namespace std;
// dont change that.
void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwidth)
{
// When in integer mode, the number is represented in 2's complement form. When a bit width is changing, we can
// change the number representation back to sign, abs num form in ratpak. Soon when display sees this, it will
// convert to 2's complement form, but this time all high bits will be propagated. Eg. -127, in byte mode is
// represented as 1000,0001. This puts it back as sign=-1, 01111111 . But DisplayNum will see this and convert it
// When in integer mode, the number is represented in 2's complement form. When a bit width is changing, we can
// change the number representation back to sign, abs num form in ratpak. Soon when display sees this, it will
// convert to 2's complement form, but this time all high bits will be propagated. Eg. -127, in byte mode is
// represented as 1000,0001. This puts it back as sign=-1, 01111111 . But DisplayNum will see this and convert it
// back to 1111,1111,1000,0001 when in Word mode.
if (m_fIntegerMode)
{
Expand Down Expand Up @@ -46,7 +46,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RADIX_TYPE radixtype, NUM_WIDTH numwid
// inform ratpak that a change in base or precision has occurred
BaseOrPrecisionChanged();

// display the correct number for the new state (ie convert displayed
// display the correct number for the new state (ie convert displayed
// number to correct base)
DisplayNum();
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void CCalcEngine::UpdateMaxIntDigits()
if (m_fIntegerMode)
{
m_cIntDigitsSav = static_cast<int>(m_maxDecimalValueStrings[m_numwidth].length()) - 1;
// This is the max digits you can enter a decimal in fixed width mode aka integer mode -1. The last digit
// This is the max digits you can enter a decimal in fixed width mode aka integer mode -1. The last digit
// has to be checked separately
}
else
Expand All @@ -161,10 +161,10 @@ void CCalcEngine::ChangeBaseConstants(uint32_t radix, int maxIntDigits, int32_t
{
if (10 == radix)
{
ChangeConstants(radix, precision); // Base 10 precision for internal computing still needs to be 32, to
ChangeConstants(radix, precision); // Base 10 precision for internal computing still needs to be 32, to
// take care of decimals precisely. For eg. to get the HI word of a qword, we do a rsh, which depends on getting
// 18446744073709551615 / 4294967296 = 4294967295.9999917... This is important it works this and doesn't reduce
// the precision to number of digits allowed to enter. In other words, precision and # of allowed digits to be
// 18446744073709551615 / 4294967296 = 4294967295.9999917... This is important it works this and doesn't reduce
// the precision to number of digits allowed to enter. In other words, precision and # of allowed digits to be
// entered are different.
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/CalculatorHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ unsigned int CalculatorHistory::AddToHistory(_In_ shared_ptr<CalculatorVector <p

// to be changed when pszexp is back
tokens->GetString(&generatedExpression);
// Prefixing and suffixing the special Unicode markers to ensure that the expression
// Prefixing and suffixing the special Unicode markers to ensure that the expression
// in the history doesn't get broken for RTL languages
spHistoryItem->historyItemVector.expression = L'\u202d' + generatedExpression + L'\u202c';
spHistoryItem->historyItemVector.result = wstring(result);
Expand Down
16 changes: 8 additions & 8 deletions src/CalcManager/CalculatorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ namespace CalculationManager
}

/// <summary>
/// Convert Command to unsigned char.
/// Convert Command to unsigned char.
/// Since some Commands are higher than 255, they are saved after subtracting 255
/// The smallest Command is CommandSIGN = 80, thus, subtracted value does not overlap with other values.
/// </summary>
Expand Down Expand Up @@ -435,9 +435,9 @@ namespace CalculationManager
if (*commandItr >= MEMORY_COMMAND_TO_UNSIGNED_CHAR(MemoryCommand::MemorizeNumber) &&
*commandItr <= MEMORY_COMMAND_TO_UNSIGNED_CHAR(MemoryCommand::MemorizedNumberClearAll))
{
//MemoryCommands(which have values above 255) are pushed on m_savedCommands upon casting to unsigned char.
//SerializeCommands uses m_savedCommands, which is then used in DeSerializeCommands.
//Hence, a simple cast to MemoryCommand is not sufficient.
// MemoryCommands(which have values above 255) are pushed on m_savedCommands upon casting to unsigned char.
// SerializeCommands uses m_savedCommands, which is then used in DeSerializeCommands.
// Hence, a simple cast to MemoryCommand is not sufficient.
MemoryCommand memoryCommand = static_cast<MemoryCommand>(*commandItr + UCHAR_MAX + 1);
unsigned int indexOfMemory = 0;
switch (memoryCommand)
Expand Down Expand Up @@ -761,7 +761,7 @@ namespace CalculationManager
}

void CalculatorManager::UpdateMaxIntDigits()
{
{
m_currentCalculatorEngine->UpdateMaxIntDigits();
}

Expand All @@ -785,7 +785,7 @@ namespace CalculationManager
/// How Rational is serialized :
/// Serialized Rational.P(Number) + Serialized Rational.Q(Number)
/// How Number is saved :
/// [0] = Rational.P.Sign
/// [0] = Rational.P.Sign
/// [1] = Rational.P.Mantissa.size
/// [2] = Rational.P.Exp
/// [3] = Rational.P.Mantissa[0]
Expand Down Expand Up @@ -823,7 +823,7 @@ namespace CalculationManager
/// <summary>
/// Serialize Number to vector of long
/// How Number is saved :
/// [0] = Number.Sign
/// [0] = Number.Sign
/// [1] = Number.Mantissa.size
/// [2] = Number.Exp
/// [3] = Number.Mantissa[0]
Expand All @@ -850,7 +850,7 @@ namespace CalculationManager
/// <summary>
/// DeserializeNumber vector and construct a Number
/// How Number is saved :
/// [0] = Number.Sign
/// [0] = Number.Sign
/// [1] = Number.Mantissa.size
/// [2] = Number.Exp
/// [3] = Number.Mantissa[0]
Expand Down
4 changes: 2 additions & 2 deletions src/CalcManager/CalculatorManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ namespace CalculationManager
ProgrammerModePrecision = 64
};

// Numbering continues from the Enum Command from Command.h
// Numbering continues from the Enum Command from Command.h
// with some gap to ensure there is no overlap of these ids
// when static_cast<unsigned char> is performed on these ids
// when static_cast<unsigned char> is performed on these ids
// they shouldn't fall in any number range greater than 80. So never
// make the memory command ids go below 330
enum class MemoryCommand
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/CalculatorResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace CalculationManager
public:
virtual ~IResourceProvider() { }

// Should return a string from the resource table for strings used
// Should return a string from the resource table for strings used
// by the calculation engine. The strings that must be defined
// and the ids to define them with can be seen in EngineStrings.h
// with SIDS prefix. Additionally it must provide values for string
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/CalculatorVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once

template <typename TType>
class CalculatorVector
class CalculatorVector
{
public:
HRESULT GetAt(_In_opt_ unsigned int index, _Out_ TType *item)
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace CalculationManager
CommandFAC = 113,
CommandREC = 114,
CommandDMS = 115,
CommandCUBEROOT = 116, //x ^ 1/3
CommandCUBEROOT = 116, // x ^ 1/3
CommandPOW10 = 117, // 10 ^ x
CommandPERCENT = 118,

Expand Down
34 changes: 17 additions & 17 deletions src/CalcManager/ExpressionCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ void CUnaryCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
CBinaryCommand::CBinaryCommand(int command) :m_command(command)
{}

void CBinaryCommand::SetCommand(int command)
{
m_command = command;
void CBinaryCommand::SetCommand(int command)
{
m_command = command;
}

int CBinaryCommand::GetCommand() const
{
return m_command;
{
return m_command;
}

CalculationManager::CommandType CBinaryCommand::GetCommandType() const
{
return CalculationManager::CommandType::BinaryCommand;
{
return CalculationManager::CommandType::BinaryCommand;
}

void CBinaryCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
Expand All @@ -111,8 +111,8 @@ void COpndCommand::Initialize(Rational const& rat)
}

const shared_ptr<CalculatorVector<int>> & COpndCommand::GetCommands() const
{
return m_commands;
{
return m_commands;
}

void COpndCommand::SetCommands(shared_ptr<CalculatorVector<int>> const& commands)
Expand Down Expand Up @@ -166,7 +166,7 @@ void COpndCommand::RemoveFromEnd()
{
unsigned int nCommands;
m_commands->GetSize(&nCommands);

if (nCommands == 1)
{
ClearAllAndAppendCommand(CalculationManager::Command::Command0);
Expand All @@ -185,8 +185,8 @@ void COpndCommand::RemoveFromEnd()
}

bool COpndCommand::IsNegative() const
{
return m_fNegative;
{
return m_fNegative;
}

bool COpndCommand::IsSciFmt() const
Expand All @@ -195,13 +195,13 @@ bool COpndCommand::IsSciFmt() const
}

bool COpndCommand::IsDecimalPresent() const
{
return m_fDecimal;
{
return m_fDecimal;
}

CalculationManager::CommandType COpndCommand::GetCommandType() const
{
return CalculationManager::CommandType::OperandCommand;
{
return CalculationManager::CommandType::OperandCommand;
}

void COpndCommand::ClearAllAndAppendCommand(CalculationManager::Command command)
Expand Down Expand Up @@ -283,7 +283,7 @@ const wstring & COpndCommand::GetToken(wchar_t decimalSymbol)
m_token.clear();
m_token.append(&chZero);
}

return m_token;
}

Expand Down
4 changes: 2 additions & 2 deletions src/CalcManager/Header Files/CCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@


// Key IDs:
// These id's must be consecutive from IDC_FIRSTCONTROL to IDC_LASTCONTROL.
// These id's must be consecutive from IDC_FIRSTCONTROL to IDC_LASTCONTROL.
// The actual values don't matter but the order and sequence are very important.
// Also, the order of the controls must match the order of the control names
// in the string table.
Expand Down Expand Up @@ -97,7 +97,7 @@
#define IDC_FAC 113
#define IDC_REC 114
#define IDC_DMS 115
#define IDC_CUBEROOT 116 //x ^ 1/3
#define IDC_CUBEROOT 116 // x ^ 1/3
#define IDC_POW10 117 // 10 ^ x
#define IDC_PERCENT 118
#define IDC_UNARYLAST IDC_PERCENT
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Header Files/CalcEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CCalcEngine {
// if it hasn't yet been computed
bool m_bChangeOp; /* Flag for changing operation. */
bool m_bRecord; // Global mode: recording or displaying
bool m_bSetCalcState; //Flag for setting the engine result state
bool m_bSetCalcState; // Flag for setting the engine result state
CalcEngine::CalcInput m_input; // Global calc input object for decimal strings
eNUMOBJ_FMT m_nFE; /* Scientific notation conversion flag. */
CalcEngine::Rational m_maxTrigonometricNum;
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Header Files/CalcInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Rational.h"

// Space to hold enough digits for a quadword binary number (64) plus digit separator strings for that number (20)
constexpr int MAX_STRLEN = 84;
constexpr int MAX_STRLEN = 84;

namespace CalcEngine
{
Expand Down
Loading

0 comments on commit 1113ff4

Please sign in to comment.