From 4fa1be1fb62a32fd9eab42ae848faa543a2a8479 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Thu, 22 Feb 2024 14:38:16 -0500 Subject: [PATCH] clang-format all source files --- src/c2py/converters/numpy_proxy.cpp | 5 +---- src/c2py/serialization/h5.hpp | 4 ++-- test/annote.cpp | 12 +++++------- test/basicfun.cpp | 2 +- test/cls.cpp | 28 +++++++++++----------------- test/cls_basic.cpp | 2 +- test/cls_der.cpp | 4 ++-- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/c2py/converters/numpy_proxy.cpp b/src/c2py/converters/numpy_proxy.cpp index ebd3ca7..5cd374f 100644 --- a/src/c2py/converters/numpy_proxy.cpp +++ b/src/c2py/converters/numpy_proxy.cpp @@ -36,7 +36,7 @@ namespace c2py { PyArray_NewFromDescr(&PyArray_Type, PyArray_DescrFromType(element_type), rank, extents.data(), strides.data(), data, flags, nullptr); //NOLINT if (not result) return nullptr; // the Python error is set - if (!PyArray_Check(result)) { //NOLINT + if (!PyArray_Check(result)) { //NOLINT PyErr_SetString(PyExc_RuntimeError, "The python object is not a numpy array"); return nullptr; } @@ -46,10 +46,7 @@ namespace c2py { arr->base = base; assert(arr->flags == (arr->flags & ~NPY_OWNDATA)); #else - //int r = PyArray_SetBaseObject(arr, base); //NOLINT - //EXPECTS(r == 0); - //EXPECTS(PyArray_FLAGS(arr) == (PyArray_FLAGS(arr) & ~NPY_ARRAY_OWNDATA)); #endif base = nullptr; // ref is stolen by the new object diff --git a/src/c2py/serialization/h5.hpp b/src/c2py/serialization/h5.hpp index 221fcd7..df45ed1 100644 --- a/src/c2py/serialization/h5.hpp +++ b/src/c2py/serialization/h5.hpp @@ -10,8 +10,8 @@ namespace c2py { -// template <> constexpr bool is_wrapped = true; -// template <> constexpr bool is_wrapped = true; + // template <> constexpr bool is_wrapped = true; + // template <> constexpr bool is_wrapped = true; /// hdf5 is not defined for this object, we still but a function + exception for a clear and early error message. template static PyObject *tpxx_write_h5(PyObject *self, PyObject *args) { diff --git a/test/annote.cpp b/test/annote.cpp index c60093a..f142f87 100644 --- a/test/annote.cpp +++ b/test/annote.cpp @@ -8,17 +8,15 @@ // Test the C2PY_WRAP annotation -int f(int i) { return 1;} +int f(int i) { return 1; } -C2PY_WRAP int g(int i) { return 2;} +C2PY_WRAP int g(int i) { return 2; } -struct C2PY_WRAP A { - int k = 12; +struct C2PY_WRAP A { + int k = 12; }; namespace c2py_module { // Filter all by default. constexpr auto reject_names = ".*"; -} - - +} // namespace c2py_module diff --git a/test/basicfun.cpp b/test/basicfun.cpp index fa424a8..79814fd 100644 --- a/test/basicfun.cpp +++ b/test/basicfun.cpp @@ -32,7 +32,7 @@ static_assert(c2py::concepts::IsConvertibleC2Py>); // attribute declaration must precede definition ! Cf clang message if reverse order. C2PY_IGNORE int ignored(int x); int ignored(int x) { return x * 3; } - + using dcomplex = std::complex; namespace N { diff --git a/test/cls.cpp b/test/cls.cpp index 2e15ac4..085d6a7 100644 --- a/test/cls.cpp +++ b/test/cls.cpp @@ -5,7 +5,7 @@ struct A { int k = 12; std::vector v = {1, 2, 3, 5}; - //A() = default; + //A() = default; auto f(int x) { return x * 2; } int f(int x) const { return x * 2; } @@ -13,15 +13,14 @@ struct A { int size() const { return v.size(); } friend int a_friend(A const &a) { return -a.k; } - double tpl(auto x) { return 256 + x;} - - int& operator[](int i) { return v[i]; } + double tpl(auto x) { return 256 + x; } + + int &operator[](int i) { return v[i]; } int operator[](int i) const { return v[i]; } + int operator()(int i) { return k + i; } + int operator()(int i, int j) const { return k + i + 10 * j; } - int operator()(int i) { return k + i;} - int operator()(int i, int j) const { return k + i + 10*j;} - bool operator==(A const &) const = default; int get_prop() const { return k; } @@ -31,8 +30,8 @@ struct A { auto end() const { return std::end(v); } template void serialize(Ar &ar, int) { - ar &k; - ar &v; + ar & k; + ar & v; } }; @@ -50,12 +49,7 @@ A maker_A(int i) { return A{i}; } - -//void describe_operations(A a, A b, int s) { - //A{a + b}; - //A{a - b}; +//void describe_operations(A a, A b, int s) { +//A{a + b}; +//A{a - b}; //}; - - - - diff --git a/test/cls_basic.cpp b/test/cls_basic.cpp index ffb3385..a5be65c 100644 --- a/test/cls_basic.cpp +++ b/test/cls_basic.cpp @@ -37,7 +37,7 @@ struct A { void no_prop() { k *= 10; } - static int static_method(int i) { return -i;} + static int static_method(int i) { return -i; } //C2PY_PROPERTY("p") //int get_prop() const { return k; } diff --git a/test/cls_der.cpp b/test/cls_der.cpp index 54bad52..dc90fa2 100644 --- a/test/cls_der.cpp +++ b/test/cls_der.cpp @@ -5,10 +5,10 @@ struct B { int ib = 12; int b(int u) { return u + 2; } - B(int i): ib(i) {} + B(int i) : ib(i) {} }; struct A : B { - A(int i): B(i) {} + A(int i) : B(i) {} int a(int i, int j) { return i + j; } };