Skip to content

Commit

Permalink
Clang format and manual style fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
saschazelzer committed Aug 2, 2018
1 parent b126bb4 commit f60fa67
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 37 deletions.
39 changes: 6 additions & 33 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,36 +1,9 @@
---
BasedOnStyle: WebKit
Cpp11BracedListStyle: 'true'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
Language: Cpp
SpacesInAngles: 'false'
TabWidth: '2'
UseTab: Never
SortIncludes: false
PointerAlignment: Left
AlignAfterOpenBracket: DontAlign
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterEnum: true
AfterStruct: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
AfterControlStatement: true
IndentWidth: 2
AccessModifierOffset: -2
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
SpaceBeforeParens: ControlStatements
ConstructorInitializerIndentWidth: 2
ColumnLimit: 90
BasedOnStyle: Mozilla

# Reflowing comments interfers with .rst identation
ReflowComments: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
IndentPPDirectives: AfterHash
...
3 changes: 3 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Fork the repository and make changes on your fork in a feature branch:
your intentions, and name it ``XXXX-something`` where XXXX is the number
of the issue.

Code must be formatted according to our ```.clang-format``` file, using
the clang-format tool.

Submit unit tests for your changes.

Update the documentation when creating or modifying features. Test your
Expand Down
3 changes: 3 additions & 0 deletions doc/src/tutorial/driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
// clang-format off
// Do not re-order include directives, it would break MinGW builds.
#include <windows.h>
#include <strsafe.h>
// clang-format on
#else
#error Unsupported platform
#endif
Expand Down
2 changes: 2 additions & 0 deletions format_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
find . -type d -name third_party -prune -o -name '*.cpp' -o -name '*.h' | xargs clang-format -i -style=file
2 changes: 1 addition & 1 deletion framework/doc/snippets/uServices-registration/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MyServiceFactory : public ServiceFactory
{
virtual InterfaceMapConstPtr GetService(const Bundle& /*bundle*/, const ServiceRegistrationBase& /*registration*/)
{
return MakeInterfaceMap<InterfaceA>(std::make_shared<MyService>());;
return MakeInterfaceMap<InterfaceA>(std::make_shared<MyService>());
}

virtual void UngetService(const Bundle& /*bundle*/, const ServiceRegistrationBase& /*registration*/,
Expand Down
3 changes: 2 additions & 1 deletion framework/include/cppmicroservices/BundleEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <iostream>
#include <memory>

US_MSVC_PUSH_DISABLE_WARNING(4251) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
// 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
US_MSVC_PUSH_DISABLE_WARNING(4251)

namespace cppmicroservices {

Expand Down
7 changes: 5 additions & 2 deletions framework/src/util/SharedLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <strsafe.h>
// clang-format off
// Do not re-order include directives, it would break MinGW builds.
# include <windows.h>
# include <strsafe.h>
// clang-format on
#else
#error Unsupported platform
#endif
Expand Down
2 changes: 2 additions & 0 deletions framework/test/driver/ResourceCompilerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ int runExecutable(const std::string& executable)
int ret = std::system(executable.c_str());

// WEXITSTATUS uses an old c-sytle cast
// clang-format off
US_GCC_PUSH_DISABLE_WARNING(old-style-cast)
// clang-format on
return WEXITSTATUS(ret);
US_GCC_POP_WARNING
}
Expand Down
3 changes: 3 additions & 0 deletions tools/shell/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

#include "linenoise.h"

// clang-format off
US_GCC_PUSH_DISABLE_WARNING(array-bounds)
// clang-format on

#include "optionparser.h"
US_GCC_POP_WARNING

Expand Down

0 comments on commit f60fa67

Please sign in to comment.