From 2b6a018716410a20765c6c94a77adff338ae1d42 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Tue, 20 Feb 2024 17:58:51 -0500 Subject: [PATCH] clang-format all source files --- doc/api.cpp | 36 +++++++++++++++---------------- doc/examples/cmake1/my_module.cpp | 8 +++---- doc/examples/cmake2/my_module.cpp | 8 +++---- doc/examples/cmake3/my_module.cpp | 7 +++--- doc/examples/config_dispatch.cpp | 20 ++++++++--------- doc/examples/config_misc.cpp | 2 +- doc/examples/config_using.cpp | 19 +++++++--------- doc/examples/fail.cpp | 9 ++------ doc/examples/filter.cpp | 20 ++++++++--------- doc/examples/fun1.cpp | 2 -- doc/examples/fun2.cpp | 4 +--- doc/examples/gs1.cpp | 2 +- doc/examples/struct1.cpp | 9 ++++---- src/clu/fullqualifiedname.cpp | 2 +- 14 files changed, 64 insertions(+), 84 deletions(-) diff --git a/doc/api.cpp b/doc/api.cpp index 6b889ca..7fac201 100644 --- a/doc/api.cpp +++ b/doc/api.cpp @@ -69,13 +69,12 @@ namespace c2py_module { // ---------- Properties ---------------- auto prop1 = c2py::property; - // - // Or tag a getter function with - // C2PY_PROPERTY + // + // Or tag a getter function with + // C2PY_PROPERTY // C2PY_PROPERTY_SET(NAME) - // + // // getter_as_properties = "regex"; // for all classes matching the regex, the method () returning non void are transformed into a property - // ---------------------------------------------------------- // List of struct/classes to be wrapped, in addition the ones automatically detected @@ -87,24 +86,23 @@ namespace c2py_module { // .e.g ... using A = N::A; using Bi = N::B; - - } // namespace add - /// Additional methods to add to the Python class - /// e.g. method template instantiation, or new injected function h - template <> struct add_methods_to { - // NB : for some obscure reason, C++ requires the & for a template method, but it can be omitted for regular functions - static constexpr auto h = c2py::dispatch<&N::A::h, N::h>; + } // namespace add - // A static method. - // TODO : implement and test - static constexpr auto h1 = c2py::dispatch_static<&N::A::h, N::h>; - }; + /// Additional methods to add to the Python class + /// e.g. method template instantiation, or new injected function h + template <> struct add_methods_to { + // NB : for some obscure reason, C++ requires the & for a template method, but it can be omitted for regular functions + static constexpr auto h = c2py::dispatch<&N::A::h, N::h>; - // Note. One can also make a derived struct in C++ - // with the additional methods, and wrap it, merging the parent methods by blacklisting the parent. - // TODO : improve the test/example + // A static method. + // TODO : implement and test + static constexpr auto h1 = c2py::dispatch_static<&N::A::h, N::h>; + }; + // Note. One can also make a derived struct in C++ + // with the additional methods, and wrap it, merging the parent methods by blacklisting the parent. + // TODO : improve the test/example // ---------------------------------------------------------- // Arithmetic diff --git a/doc/examples/cmake1/my_module.cpp b/doc/examples/cmake1/my_module.cpp index 7e5b6f1..4c67e5f 100644 --- a/doc/examples/cmake1/my_module.cpp +++ b/doc/examples/cmake1/my_module.cpp @@ -3,10 +3,10 @@ #include "c2py/c2py.hpp" /// A wonderful little class -class my_class{ +class my_class { int a, b; + public: - my_class(int a_, int b_) : a(a_), b(b_) {} - int f(int u) const { return u + a;} + my_class(int a_, int b_) : a(a_), b(b_) {} + int f(int u) const { return u + a; } }; - diff --git a/doc/examples/cmake2/my_module.cpp b/doc/examples/cmake2/my_module.cpp index 9d76e82..b571c4c 100644 --- a/doc/examples/cmake2/my_module.cpp +++ b/doc/examples/cmake2/my_module.cpp @@ -1,10 +1,10 @@ #include "c2py/c2py.hpp" /// A wonderful little class -class my_class{ +class my_class { int a, b; + public: - my_class(int a_, int b_) : a(a_), b(b_) {} - int f(int u) const { return u + a;} + my_class(int a_, int b_) : a(a_), b(b_) {} + int f(int u) const { return u + a; } }; - diff --git a/doc/examples/cmake3/my_module.cpp b/doc/examples/cmake3/my_module.cpp index ce2d205..81fa48d 100644 --- a/doc/examples/cmake3/my_module.cpp +++ b/doc/examples/cmake3/my_module.cpp @@ -1,12 +1,11 @@ #include "c2py/c2py.hpp" /// A wonderful little class -class my_class{ +class my_class { int a, b; public: - my_class(int a_, int b_) : a(a_), b(b_) {} + my_class(int a_, int b_) : a(a_), b(b_) {} - int f(int u) const { return u + a;} + int f(int u) const { return u + a; } }; - diff --git a/doc/examples/config_dispatch.cpp b/doc/examples/config_dispatch.cpp index 324ef1c..60306c0 100644 --- a/doc/examples/config_dispatch.cpp +++ b/doc/examples/config_dispatch.cpp @@ -1,13 +1,11 @@ #include -int f(auto x) { return 1;} // a generic (template) function - -namespace c2py_module { - // ... - namespace add { - // function f in python dispatching the 2 instantiations. - auto f = c2py::dispatch<::f, ::f>; - } -} - - +int f(auto x) { return 1; } // a generic (template) function + +namespace c2py_module { + // ... + namespace add { + // function f in python dispatching the 2 instantiations. + auto f = c2py::dispatch<::f, ::f>; + } // namespace add +} // namespace c2py_module diff --git a/doc/examples/config_misc.cpp b/doc/examples/config_misc.cpp index 1e92619..335bd64 100644 --- a/doc/examples/config_misc.cpp +++ b/doc/examples/config_misc.cpp @@ -10,4 +10,4 @@ namespace c2py_module { // Signature must be () -> void auto module_init = []() {}; -} +} // namespace c2py_module diff --git a/doc/examples/config_using.cpp b/doc/examples/config_using.cpp index 5d358c2..eaa1730 100644 --- a/doc/examples/config_using.cpp +++ b/doc/examples/config_using.cpp @@ -1,16 +1,13 @@ #include -template -struct A { +template struct A { T x; }; -namespace c2py_module { - // ... - namespace add { - using Ai = A; - using Ad = A; - } -} - - +namespace c2py_module { + // ... + namespace add { + using Ai = A; + using Ad = A; + } // namespace add +} // namespace c2py_module diff --git a/doc/examples/fail.cpp b/doc/examples/fail.cpp index 649ad5f..5de6d66 100644 --- a/doc/examples/fail.cpp +++ b/doc/examples/fail.cpp @@ -1,10 +1,5 @@ #include +double *make_raw_pointer(long size) { return new double[size]; } -double * make_raw_pointer(long size) { return new double[size];} - - -void f(FILE * x){} - - - +void f(FILE *x) {} diff --git a/doc/examples/filter.cpp b/doc/examples/filter.cpp index b189e2a..dba1541 100644 --- a/doc/examples/filter.cpp +++ b/doc/examples/filter.cpp @@ -1,22 +1,20 @@ #include -int g() { return 8;} +int g() { return 8; } -namespace N { - int f(int x) { return -x;} +namespace N { + int f(int x) { return -x; } - struct a_class{ + struct a_class { // ... }; - - struct hidden{ + + struct hidden { //... }; -} +} // namespace N namespace c2py_module { - auto match_names = "N::.*"; // match functions and names in namespace N + auto match_names = "N::.*"; // match functions and names in namespace N auto reject_names = "N::hidden"; // reject the specific name "hidden" in namespace N -} - - +} // namespace c2py_module diff --git a/doc/examples/fun1.cpp b/doc/examples/fun1.cpp index 0873981..c83d6ca 100644 --- a/doc/examples/fun1.cpp +++ b/doc/examples/fun1.cpp @@ -5,5 +5,3 @@ struct A { double x; std::string s; }; - - diff --git a/doc/examples/fun2.cpp b/doc/examples/fun2.cpp index baae1e1..4134431 100644 --- a/doc/examples/fun2.cpp +++ b/doc/examples/fun2.cpp @@ -4,6 +4,4 @@ #include #include -double sum(std::vector const & v){ return std::accumulate(begin(v), end(v), 0.0);} - - +double sum(std::vector const &v) { return std::accumulate(begin(v), end(v), 0.0); } diff --git a/doc/examples/gs1.cpp b/doc/examples/gs1.cpp index 7b39aab..82e4f0b 100644 --- a/doc/examples/gs1.cpp +++ b/doc/examples/gs1.cpp @@ -8,4 +8,4 @@ * @param y Second value * @return The result */ -int add(int x, int y) { return x + y;} +int add(int x, int y) { return x + y; } diff --git a/doc/examples/struct1.cpp b/doc/examples/struct1.cpp index fd4af09..c315d45 100644 --- a/doc/examples/struct1.cpp +++ b/doc/examples/struct1.cpp @@ -5,14 +5,13 @@ struct S { int i; - S(int i):i{i}{} + S(int i) : i{i} {} - int m() const { return i+2;} + int m() const { return i + 2; } }; // A function using S -int f(S const & s){ return s.i;} +int f(S const &s) { return s.i; } // make S printable in C++ -std::ostream & operator<<(std::ostream &out, S const & s) {return out << "S struct with i=" << s.i << '\n';} - +std::ostream &operator<<(std::ostream &out, S const &s) { return out << "S struct with i=" << s.i << '\n'; } diff --git a/src/clu/fullqualifiedname.cpp b/src/clu/fullqualifiedname.cpp index 6363c93..567bc03 100644 --- a/src/clu/fullqualifiedname.cpp +++ b/src/clu/fullqualifiedname.cpp @@ -45,7 +45,7 @@ namespace clu { llvm::raw_string_ostream out(res); targ.print(policy, out, true); return out.str(); - }; // end lambda + }; // end lambda return (t.isConstQualified() ? "const " : "") // const or not + spe->getTemplateName().getAsTemplateDecl()->getQualifiedNameAsString() // template name, qualified