diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 812b8ab5e9fb1e08aaf1723e60651aa4a34a6fc9..5a99725d4a4a6790b5d01ce4276d8276087335d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,7 +69,7 @@ code_style_cpp: tags: [ docker ] stage: test script: - - clang-format-11 --dry-run --verbose --Werror $(find test/ src/ -type f -iname "*.cpp" -o -iname "*.h" -o -iname "*.h.in") + - make style allow_failure: true unit_tests: diff --git a/.miss_hit b/.miss_hit index f15ccfe29ff4a2e193fb4ae51ca5a7bd1cc3a88d..1ec1ed2e3f9ad6a09619d69746c5b79685c6d89f 100644 --- a/.miss_hit +++ b/.miss_hit @@ -2,6 +2,6 @@ # See https://florianschanda.github.io/miss_hit/style_checker.html line_length: 100 -regex_function_name: "[a-z]+(_[a-z]+)*" +regex_function_name: "[_a-z]+(_[a-z]+)*" suppress_rule: "whitespace_comments" tab_width: 2 diff --git a/Makefile b/Makefile index e3d9d8d9070566cf48463b6dc534db354daaff07..4c125fbdf53fed65cd80b4db905e9d77be07e88d 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,15 @@ help: doc: cd doc && $(MAKE) html -.PHONY: style style: - mh_style --fix --octave src doc + # Wait for https://github.com/florianschanda/miss_hit/issues/224 + # mh_style --fix --octave src doc + clang-format-11 --dry-run --verbose --Werror $(shell find test/ src/ -type f -iname "*.cpp" -o -iname "*.hpp" -o -iname "*.h" -o -iname "*.h.in") +.PHONY: style + +style_fix: + clang-format-11 -i --verbose --Werror $(shell find test/ src/ -type f -iname "*.cpp" -o -iname "*.hpp" -o -iname "*.h" -o -iname "*.h.in") +.PHONY: style_fix .PHONY: test test: diff --git a/src/private/_info.cpp b/src/private/_info.cpp index b3eb701b8ceb4044501a482ec4c700f23b5da9be..cdd248f6c32084a70473d3184111531635a377b5 100644 --- a/src/private/_info.cpp +++ b/src/private/_info.cpp @@ -8,16 +8,16 @@ #include <memory> // for unique_ptr, __shared_ptr_access, shar... #include <string> // for allocator, char_traits, operator+ -using std::string; using caosdb::connection::Connection; using caosdb::connection::ConnectionManager; +using std::string; -mxArray* info(const string &connection_name); +mxArray *info(const string &connection_name); /** * The implementation of the info retrieval. */ -mxArray* info(string const &connection_name) { +mxArray *info(string const &connection_name) { std::shared_ptr<Connection> connection = NULL; if (connection_name == "") { connection = ConnectionManager::GetDefaultConnection(); @@ -27,11 +27,11 @@ mxArray* info(string const &connection_name) { const auto &version_info = connection->GetVersionInfo(); const char *keys[] = {"major", "minor", "patch", "pre_release", "build"}; mwSize dims[2] = {1, 1}; - mxArray* info_struct = mxCreateStructArray(2, dims, 5, keys); + mxArray *info_struct = mxCreateStructArray(2, dims, 5, keys); - auto* major = mxSCALAR(UINT64, major, version_info->GetMajor()); - auto* minor = mxSCALAR(UINT64, minor, version_info->GetMinor()); - auto* patch = mxSCALAR(UINT64, patch, version_info->GetPatch()); + auto *major = mxSCALAR(UINT64, major, version_info->GetMajor()); + auto *minor = mxSCALAR(UINT64, minor, version_info->GetMinor()); + auto *patch = mxSCALAR(UINT64, patch, version_info->GetPatch()); mxSetField(info_struct, 0, "major", major); mxSetField(info_struct, 0, "minor", minor); @@ -48,19 +48,18 @@ mxArray* info(string const &connection_name) { * * @details At the moment, this is just the version of the server. * - * @param connection_name A string with the connection name. May be omitted or an empty string. + * @param connection_name A string with the connection name. May be omitted or + * an empty string. * * @return return type */ -void mexFunction(int nlhs, mxArray *plhs[], int nrhs, - const mxArray *prhs[]) { +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { string conn_name(""); - if (nrhs >= 1 && mxGetNumberOfElements(prhs[0]) > 0) { + if (nrhs >= 1 && mxGetNumberOfElements(prhs[0]) > 0) { conn_name = mxGetChars(prhs[0]); } mexPrintf("Connection: >%s< \t %d\n", conn_name.c_str(), nrhs); auto info_struct = info(conn_name); plhs[0] = info_struct; - } diff --git a/src/private/maoxdbUtils.hpp b/src/private/maoxdbUtils.hpp index cb40c578a6609f10b38d45387a970cbf41cf778f..1f68dade79877457f4e7c16aa19a3b031ae76ef2 100644 --- a/src/private/maoxdbUtils.hpp +++ b/src/private/maoxdbUtils.hpp @@ -5,13 +5,13 @@ #include "mexproto.h" /** - * mxSCALAR(type, name, value): Create a 1x1 mxArray of type TYPE and value VALUE. The NAME must be - * unique within each scope. + * mxSCALAR(type, name, value): Create a 1x1 mxArray of type TYPE and value + * VALUE. The NAME must be unique within each scope. * * Use it like so (note that the assignment to NAME is necessary): * * auto* scalar = mxSCALAR(UINT64, scalar, value); - * + * * This will exand to: * * mxCreateNumericMatrix(1, 1, mxUINT64_CLASS, mxREAL); @@ -20,10 +20,10 @@ * mxSetData(scalar, scalar_data); * */ -#define mxSCALAR(type, name, value) \ - mxCreateNumericMatrix(1, 1, mx ## type ## _CLASS, mxREAL); \ - auto * __ ## name ##_data = (type ## _T*) mxGetData(name); \ - __ ## name ## _data[0] = value; \ - mxSetData(name, __ ## name ## _data) +#define mxSCALAR(type, name, value) \ + mxCreateNumericMatrix(1, 1, mx##type##_CLASS, mxREAL); \ + auto *__##name##_data = (type##_T *)mxGetData(name); \ + __##name##_data[0] = value; \ + mxSetData(name, __##name##_data) #endif /* MAOXDBUTILS_H */