Skip to content

Commit

Permalink
clang-format all source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Wentzell committed Feb 22, 2024
1 parent 49e88c3 commit 4fa1be1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
5 changes: 1 addition & 4 deletions src/c2py/converters/numpy_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/c2py/serialization/h5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

namespace c2py {

// template <> constexpr bool is_wrapped<h5::group> = true;
// template <> constexpr bool is_wrapped<h5::file> = true;
// template <> constexpr bool is_wrapped<h5::group> = true;
// template <> constexpr bool is_wrapped<h5::file> = true;

/// hdf5 is not defined for this object, we still but a function + exception for a clear and early error message.
template <typename Cls> static PyObject *tpxx_write_h5(PyObject *self, PyObject *args) {
Expand Down
12 changes: 5 additions & 7 deletions test/annote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/basicfun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static_assert(c2py::concepts::IsConvertibleC2Py<std::pair<return_t, double>>);
// 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<double>;

namespace N {
Expand Down
28 changes: 11 additions & 17 deletions test/cls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ struct A {
int k = 12;
std::vector<int> v = {1, 2, 3, 5};

//A() = default;
//A() = default;

auto f(int x) { return x * 2; }
int f(int x) const { return x * 2; }

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; }
Expand All @@ -31,8 +30,8 @@ struct A {
auto end() const { return std::end(v); }

template <typename Ar> void serialize(Ar &ar, int) {
ar &k;
ar &v;
ar & k;
ar & v;
}
};

Expand All @@ -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};
//};




2 changes: 1 addition & 1 deletion test/cls_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
4 changes: 2 additions & 2 deletions test/cls_der.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
};

0 comments on commit 4fa1be1

Please sign in to comment.