From 6dc49e5bdb86ffd5730eb10eb9c477276e79923c Mon Sep 17 00:00:00 2001 From: Riku Isokoski Date: Wed, 25 Jan 2023 11:24:38 +0200 Subject: [PATCH] clang-format: Always break template declarations I find this format easier to read, because the definitions are at the expected indentation, making it easier to find what I'm looking for. --- .clang-format | 2 +- src/StaticStack.h | 15 ++++++++++----- src/components/utility/LinearApproximation.h | 3 ++- src/displayapp/screens/Screen.h | 3 ++- src/displayapp/screens/ScreenList.h | 3 ++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.clang-format b/.clang-format index b5c102d5..18f134dc 100644 --- a/.clang-format +++ b/.clang-format @@ -20,7 +20,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine +AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false BraceWrapping: diff --git a/src/StaticStack.h b/src/StaticStack.h index 64886604..598febce 100644 --- a/src/StaticStack.h +++ b/src/StaticStack.h @@ -1,7 +1,8 @@ #include #include -template class StaticStack { +template +class StaticStack { public: T Pop(); void Push(T element); @@ -15,24 +16,28 @@ private: }; // Returns random data when popping from empty array. -template T StaticStack::Pop() { +template +T StaticStack::Pop() { if (stackPointer > 0) { stackPointer--; } return elementArray[stackPointer]; } -template void StaticStack::Push(T element) { +template +void StaticStack::Push(T element) { if (stackPointer < elementArray.size()) { elementArray[stackPointer] = element; stackPointer++; } } -template void StaticStack::Reset() { +template +void StaticStack::Reset() { stackPointer = 0; } -template T StaticStack::Top() { +template +T StaticStack::Top() { return elementArray[stackPointer - 1]; } diff --git a/src/components/utility/LinearApproximation.h b/src/components/utility/LinearApproximation.h index f7104ced..1fe58d44 100644 --- a/src/components/utility/LinearApproximation.h +++ b/src/components/utility/LinearApproximation.h @@ -7,7 +7,8 @@ namespace Pinetime { namespace Utility { // based on: https://github.com/SHristov92/LinearApproximation/blob/main/Linear.h - template class LinearApproximation { + template + class LinearApproximation { using Point = struct { Key key; Value value; diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index 4cf134d2..73f80191 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -10,7 +10,8 @@ namespace Pinetime { namespace Screens { - template class DirtyValue { + template + class DirtyValue { public: DirtyValue() = default; // Use NSDMI diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h index 6c9a2218..255544b6 100644 --- a/src/displayapp/screens/ScreenList.h +++ b/src/displayapp/screens/ScreenList.h @@ -12,7 +12,8 @@ namespace Pinetime { enum class ScreenListModes { UpDown, RightLeft, LongPress }; - template class ScreenList : public Screen { + template + class ScreenList : public Screen { public: ScreenList(DisplayApp* app, uint8_t initScreen,