Skip to content

Commit

Permalink
[binder] Release version 1.2.7 reverting operator<< breaking changes.
Browse files Browse the repository at this point in the history
Revert "using fully qualified insertion operator name when binding `__str__` (fixing RosettaCommons#236)"

This reverts commit 7b47e78.
  • Loading branch information
hogabrie committed Oct 25, 2022
1 parent b96cac9 commit 5c2f8e8
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion source/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ std::string ClassBinder::bind_repr(Context &context, Config const &config)
if( FunctionDecl const *F = context.global_insertion_operator(C) ) {
// outs() << "Found insertion operator for: " << class_qualified_name(C) << "\n";

c += "\n\tcl.def(\"__str__\", []({} const &o) -> std::string {{ std::ostringstream s; {}(s, o); return s.str(); }} );\n"_format(qualified_name, F->getQualifiedNameAsString());
c += "\n\tcl.def(\"__str__\", []({} const &o) -> std::string {{ std::ostringstream s; s << o; return s.str(); }} );\n"_format(qualified_name);

prefix_includes_.push_back(F);
}
Expand Down
4 changes: 2 additions & 2 deletions test/T12.operator.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void bind_T12_operator(std::function< pybind11::module &(std::string const &name
cl.def("__add__", (struct T & (T::*)(int)) &T::operator+, "C++: T::operator+(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__sub__", (struct T & (T::*)(int)) &T::operator-, "C++: T::operator-(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__mul__", (struct T & (T::*)(int)) &T::operator*, "C++: T::operator*(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__truediv__", (struct T & (T::*)(int)) &T::operator/, "C++: T::operator/(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__div__", (struct T & (T::*)(int)) &T::operator/, "C++: T::operator/(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__mod__", (struct T & (T::*)(int)) &T::operator%, "C++: T::operator%(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__or__", (struct T & (T::*)(int)) &T::operator|, "C++: T::operator|(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
cl.def("__and__", (struct T & (T::*)(int)) &T::operator&, "C++: T::operator&(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg(""));
Expand All @@ -35,7 +35,7 @@ void bind_T12_operator(std::function< pybind11::module &(std::string const &name
cl.def("__iadd__", (void (T::*)(int)) &T::operator+=, "C++: T::operator+=(int) --> void", pybind11::arg(""));
cl.def("__isub__", (void (T::*)(int)) &T::operator-=, "C++: T::operator-=(int) --> void", pybind11::arg(""));
cl.def("__imul__", (void (T::*)(int)) &T::operator*=, "C++: T::operator*=(int) --> void", pybind11::arg(""));
cl.def("__itruediv__", (void (T::*)(int)) &T::operator/=, "C++: T::operator/=(int) --> void", pybind11::arg(""));
cl.def("__idiv__", (void (T::*)(int)) &T::operator/=, "C++: T::operator/=(int) --> void", pybind11::arg(""));
cl.def("__imod__", (void (T::*)(int)) &T::operator%=, "C++: T::operator%=(int) --> void", pybind11::arg(""));
cl.def("__ior__", (void (T::*)(int)) &T::operator|=, "C++: T::operator|=(int) --> void", pybind11::arg(""));
cl.def("__iand__", (void (T::*)(int)) &T::operator&=, "C++: T::operator&=(int) --> void", pybind11::arg(""));
Expand Down
1 change: 0 additions & 1 deletion test/T31.include_for_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@

#include <T31.include_for_class.incl.a.include>
#include <T31.include_for_class.incl.b.include>
#include <T31.include_for_class.incl.c.include>
13 changes: 0 additions & 13 deletions test/T31.include_for_class.incl.c.include

This file was deleted.

8 changes: 0 additions & 8 deletions test/T31.include_for_class.ref
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// File: T31_include_for_class_incl_a_include.cpp
#include <T31.include_for_class.incl.a.include> // aaaa::A
#include <T31.include_for_class.incl.c.include> // aaaa::cccc::operator<<
#include <ios> // std::_Ios_Seekdir
#include <locale> // std::locale
#include <ostream> // std::basic_ostream
#include <sstream> // __str__
#include <streambuf> // std::basic_streambuf
#include <string> // std::char_traits

#include <functional>
#include <pybind11/pybind11.h>
Expand All @@ -24,8 +18,6 @@ void bind_T31_include_for_class_incl_a_include(std::function< pybind11::module &
{ // aaaa::A file:T31.include_for_class.incl.a.include line:6
pybind11::class_<aaaa::A, std::shared_ptr<aaaa::A>> cl(M("aaaa"), "A", "");
cl.def( pybind11::init( [](){ return new aaaa::A(); } ) );

cl.def("__str__", [](aaaa::A const &o) -> std::string { std::ostringstream s; aaaa::cccc::operator<<(s, o); return s.str(); } );
}
}

Expand Down

0 comments on commit 5c2f8e8

Please sign in to comment.