From 7b78c412b01a31727a10586a4fcbcac1d95dd371 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 14 Dec 2018 16:36:56 -0800 Subject: [PATCH] Update rpiConfigServer formatting --- deps/tools/.clang | 1 + deps/tools/.clang-format | 107 ++++++++++++++++++ deps/tools/rpiConfigServer_src/DataHistory.h | 6 +- .../rpiConfigServer_src/MyHttpConnection.cpp | 5 +- .../rpiConfigServer_src/MyHttpConnection.h | 12 +- .../rpiConfigServer_src/SystemStatus.cpp | 12 +- deps/tools/rpiConfigServer_src/SystemStatus.h | 9 +- .../rpiConfigServer_src/VisionStatus.cpp | 22 ++-- deps/tools/rpiConfigServer_src/VisionStatus.h | 10 +- .../rpiConfigServer_src/WebSocketHandlers.cpp | 17 +-- .../rpiConfigServer_src/WebSocketHandlers.h | 8 +- deps/tools/rpiConfigServer_src/main.cpp | 21 ++-- 12 files changed, 168 insertions(+), 62 deletions(-) create mode 100644 deps/tools/.clang create mode 100644 deps/tools/.clang-format diff --git a/deps/tools/.clang b/deps/tools/.clang new file mode 100644 index 0000000..94f19a6 --- /dev/null +++ b/deps/tools/.clang @@ -0,0 +1 @@ +-std=c++11 -I../allwpilib/src/main/native/include diff --git a/deps/tools/.clang-format b/deps/tools/.clang-format new file mode 100644 index 0000000..92b4049 --- /dev/null +++ b/deps/tools/.clang-format @@ -0,0 +1,107 @@ +--- +Language: Cpp +BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 8 +UseTab: Never +... diff --git a/deps/tools/rpiConfigServer_src/DataHistory.h b/deps/tools/rpiConfigServer_src/DataHistory.h index f6edc04..aa33684 100644 --- a/deps/tools/rpiConfigServer_src/DataHistory.h +++ b/deps/tools/rpiConfigServer_src/DataHistory.h @@ -5,8 +5,8 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#ifndef WPIUTIL_DATAHISTORY_H_ -#define WPIUTIL_DATAHISTORY_H_ +#ifndef RPICONFIGSERVER_DATAHISTORY_H_ +#define RPICONFIGSERVER_DATAHISTORY_H_ #include @@ -53,4 +53,4 @@ class DataHistory { size_t m_qty = 0; }; -#endif // WPIUTIL_DATAHISTORY_H_ +#endif // RPICONFIGSERVER_DATAHISTORY_H_ diff --git a/deps/tools/rpiConfigServer_src/MyHttpConnection.cpp b/deps/tools/rpiConfigServer_src/MyHttpConnection.cpp index 47e1476..e4ca58e 100644 --- a/deps/tools/rpiConfigServer_src/MyHttpConnection.cpp +++ b/deps/tools/rpiConfigServer_src/MyHttpConnection.cpp @@ -7,9 +7,10 @@ #include "MyHttpConnection.h" +#include +#include + #include "WebSocketHandlers.h" -#include "wpi/UrlParser.h" -#include "wpi/raw_ostream.h" // static resources namespace wpi { diff --git a/deps/tools/rpiConfigServer_src/MyHttpConnection.h b/deps/tools/rpiConfigServer_src/MyHttpConnection.h index a1c70e6..5d2c9fd 100644 --- a/deps/tools/rpiConfigServer_src/MyHttpConnection.h +++ b/deps/tools/rpiConfigServer_src/MyHttpConnection.h @@ -5,14 +5,14 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#ifndef WPIUTIL_MYHTTPCONNECTION_H_ -#define WPIUTIL_MYHTTPCONNECTION_H_ +#ifndef RPICONFIGSERVER_MYHTTPCONNECTION_H_ +#define RPICONFIGSERVER_MYHTTPCONNECTION_H_ #include -#include "wpi/HttpServerConnection.h" -#include "wpi/WebSocketServer.h" -#include "wpi/uv/Stream.h" +#include +#include +#include class MyHttpConnection : public wpi::HttpServerConnection, public std::enable_shared_from_this { @@ -25,4 +25,4 @@ class MyHttpConnection : public wpi::HttpServerConnection, wpi::WebSocketServerHelper m_websocketHelper; }; -#endif // WPIUTIL_MYHTTPCONNECTION_H_ +#endif // RPICONFIGSERVER_MYHTTPCONNECTION_H_ diff --git a/deps/tools/rpiConfigServer_src/SystemStatus.cpp b/deps/tools/rpiConfigServer_src/SystemStatus.cpp index 6e50e81..eb4fda9 100644 --- a/deps/tools/rpiConfigServer_src/SystemStatus.cpp +++ b/deps/tools/rpiConfigServer_src/SystemStatus.cpp @@ -7,12 +7,12 @@ #include "SystemStatus.h" -#include "wpi/SmallString.h" -#include "wpi/SmallVector.h" -#include "wpi/StringRef.h" -#include "wpi/json.h" -#include "wpi/raw_istream.h" -#include "wpi/raw_ostream.h" +#include +#include +#include +#include +#include +#include std::shared_ptr SystemStatus::GetInstance() { static auto sysStatus = std::make_shared(private_init{}); diff --git a/deps/tools/rpiConfigServer_src/SystemStatus.h b/deps/tools/rpiConfigServer_src/SystemStatus.h index 7cf23f0..d5f81a3 100644 --- a/deps/tools/rpiConfigServer_src/SystemStatus.h +++ b/deps/tools/rpiConfigServer_src/SystemStatus.h @@ -5,13 +5,14 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#ifndef WPIUTIL_SYSTEMSTATUS_H_ -#define WPIUTIL_SYSTEMSTATUS_H_ +#ifndef RPICONFIGSERVER_SYSTEMSTATUS_H_ +#define RPICONFIGSERVER_SYSTEMSTATUS_H_ #include +#include + #include "DataHistory.h" -#include "wpi/Signal.h" namespace wpi { class json; @@ -57,4 +58,4 @@ class SystemStatus { DataHistory m_network; }; -#endif // WPIUTIL_SYSTEMSTATUS_H_ +#endif // RPICONFIGSERVER_SYSTEMSTATUS_H_ diff --git a/deps/tools/rpiConfigServer_src/VisionStatus.cpp b/deps/tools/rpiConfigServer_src/VisionStatus.cpp index de25c8a..ab8b8b2 100644 --- a/deps/tools/rpiConfigServer_src/VisionStatus.cpp +++ b/deps/tools/rpiConfigServer_src/VisionStatus.cpp @@ -7,24 +7,22 @@ #include "VisionStatus.h" -#ifndef _WIN32 #include #include #include #include #include -#endif #include -#include "wpi/SmallString.h" -#include "wpi/StringRef.h" -#include "wpi/json.h" -#include "wpi/raw_ostream.h" -#include "wpi/uv/Buffer.h" -#include "wpi/uv/Pipe.h" -#include "wpi/uv/Process.h" -#include "wpi/uv/Work.h" +#include +#include +#include +#include +#include +#include +#include +#include namespace uv = wpi::uv; @@ -37,7 +35,6 @@ std::shared_ptr VisionStatus::GetInstance() { void VisionStatus::RunSvc(const char* cmd, std::function onFail) { -#ifndef _WIN32 struct SvcWorkReq : public uv::WorkReq { SvcWorkReq(const char* cmd_, std::function onFail_) : cmd(cmd_), onFail(onFail_) {} @@ -69,7 +66,6 @@ void VisionStatus::RunSvc(const char* cmd, }); uv::QueueWork(m_loop, workReq); -#endif } void VisionStatus::Up(std::function onFail) { @@ -93,7 +89,6 @@ void VisionStatus::Kill(std::function onFail) { } void VisionStatus::UpdateStatus() { -#ifndef _WIN32 struct StatusWorkReq : public uv::WorkReq { bool enabled = false; wpi::SmallString<128> status; @@ -178,7 +173,6 @@ void VisionStatus::UpdateStatus() { }); uv::QueueWork(m_loop, workReq); -#endif } void VisionStatus::ConsoleLog(uv::Buffer& buf, size_t len) { diff --git a/deps/tools/rpiConfigServer_src/VisionStatus.h b/deps/tools/rpiConfigServer_src/VisionStatus.h index aaa2a22..8f6f146 100644 --- a/deps/tools/rpiConfigServer_src/VisionStatus.h +++ b/deps/tools/rpiConfigServer_src/VisionStatus.h @@ -5,14 +5,14 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#ifndef WPIUTIL_VISIONSTATUS_H_ -#define WPIUTIL_VISIONSTATUS_H_ +#ifndef RPICONFIGSERVER_VISIONSTATUS_H_ +#define RPICONFIGSERVER_VISIONSTATUS_H_ #include #include -#include "wpi/Signal.h" -#include "wpi/StringRef.h" +#include +#include namespace wpi { class json; @@ -54,4 +54,4 @@ class VisionStatus { std::shared_ptr m_loop; }; -#endif // WPIUTIL_VISIONSTATUS_H_ +#endif // RPICONFIGSERVER_VISIONSTATUS_H_ diff --git a/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp b/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp index 5e6817f..a7acece 100644 --- a/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp +++ b/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp @@ -9,16 +9,17 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include + #include "SystemStatus.h" #include "VisionStatus.h" -#include "wpi/SmallVector.h" -#include "wpi/WebSocket.h" -#include "wpi/json.h" -#include "wpi/raw_ostream.h" -#include "wpi/raw_uv_ostream.h" -#include "wpi/uv/Loop.h" -#include "wpi/uv/Pipe.h" -#include "wpi/uv/Process.h" namespace uv = wpi::uv; diff --git a/deps/tools/rpiConfigServer_src/WebSocketHandlers.h b/deps/tools/rpiConfigServer_src/WebSocketHandlers.h index 567ef52..9578468 100644 --- a/deps/tools/rpiConfigServer_src/WebSocketHandlers.h +++ b/deps/tools/rpiConfigServer_src/WebSocketHandlers.h @@ -5,10 +5,10 @@ /* the project. */ /*----------------------------------------------------------------------------*/ -#ifndef WPIUTIL_WEBSOCKETHANDLERS_H_ -#define WPIUTIL_WEBSOCKETHANDLERS_H_ +#ifndef RPICONFIGSERVER_WEBSOCKETHANDLERS_H_ +#define RPICONFIGSERVER_WEBSOCKETHANDLERS_H_ -#include "wpi/StringRef.h" +#include namespace wpi { class WebSocket; @@ -17,4 +17,4 @@ class WebSocket; void InitWs(wpi::WebSocket& ws); void ProcessWsText(wpi::WebSocket& ws, wpi::StringRef msg); -#endif // WPIUTIL_WEBSOCKETHANDLERS_H_ +#endif // RPICONFIGSERVER_WEBSOCKETHANDLERS_H_ diff --git a/deps/tools/rpiConfigServer_src/main.cpp b/deps/tools/rpiConfigServer_src/main.cpp index 7fc96ac..53b778f 100644 --- a/deps/tools/rpiConfigServer_src/main.cpp +++ b/deps/tools/rpiConfigServer_src/main.cpp @@ -8,19 +8,20 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "MyHttpConnection.h" #include "SystemStatus.h" #include "VisionStatus.h" -#include "wpi/ArrayRef.h" -#include "wpi/StringRef.h" -#include "wpi/raw_ostream.h" -#include "wpi/raw_uv_ostream.h" -#include "wpi/timestamp.h" -#include "wpi/uv/Loop.h" -#include "wpi/uv/Process.h" -#include "wpi/uv/Tcp.h" -#include "wpi/uv/Timer.h" -#include "wpi/uv/Udp.h" namespace uv = wpi::uv;