Skip to content

Commit d5ede22

Browse files
committed
Run clang-format over whole codebase
1 parent c87417e commit d5ede22

File tree

144 files changed

+2883
-3560
lines changed

Some content is hidden

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

144 files changed

+2883
-3560
lines changed

Diff for: .clang-format

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
Language: Cpp
2+
# BasedOnStyle: LLVM
3+
AccessModifierOffset: -2
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveDeclarations: false
7+
AlignEscapedNewlines: Right
8+
AlignOperands: true
9+
AlignTrailingComments: true
10+
AllowAllParametersOfDeclarationOnNextLine: true
11+
AllowShortBlocksOnASingleLine: false
12+
AllowShortCaseLabelsOnASingleLine: false
13+
AllowShortFunctionsOnASingleLine: All
14+
AllowShortIfStatementsOnASingleLine: false
15+
AllowShortLoopsOnASingleLine: false
16+
AlwaysBreakAfterDefinitionReturnType: None
17+
AlwaysBreakAfterReturnType: None
18+
AlwaysBreakBeforeMultilineStrings: false
19+
AlwaysBreakTemplateDeclarations: Yes
20+
BinPackArguments: true
21+
BinPackParameters: true
22+
BraceWrapping:
23+
AfterClass: false
24+
AfterControlStatement: false
25+
AfterEnum: false
26+
AfterFunction: false
27+
AfterNamespace: false
28+
AfterObjCDeclaration: false
29+
AfterStruct: false
30+
AfterUnion: false
31+
AfterExternBlock: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
SplitEmptyFunction: true
36+
SplitEmptyRecord: true
37+
SplitEmptyNamespace: true
38+
BreakBeforeBinaryOperators: None
39+
BreakBeforeBraces: Attach
40+
BreakBeforeInheritanceComma: false
41+
BreakInheritanceList: BeforeColon
42+
BreakBeforeTernaryOperators: true
43+
BreakConstructorInitializersBeforeComma: false
44+
BreakConstructorInitializers: BeforeColon
45+
BreakAfterJavaFieldAnnotations: false
46+
BreakStringLiterals: true
47+
ColumnLimit: 160
48+
CommentPragmas: '^ IWYU pragma:'
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
ExperimentalAutoDetectBinPacking: false
57+
FixNamespaceComments: true
58+
ForEachMacros:
59+
- foreach
60+
- Q_FOREACH
61+
- BOOST_FOREACH
62+
IncludeBlocks: Preserve
63+
IncludeCategories:
64+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
65+
Priority: 2
66+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
67+
Priority: 3
68+
- Regex: '.*'
69+
Priority: 1
70+
IncludeIsMainRegex: '(Test)?$'
71+
IndentCaseLabels: false
72+
IndentPPDirectives: None
73+
IndentWidth: 2
74+
IndentWrappedFunctionNames: false
75+
JavaScriptQuotes: Leave
76+
JavaScriptWrapImports: true
77+
KeepEmptyLinesAtTheStartOfBlocks: true
78+
MacroBlockBegin: ''
79+
MacroBlockEnd: ''
80+
MaxEmptyLinesToKeep: 1
81+
NamespaceIndentation: All
82+
ObjCBinPackProtocolList: Auto
83+
ObjCBlockIndentWidth: 2
84+
ObjCSpaceAfterProperty: false
85+
ObjCSpaceBeforeProtocolList: true
86+
PenaltyBreakAssignment: 2
87+
PenaltyBreakBeforeFirstCallParameter: 19
88+
PenaltyBreakComment: 300
89+
PenaltyBreakFirstLessLess: 120
90+
PenaltyBreakString: 1000
91+
PenaltyBreakTemplateDeclaration: 10
92+
PenaltyExcessCharacter: 1000000
93+
PenaltyReturnTypeOnItsOwnLine: 60
94+
PointerAlignment: Right
95+
ReflowComments: true
96+
SortIncludes: true
97+
SortUsingDeclarations: true
98+
SpaceAfterCStyleCast: false
99+
SpaceAfterTemplateKeyword: true
100+
SpaceBeforeAssignmentOperators: true
101+
SpaceBeforeCpp11BracedList: false
102+
SpaceBeforeCtorInitializerColon: true
103+
SpaceBeforeInheritanceColon: true
104+
SpaceBeforeParens: ControlStatements
105+
SpaceBeforeRangeBasedForLoopColon: true
106+
SpaceInEmptyParentheses: false
107+
SpacesBeforeTrailingComments: 1
108+
SpacesInAngles: false
109+
SpacesInContainerLiterals: true
110+
SpacesInCStyleCastParentheses: false
111+
SpacesInParentheses: false
112+
SpacesInSquareBrackets: false
113+
Standard: Cpp11
114+
TabWidth: 2
115+
UseTab: Never

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ coverage: test
1313
gcovr -r . -d -e "build" -e "src/test" -e "src/examples" -e "src/stubgenerator/main.cpp" --html --html-details -o reports/coverage.html
1414

1515
format:
16-
find . -name "*.h" -o -name "*.cpp" -exec clang-format -style=LLVM -i {} \;
16+
find src/ -name "*.h" -o -name "*.cpp" -exec clang-format -i {} \;
1717

1818
check-format: format
1919
git diff --exit-code

Diff for: src/catch/CMakeLists.txt

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ project(catch_builder CXX)
33
include(ExternalProject)
44

55
ExternalProject_Add(
6-
catch
7-
PREFIX ${CMAKE_BINARY_DIR}/catch
8-
URL https://github.com/catchorg/Catch2/archive/v2.7.0.tar.gz
9-
URL_HASH SHA1=6df37d5b64a71b840a6a9d8c79c3705aa8a3f56e
10-
CONFIGURE_COMMAND ""
11-
BUILD_COMMAND ""
12-
INSTALL_COMMAND ""
6+
catch
7+
PREFIX ${CMAKE_BINARY_DIR}/catch
8+
URL https://github.com/catchorg/Catch2/archive/v2.7.0.tar.gz
9+
URL_HASH SHA1=6df37d5b64a71b840a6a9d8c79c3705aa8a3f56e
10+
CONFIGURE_COMMAND ""
11+
BUILD_COMMAND ""
12+
INSTALL_COMMAND ""
1313
)
1414

1515
ExternalProject_Get_Property(catch source_dir)

Diff for: src/examples/CMakeLists.txt

+45-45
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/gen)
22

33
add_custom_command(
4-
OUTPUT ${CMAKE_BINARY_DIR}/gen/abstractstubserver.h
5-
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/spec.json --cpp-server=AbstractStubServer --cpp-server-file=${CMAKE_BINARY_DIR}/gen/abstractstubserver.h
6-
MAIN_DEPENDENCY spec.json
7-
DEPENDS jsonrpcstub
8-
COMMENT "Generating Server Stubfiles"
9-
VERBATIM
4+
OUTPUT ${CMAKE_BINARY_DIR}/gen/abstractstubserver.h
5+
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/spec.json --cpp-server=AbstractStubServer --cpp-server-file=${CMAKE_BINARY_DIR}/gen/abstractstubserver.h
6+
MAIN_DEPENDENCY spec.json
7+
DEPENDS jsonrpcstub
8+
COMMENT "Generating Server Stubfiles"
9+
VERBATIM
1010
)
1111

1212
add_custom_command(
13-
OUTPUT ${CMAKE_BINARY_DIR}/gen/stubclient.h
14-
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/spec.json --cpp-client=StubClient --cpp-client-file=${CMAKE_BINARY_DIR}/gen/stubclient.h
15-
MAIN_DEPENDENCY spec.json
16-
DEPENDS jsonrpcstub
17-
COMMENT "Generating Client Stubfile"
18-
VERBATIM
13+
OUTPUT ${CMAKE_BINARY_DIR}/gen/stubclient.h
14+
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/spec.json --cpp-client=StubClient --cpp-client-file=${CMAKE_BINARY_DIR}/gen/stubclient.h
15+
MAIN_DEPENDENCY spec.json
16+
DEPENDS jsonrpcstub
17+
COMMENT "Generating Client Stubfile"
18+
VERBATIM
1919
)
2020

2121
add_custom_target(common_stubs
22-
DEPENDS ${CMAKE_BINARY_DIR}/gen/abstractstubserver.h ${CMAKE_BINARY_DIR}/gen/stubclient.h
23-
)
22+
DEPENDS ${CMAKE_BINARY_DIR}/gen/abstractstubserver.h ${CMAKE_BINARY_DIR}/gen/stubclient.h
23+
)
2424

2525
add_custom_command(
26-
OUTPUT ${CMAKE_BINARY_DIR}/gen/xbmcremote.h
27-
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/xbmc_remote.json --cpp-client=XbmcRemoteClient --cpp-client-file=${CMAKE_BINARY_DIR}/gen/xbmcremote.h
28-
MAIN_DEPENDENCY xbmc_remote.json
29-
DEPENDS jsonrpcstub
30-
COMMENT "Generating Client XBMC Stubfile"
31-
VERBATIM
26+
OUTPUT ${CMAKE_BINARY_DIR}/gen/xbmcremote.h
27+
COMMAND jsonrpcstub ARGS ${CMAKE_CURRENT_SOURCE_DIR}/xbmc_remote.json --cpp-client=XbmcRemoteClient --cpp-client-file=${CMAKE_BINARY_DIR}/gen/xbmcremote.h
28+
MAIN_DEPENDENCY xbmc_remote.json
29+
DEPENDS jsonrpcstub
30+
COMMENT "Generating Client XBMC Stubfile"
31+
VERBATIM
3232
)
3333

3434
include_directories(..)
3535
include_directories(${CMAKE_BINARY_DIR})
3636
include_directories(${MHD_INCLUDE_DIRS})
3737

38-
if(UNIX)
39-
if(UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
38+
if (UNIX)
39+
if (UNIX_DOMAIN_SOCKET_SERVER AND UNIX_DOMAIN_SOCKET_CLIENT)
4040
add_executable(unixdomainsocketserversample unixdomainsocketserver.cpp)
4141
target_link_libraries(unixdomainsocketserversample jsonrpcserver)
4242
add_executable(unixdomainsocketclientsample unixdomainsocketclient.cpp)
4343
target_link_libraries(unixdomainsocketclientsample jsonrpcclient)
44-
endif()
44+
endif ()
4545

46-
if(FILE_DESCRIPTOR_SERVER AND FILE_DESCRIPTOR_CLIENT)
47-
add_executable(filedescriptorserversample filedescriptorserver.cpp)
48-
target_link_libraries(filedescriptorserversample jsonrpcserver)
49-
add_executable(filedescriptorclientsample filedescriptorclient.cpp)
50-
target_link_libraries(filedescriptorclientsample jsonrpcclient)
51-
endif()
52-
endif(UNIX)
46+
if (FILE_DESCRIPTOR_SERVER AND FILE_DESCRIPTOR_CLIENT)
47+
add_executable(filedescriptorserversample filedescriptorserver.cpp)
48+
target_link_libraries(filedescriptorserversample jsonrpcserver)
49+
add_executable(filedescriptorclientsample filedescriptorclient.cpp)
50+
target_link_libraries(filedescriptorclientsample jsonrpcclient)
51+
endif ()
52+
endif (UNIX)
5353

5454
if (TCP_SOCKET_SERVER AND TCP_SOCKET_CLIENT)
5555
add_executable(tcpsocketclient tcpsocketclient.cpp)
5656
target_link_libraries(tcpsocketclient jsonrpcclient)
5757
add_executable(tcpsocketserver tcpsocketserver.cpp)
5858
target_link_libraries(tcpsocketserver jsonrpcserver)
59-
endif()
59+
endif ()
6060

6161
if (SERIAL_PORT_SERVER AND SERIAL_PORT_CLIENT)
6262
add_executable(serialportclient serialportclient.cpp)
6363
target_link_libraries(serialportclient jsonrpcclient)
6464
add_executable(serialportserver serialportserver.cpp)
6565
target_link_libraries(serialportserver jsonrpcserver)
66-
endif()
66+
endif ()
6767

68-
if(HTTP_SERVER)
68+
if (HTTP_SERVER)
6969
add_executable(simpleserversample simpleserver.cpp)
7070
target_link_libraries(simpleserversample jsonrpcserver)
71-
endif()
71+
endif ()
7272

73-
if(HTTP_CLIENT)
73+
if (HTTP_CLIENT)
7474
add_executable(simpleclientsample simpleclient.cpp)
7575
target_link_libraries(simpleclientsample jsonrpcclient)
76-
endif()
76+
endif ()
7777

78-
if(REDIS_SERVER)
78+
if (REDIS_SERVER)
7979
add_executable(redisserversample redisserver.cpp)
8080
target_link_libraries(redisserversample jsonrpcserver)
81-
endif()
81+
endif ()
8282

83-
if(REDIS_CLIENT)
83+
if (REDIS_CLIENT)
8484
add_executable(redisclientsample redisclient.cpp)
8585
target_link_libraries(redisclientsample jsonrpcclient)
86-
endif()
86+
endif ()
8787

8888
if (COMPILE_STUBGEN)
89-
if(HTTP_CLIENT)
89+
if (HTTP_CLIENT)
9090
add_executable(stubclientsample stubclient.cpp ${CMAKE_BINARY_DIR}/gen/stubclient.h)
9191
target_link_libraries(stubclientsample jsonrpcclient)
9292
add_executable(xbmcremote xbmcremote.cpp ${CMAKE_BINARY_DIR}/gen/xbmcremote.h)
9393
target_link_libraries(xbmcremote jsonrpcclient)
94-
endif()
94+
endif ()
9595

96-
if(HTTP_SERVER)
96+
if (HTTP_SERVER)
9797
add_executable(stubserversample stubserver.cpp ${CMAKE_BINARY_DIR}/gen/abstractstubserver.h)
9898
target_link_libraries(stubserversample jsonrpcserver)
99-
endif()
100-
endif()
99+
endif ()
100+
endif ()
101101

Diff for: src/examples/filedescriptorserver.cpp

+4-11
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,13 @@ using namespace std;
4343

4444
class SampleServer : public AbstractServer<SampleServer> {
4545
public:
46-
SampleServer(FileDescriptorServer &server)
47-
: AbstractServer<SampleServer>(server) {
48-
this->bindAndAddMethod(Procedure("sayHello", PARAMS_BY_NAME, JSON_STRING,
49-
"name", JSON_STRING, NULL),
50-
&SampleServer::sayHello);
51-
this->bindAndAddNotification(
52-
Procedure("notifyServer", PARAMS_BY_NAME, NULL),
53-
&SampleServer::notifyServer);
46+
SampleServer(FileDescriptorServer &server) : AbstractServer<SampleServer>(server) {
47+
this->bindAndAddMethod(Procedure("sayHello", PARAMS_BY_NAME, JSON_STRING, "name", JSON_STRING, NULL), &SampleServer::sayHello);
48+
this->bindAndAddNotification(Procedure("notifyServer", PARAMS_BY_NAME, NULL), &SampleServer::notifyServer);
5449
}
5550

5651
// method
57-
void sayHello(const Json::Value &request, Json::Value &response) {
58-
response = "Hello: " + request["name"].asString();
59-
}
52+
void sayHello(const Json::Value &request, Json::Value &response) { response = "Hello: " + request["name"].asString(); }
6053

6154
// notification
6255
void notifyServer(const Json::Value &request) {

Diff for: src/examples/index.html

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
<!DOCTYPE html>
1+
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
5-
<title>Title of the document</title>
6-
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
7-
<!--
8-
This file needs to be generated using jsonrpcstub:
9-
cd build
10-
./bin/jsonrpcstub ../src/examples/spec.json --js-client=StubClient --js-client-file=../src/examples/stubclient.js
11-
-->
12-
<script src="stubclient.js" type="text/javascript"></script>
13-
<script type="text/javascript">
4+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
5+
<title>Title of the document</title>
6+
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
7+
<!--
8+
This file needs to be generated using jsonrpcstub:
9+
cd build
10+
./bin/jsonrpcstub ../src/examples/spec.json --js-client=StubClient --js-client-file=../src/examples/stubclient.js
11+
-->
12+
<script src="stubclient.js" type="text/javascript"></script>
13+
<script type="text/javascript">
1414

15-
$(document).ready(function () {
16-
function showResult(id, result) {
17-
alert("ID: " + id + " Result: " + result);
18-
}
15+
$(document).ready(function () {
16+
function showResult(id, result) {
17+
alert("ID: " + id + " Result: " + result);
18+
}
1919

20-
function showError(code, message) {
21-
alert("Error: " + code + " -> " + message);
22-
}
20+
function showError(code, message) {
21+
alert("Error: " + code + " -> " + message);
22+
}
2323

24-
var client = new StubClient("http://localhost:8383");
24+
var client = new StubClient("http://localhost:8383");
2525

26-
client.sayHello("Peter", showResult, showError);
27-
client.addNumbers(3,4,showResult, showError);
28-
client.isEqual("3","3",showResult,showError);
29-
client.isEqual("3",4,showResult,showError); //invalid params error
30-
client.notifyServer();
31-
});
32-
function displayResult(result) {
33-
alert(JSON.stringify(result));
34-
}
35-
</script>
26+
client.sayHello("Peter", showResult, showError);
27+
client.addNumbers(3, 4, showResult, showError);
28+
client.isEqual("3", "3", showResult, showError);
29+
client.isEqual("3", 4, showResult, showError); //invalid params error
30+
client.notifyServer();
31+
});
32+
33+
function displayResult(result) {
34+
alert(JSON.stringify(result));
35+
}
36+
</script>
3637
</head>
3738
<body>
3839
</body>

0 commit comments

Comments
 (0)