Skip to content

Commit 9f01c81

Browse files
author
Daniel Belcher
authored
Secondary formatting changes (#489)
Description of the changes: Adjusted some of the values in .clang-format Add clang-format-all.ps1 Fix path to .clang-format in Calculator.sln How changes were validated: Manual.
1 parent 2826d37 commit 9f01c81

File tree

113 files changed

+1785
-824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1785
-824
lines changed

.clang-format

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
AccessModifierOffset: -4
2-
AlignAfterOpenBracket: Align
2+
AlignAfterOpenBracket: AlwaysBreak
33
AlignConsecutiveAssignments: false
44
AlignConsecutiveDeclarations: false
55
AlignEscapedNewlines: Right
66
AlignOperands: true
77
AlignTrailingComments: true
8-
AllowAllParametersOfDeclarationOnNextLine: true
8+
AllowAllParametersOfDeclarationOnNextLine: false
99
AllowShortBlocksOnASingleLine: false
1010
AllowShortCaseLabelsOnASingleLine: false
1111
AllowShortFunctionsOnASingleLine: None
@@ -15,8 +15,8 @@ AlwaysBreakAfterDefinitionReturnType: None
1515
AlwaysBreakAfterReturnType: None
1616
AlwaysBreakBeforeMultilineStrings: false
1717
AlwaysBreakTemplateDeclarations: true
18-
BinPackArguments: true
19-
BinPackParameters: true
18+
BinPackArguments: false
19+
BinPackParameters: false
2020
BreakBeforeBinaryOperators: NonAssignment
2121
BreakBeforeBraces: Allman
2222
BreakBeforeInheritanceComma: false
@@ -28,7 +28,7 @@ BreakStringLiterals: true
2828
ColumnLimit: 160
2929
CommentPragmas: '^ IWYU pragma:'
3030
CompactNamespaces: true
31-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
31+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
3232
ConstructorInitializerIndentWidth: 4
3333
ContinuationIndentWidth: 4
3434
Cpp11BracedListStyle: false
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<#
2+
.DESCRIPTION
3+
Helper script to format all header and source files in the repository.
4+
5+
By default, the script will recursively search under the repo root for
6+
files to format. Users can give explicit parameters indicating how the
7+
search should include and exclude filetypes.
8+
9+
If users don't want the search functionality, they can instead provide
10+
an explicit list of files to format.
11+
12+
.PARAMETER RepoRoot
13+
Full path to the root of the repository which is the target of the search.
14+
Will default to the root of the current working directory.
15+
16+
.PARAMETER Include
17+
Array of filetype extensions to target for formatting.
18+
By default, targets standard extensions for header and source files.
19+
Follows the same rules as the -Include parameter for Get-ChildItem.
20+
21+
.PARAMETER Exclude
22+
Array of filetype extensions to exclude from formatting.
23+
By default, excludes generated XAML files.
24+
Follows the same rules as the -Exclude paramter for Get-ChildItem.
25+
26+
.PARAMETER Files
27+
Array of files to format. The script will exit if one of the provided
28+
filepaths does not exist.
29+
30+
.EXAMPLE
31+
.\clang-format-all.ps1
32+
33+
Formats all header and source files under the repository root.
34+
35+
.EXAMPLE
36+
.\clang-format-all.ps1 -RepoRoot 'S:\repos\calculator' -Include '*.h', '*.cpp' -Exclude '*.g.*'
37+
38+
Formats all *.h and *.cpp files under 'S:\repos\calculator', excluding files with an extension
39+
like *.g.*
40+
41+
.EXAMPLE
42+
.\clang-format-all.ps1 -File 'S:\repos\calculator\src\CalcViewModel\UnitConverterViewModel.h', 'S:\repos\calculator\src\CalcViewModel\MemoryItemViewModel.cpp'
43+
44+
Formats the specified files.
45+
#>
46+
[CmdletBinding( DefaultParameterSetName = 'Search' )]
47+
param(
48+
[Parameter( ParameterSetName = 'Search' )]
49+
[ValidateScript({ Test-Path -PathType Container -Path $_ })]
50+
[string] $RepoRoot = "$( git rev-parse --show-toplevel )",
51+
52+
[Parameter( ParameterSetName = 'Search' )]
53+
[string[]] $Include = ( '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp' ),
54+
55+
[Parameter( ParameterSetName = 'Search' )]
56+
[string[]] $Exclude = '*.g.*',
57+
58+
[Parameter(
59+
ParameterSetName = 'Explicit',
60+
Mandatory)]
61+
[ValidateScript({
62+
$_ | Where-Object { -not (Test-Path -PathType Leaf -Path $_) } |
63+
ForEach-Object { throw "Could not find file: [$_]" }
64+
65+
return $true
66+
})]
67+
[string[]] $Files
68+
)
69+
70+
if ($PSCmdlet.ParameterSetName -eq 'Explicit')
71+
{
72+
# Use the file paths we were given.
73+
$targetFiles = @($Files)
74+
}
75+
else
76+
{
77+
# Gather the files to be formatted.
78+
$targetFiles = @(
79+
Get-ChildItem -Recurse -Path $RepoRoot -Include $Include -Exclude $Exclude |
80+
Select-Object -ExpandProperty FullName
81+
)
82+
}
83+
84+
# Format the files.
85+
$formatParams = @(
86+
'-i' # In-place
87+
'-style=file' # Search for a .clang-format file in the parent directory of the source file.
88+
'-verbose'
89+
)
90+
91+
clang-format $formatParams $targetFiles

src/CalcManager/CEngine/History.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ void CHistoryCollector::ReinitHistory()
4040
// Constructor
4141
// Can throw Out of memory error
4242
CHistoryCollector::CHistoryCollector(ICalcDisplay* pCalcDisplay, std::shared_ptr<IHistoryDisplay> pHistoryDisplay, wchar_t decimalSymbol)
43-
: m_pHistoryDisplay(pHistoryDisplay), m_pCalcDisplay(pCalcDisplay), m_iCurLineHistStart(-1), m_decimalSymbol(decimalSymbol)
43+
: m_pHistoryDisplay(pHistoryDisplay)
44+
, m_pCalcDisplay(pCalcDisplay)
45+
, m_iCurLineHistStart(-1)
46+
, m_decimalSymbol(decimalSymbol)
4447
{
4548
ReinitHistory();
4649
}
@@ -300,8 +303,8 @@ void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
300303
{
301304
if (nullptr != m_pCalcDisplay)
302305
{
303-
m_pCalcDisplay->SetExpressionDisplay(std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(),
304-
std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
306+
m_pCalcDisplay->SetExpressionDisplay(
307+
std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
305308
}
306309

307310
if (nullptr != m_pHistoryDisplay)
@@ -322,8 +325,8 @@ void CHistoryCollector::ClearHistoryLine(wstring_view errStr)
322325
{
323326
if (nullptr != m_pCalcDisplay)
324327
{
325-
m_pCalcDisplay->SetExpressionDisplay(std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(),
326-
std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
328+
m_pCalcDisplay->SetExpressionDisplay(
329+
std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
327330
}
328331
m_iCurLineHistStart = -1; // It will get recomputed at the first Opnd
329332
ReinitHistory();

src/CalcManager/CEngine/Number.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ using namespace std;
77

88
namespace CalcEngine
99
{
10-
Number::Number() noexcept : Number(1, 0, { 0 })
10+
Number::Number() noexcept
11+
: Number(1, 0, { 0 })
1112
{
1213
}
1314

14-
Number::Number(int32_t sign, int32_t exp, vector<uint32_t> const& mantissa) noexcept : m_sign{ sign }, m_exp{ exp }, m_mantissa{ mantissa }
15+
Number::Number(int32_t sign, int32_t exp, vector<uint32_t> const& mantissa) noexcept
16+
: m_sign{ sign }
17+
, m_exp{ exp }
18+
, m_mantissa{ mantissa }
1519
{
1620
}
1721

18-
Number::Number(PNUMBER p) noexcept : m_sign{ p->sign }, m_exp{ p->exp }, m_mantissa{}
22+
Number::Number(PNUMBER p) noexcept
23+
: m_sign{ p->sign }
24+
, m_exp{ p->exp }
25+
, m_mantissa{}
1926
{
2027
m_mantissa.reserve(p->cdigit);
2128
copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa));

src/CalcManager/CEngine/Rational.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ using namespace std;
77

88
namespace CalcEngine
99
{
10-
Rational::Rational() noexcept : m_p{}, m_q{ 1, 0, { 1 } }
10+
Rational::Rational() noexcept
11+
: m_p{}
12+
, m_q{ 1, 0, { 1 } }
1113
{
1214
}
1315

@@ -23,7 +25,9 @@ namespace CalcEngine
2325
m_q = Number(1, qExp, { 1 });
2426
}
2527

26-
Rational::Rational(Number const& p, Number const& q) noexcept : m_p{ p }, m_q{ q }
28+
Rational::Rational(Number const& p, Number const& q) noexcept
29+
: m_p{ p }
30+
, m_q{ q }
2731
{
2832
}
2933

@@ -58,7 +62,9 @@ namespace CalcEngine
5862
m_q = Number{ temp.Q() };
5963
}
6064

61-
Rational::Rational(PRAT prat) noexcept : m_p{ Number{ prat->pp } }, m_q{ Number{ prat->pq } }
65+
Rational::Rational(PRAT prat) noexcept
66+
: m_p{ Number{ prat->pp } }
67+
, m_q{ Number{ prat->pq } }
6268
{
6369
}
6470

src/CalcManager/CEngine/calc.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ void CCalcEngine::InitialOneTimeOnlySetup(CalculationManager::IResourceProvider&
5858
// CCalcEngine::CCalcEngine
5959
//
6060
//////////////////////////////////////////////////
61-
CCalcEngine::CCalcEngine(bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider,
62-
__in_opt ICalcDisplay* pCalcDisplay, __in_opt shared_ptr<IHistoryDisplay> pHistoryDisplay)
61+
CCalcEngine::CCalcEngine(
62+
bool fPrecedence,
63+
bool fIntegerMode,
64+
CalculationManager::IResourceProvider* const pResourceProvider,
65+
__in_opt ICalcDisplay* pCalcDisplay,
66+
__in_opt shared_ptr<IHistoryDisplay> pHistoryDisplay)
6367
: m_fPrecedence(fPrecedence)
6468
, m_fIntegerMode(fIntegerMode)
6569
, m_pCalcDisplay(pCalcDisplay)

src/CalcManager/CEngine/scicomm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
382382
if (nullptr != m_pCalcDisplay)
383383
{
384384
m_pCalcDisplay->SetParenthesisNumber(0);
385-
m_pCalcDisplay->SetExpressionDisplay(make_shared<CalculatorVector<pair<wstring, int>>>(),
386-
make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
385+
m_pCalcDisplay->SetExpressionDisplay(
386+
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
387387
}
388388

389389
m_HistoryCollector.ClearHistoryLine(wstring());
@@ -476,8 +476,8 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
476476
m_HistoryCollector.CompleteHistoryLine(groupedString);
477477
if (nullptr != m_pCalcDisplay)
478478
{
479-
m_pCalcDisplay->SetExpressionDisplay(make_shared<CalculatorVector<pair<wstring, int>>>(),
480-
make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
479+
m_pCalcDisplay->SetExpressionDisplay(
480+
make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
481481
}
482482
}
483483

src/CalcManager/CalculatorHistory.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
using namespace std;
88
using namespace CalculationManager;
99

10-
CalculatorHistory::CalculatorHistory(size_t maxSize) : m_maxHistorySize(maxSize)
10+
CalculatorHistory::CalculatorHistory(size_t maxSize)
11+
: m_maxHistorySize(maxSize)
1112
{
1213
}
1314

14-
unsigned int CalculatorHistory::AddToHistory(_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
15-
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands, _In_ wstring_view result)
15+
unsigned int CalculatorHistory::AddToHistory(
16+
_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
17+
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands,
18+
_In_ wstring_view result)
1619
{
1720
unsigned int addedIndex;
1821
wstring generatedExpression;

src/CalcManager/CalculatorHistory.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ namespace CalculationManager
3030
{
3131
public:
3232
CalculatorHistory(const size_t maxSize);
33-
unsigned int AddToHistory(_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
34-
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands, std::wstring_view result);
33+
unsigned int AddToHistory(
34+
_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
35+
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands,
36+
std::wstring_view result);
3537
std::vector<std::shared_ptr<HISTORYITEM>> const& GetHistory();
3638
std::shared_ptr<HISTORYITEM> const& GetHistoryItem(unsigned int uIdx);
3739
void ClearHistory();

src/CalcManager/CalculatorManager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ namespace CalculationManager
8585
/// Used to set the expression display value on ViewModel
8686
/// </summary>
8787
/// <param name="expressionString">wstring representing expression to be displayed</param>
88-
void CalculatorManager::SetExpressionDisplay(_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
89-
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
88+
void CalculatorManager::SetExpressionDisplay(
89+
_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
90+
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
9091
{
9192
if (!m_inHistoryItemLoadMode)
9293
{

0 commit comments

Comments
 (0)