diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..23f0d05 --- /dev/null +++ b/.clang-format @@ -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 +... + diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c29b7..304ce41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} +) diff --git a/src/cpp/lua-module.cpp b/src/cpp/lua-module.cpp index 64739bd..15a08d7 100644 --- a/src/cpp/lua-module.cpp +++ b/src/cpp/lua-module.cpp @@ -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; diff --git a/src/cpp/shared-table.cpp b/src/cpp/shared-table.cpp index 8728497..dc997dc 100644 --- a/src/cpp/shared-table.cpp +++ b/src/cpp/shared-table.cpp @@ -19,12 +19,12 @@ SharedTable::SharedTable(const SharedTable& init) sol::object SharedTable::getUserType(sol::state_view &lua) { static sol::usertype 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(lua); diff --git a/src/cpp/threading.cpp b/src/cpp/threading.cpp index 83b1f7b..c9b4e63 100644 --- a/src/cpp/threading.cpp +++ b/src/cpp/threading.cpp @@ -167,11 +167,11 @@ std::string LuaThread::status() const sol::object LuaThread::getUserType(sol::state_view &lua) { static sol::usertype 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& value) sol::object ThreadFactory::getUserType(sol::state_view &lua) { static sol::usertype 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(lua); diff --git a/src/cpp/threading.h b/src/cpp/threading.h index 7c0d28b..7395a29 100644 --- a/src/cpp/threading.h +++ b/src/cpp/threading.h @@ -16,7 +16,7 @@ void sleep(int64_t, sol::optional); class LuaThread { public: enum class ThreadStatus { - Running, + Running = 1, Paused, Canceled, Completed,