Unverified Commit e96221be authored by Ralf W. Grosse-Kunstleve's avatar Ralf W. Grosse-Kunstleve Committed by GitHub
Browse files

Final manual curation in preparation for global `clang-format`ing (#3712)

* Manual line breaks to pre-empt undesired `clang-format`ing.

Informed by work under https://github.com/pybind/pybind11/pull/3683:

https://github.com/pybind/pybind11/commit/60b7eb410fefe2b23aeb6906f2a9184e91b11a15

https://github.com/pybind/pybind11/commit/59572e65598b4b9f2c9ae0b8a0e5fcb6d65c7f92

* Manual curation of clang-format diffs involving source code comments.

Very labor-intensive and dull.

* Pulling .clang-format change from @henryiii's https://github.com/pybind/pybind11/pull/3683/commits/9057962d40ca520b9d26abbe0ff125796e2323dd



* Adding commonly used .clang-format `CommentPragmas:`

* Ensure short lambdas are allowed
Co-authored-by: default avatarAaron Gokaslan <skylion.aaron@gmail.com>
parent d6c66d25
......@@ -370,9 +370,12 @@ TEST_SUBMODULE(virtual_functions, m) {
public:
using OverrideTest::OverrideTest;
std::string str_value() override { PYBIND11_OVERRIDE(std::string, OverrideTest, str_value); }
// Not allowed (uncommenting should hit a static_assert failure): we can't get a reference
// to a python numeric value, since we only copy values in the numeric type caster:
// std::string &str_ref() override { PYBIND11_OVERRIDE(std::string &, OverrideTest, str_ref); }
// Not allowed (enabling the below should hit a static_assert failure): we can't get a
// reference to a python numeric value, since we only copy values in the numeric type
// caster:
#ifdef PYBIND11_NEVER_DEFINED_EVER
std::string &str_ref() override { PYBIND11_OVERRIDE(std::string &, OverrideTest, str_ref); }
#endif
// But we can work around it like this:
private:
std::string _tmp;
......@@ -389,7 +392,9 @@ TEST_SUBMODULE(virtual_functions, m) {
py::class_<OverrideTest, PyOverrideTest>(m, "OverrideTest")
.def(py::init<const std::string &>())
.def("str_value", &OverrideTest::str_value)
// .def("str_ref", &OverrideTest::str_ref)
#ifdef PYBIND11_NEVER_DEFINED_EVER
.def("str_ref", &OverrideTest::str_ref)
#endif
.def("A_value", &OverrideTest::A_value)
.def("A_ref", &OverrideTest::A_ref);
......@@ -492,11 +497,11 @@ public:
// Inheritance approach 2: templated trampoline classes.
//
// Advantages:
// - we have only 2 (template) class and 4 method declarations (one per virtual method, plus one for
// any override of a pure virtual method), versus 4 classes and 6 methods (MI) or 4 classes and 11
// methods (repeat).
// - Compared to MI, we also don't have to change the non-trampoline inheritance to virtual, and can
// properly inherit constructors.
// - we have only 2 (template) class and 4 method declarations (one per virtual method, plus one
// for any override of a pure virtual method), versus 4 classes and 6 methods (MI) or 4 classes
// and 11 methods (repeat).
// - Compared to MI, we also don't have to change the non-trampoline inheritance to virtual, and
// can properly inherit constructors.
//
// Disadvantage:
// - the compiler must still generate and compile 14 different methods (more, even, than the 11
......@@ -518,8 +523,8 @@ public:
int unlucky_number() override { PYBIND11_OVERRIDE(int, Base, unlucky_number, ); }
double lucky_number() override { PYBIND11_OVERRIDE(double, Base, lucky_number, ); }
};
// Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these (we can
// use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):
// Since C_Tpl and D_Tpl don't declare any new virtual methods, we don't actually need these
// (we can use PyB_Tpl<C_Tpl> and PyB_Tpl<D_Tpl> for the trampoline classes instead):
/*
template <class Base = C_Tpl> class PyC_Tpl : public PyB_Tpl<Base> {
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment