Merge pull request #26 from loud-hound/clang-format

Add clang-format
This commit is contained in:
Ilia 2017-02-18 14:02:00 +03:00 committed by GitHub
commit 78f2306657
6 changed files with 119 additions and 23 deletions

89
.clang-format Normal file
View File

@ -0,0 +1,89 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
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
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
...

View File

@ -46,3 +46,10 @@ set_target_properties(tests PROPERTIES COMPILE_FLAGS "${ENABLE_WARNINGS} ${GENER
install(FILES ${LUA_SOURCES} ${LUA_TEST_SOURCES}
DESTINATION ${CMAKE_BINARY_DIR}
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)
#----------
# FORMAT -
#----------
add_custom_target( format
COMMAND clang-format -i ${TEST_SOURCES} ${SOURCES}
)

View File

@ -24,11 +24,11 @@ extern "C" int luaopen_libeffil(lua_State *L) {
SharedTable::getUserType(lua);
ThreadFactory::getUserType(lua);
sol::table public_api = lua.create_table_with(
"thread", createThreadFactory,
"thread_id", threadId,
"sleep", sleep,
"yield", yield,
"share", createShare
"thread", createThreadFactory, //
"thread_id", threadId, //
"sleep", sleep, //
"yield", yield, //
"share", createShare //
);
sol::stack::push(lua, public_api);
return 1;

View File

@ -19,12 +19,12 @@ SharedTable::SharedTable(const SharedTable& init)
sol::object SharedTable::getUserType(sol::state_view &lua) {
static sol::usertype<SharedTable> type(
"new", sol::no_constructor,
sol::meta_function::new_index, &SharedTable::luaSet,
sol::meta_function::index, &SharedTable::luaGet,
sol::meta_function::length, &SharedTable::length,
"__pairs", &SharedTable::pairs,
"__ipairs", &SharedTable::ipairs
"new", sol::no_constructor, //
sol::meta_function::new_index, &SharedTable::luaSet,//
sol::meta_function::index, &SharedTable::luaGet,//
sol::meta_function::length, &SharedTable::length,//
"__pairs", &SharedTable::pairs, //
"__ipairs", &SharedTable::ipairs //
);
sol::stack::push(lua, type);
return sol::stack::pop<sol::object>(lua);

View File

@ -167,11 +167,11 @@ std::string LuaThread::status() const
sol::object LuaThread::getUserType(sol::state_view &lua)
{
static sol::usertype<LuaThread> type(
"new", sol::no_constructor,
"cancel", &LuaThread::cancel,
"pause", &LuaThread::pause,
"resume", &LuaThread::resume,
"status", &LuaThread::status,
"new", sol::no_constructor, //
"cancel", &LuaThread::cancel, //
"pause", &LuaThread::pause, //
"resume", &LuaThread::resume, //
"status", &LuaThread::status, //
"wait", &LuaThread::wait
);
sol::stack::push(lua, type);
@ -248,12 +248,12 @@ std::string ThreadFactory::packageCPath(const sol::optional<std::string>& value)
sol::object ThreadFactory::getUserType(sol::state_view &lua)
{
static sol::usertype<ThreadFactory> type(
"new", sol::no_constructor,
sol::meta_function::call, &ThreadFactory::runThread,
"stepwise", &ThreadFactory::stepwise,
"step", &ThreadFactory::step,
"package_path", &ThreadFactory::packagePath,
"package_cpath", &ThreadFactory::packageCPath
"new", sol::no_constructor, //
sol::meta_function::call, &ThreadFactory::runThread,//
"stepwise", &ThreadFactory::stepwise, //
"step", &ThreadFactory::step, //
"package_path", &ThreadFactory::packagePath, //
"package_cpath", &ThreadFactory::packageCPath //
);
sol::stack::push(lua, type);
return sol::stack::pop<sol::object>(lua);

View File

@ -16,7 +16,7 @@ void sleep(int64_t, sol::optional<std::string>);
class LuaThread {
public:
enum class ThreadStatus {
Running,
Running = 1,
Paused,
Canceled,
Completed,