Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce C++ formatting for ThemisPP #404

Merged
merged 2 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
Checks: 'readability-*'
Checks: 'readability-*,-readability-implicit-bool-conversion'
FormatStyle: none
...
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,17 @@ $(OBJ_PATH)/%.fmt_check: $(SRC_PATH)/%
@echo -n "check $< "
@$(BUILD_CMD_)

THEMISPP_HEADERS = $(wildcard $(SRC_PATH)/wrappers/themis/themispp/*.hpp)

FMT_FIXUP += $(patsubst $(SRC_PATH)/%,$(OBJ_PATH)/%.fmt_fixup,$(THEMISPP_HEADERS))
FMT_CHECK += $(patsubst $(SRC_PATH)/%,$(OBJ_PATH)/%.fmt_check,$(THEMISPP_HEADERS))

$(OBJ_PATH)/%.hpp.fmt_fixup: \
CMD = $(CLANG_TIDY) -fix $< -- $(CFLAGS) 2>/dev/null && $(CLANG_FORMAT) -i $< && touch $@

$(OBJ_PATH)/%.hpp.fmt_check: \
CMD = $(CLANG_FORMAT) $< | diff -u $< - && $(CLANG_TIDY) $< -- $(CFLAGS) 2>/dev/null && touch $@

#$(AUD_PATH)/%: CMD = $(CC) $(CFLAGS) -E -dI -dD $< -o $@
$(AUD_PATH)/%: CMD = ./scripts/pp.sh $< $@

Expand Down
19 changes: 19 additions & 0 deletions src/wrappers/themis/themispp/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
BasedOnStyle: LLVM
AccessModifierOffset: -4
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Linux
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
IndentWidth: 4
ObjCSpaceAfterProperty: true
PointerAlignment: Left
TabWidth: 8
UseTab: Never
...
65 changes: 36 additions & 29 deletions src/wrappers/themis/themispp/exception.hpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,53 @@
/*
* Copyright (c) 2015 Cossack Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2015 Cossack Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef THEMISPP_EXCEPTION_HPP_
#define THEMISPP_EXCEPTION_HPP_

#include <stdexcept>

#include <themis/themis.h>

namespace themispp{
class exception_t: public std::runtime_error
{
public:
namespace themispp
{

class exception_t : public std::runtime_error
{
public:
explicit exception_t(const char* what)
: std::runtime_error(what)
, status_(THEMIS_INVALID_PARAMETER)
{}
: std::runtime_error(what)
, status_(THEMIS_INVALID_PARAMETER)
{
}

exception_t(const char* what, ::themis_status_t status)
: std::runtime_error(what)
, status_(status)
{}
: std::runtime_error(what)
, status_(status)
{
}

::themis_status_t status() const {
return status_;
::themis_status_t status() const
{
return status_;
}

private:
private:
::themis_status_t status_;
};
}//themispp ns
};

} // namespace themispp

#endif
Loading