static/source/embindmaker/embindmaker.cxx | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
New commits: commit d95f6eee059a76f91cd51c2850849fe4484b1ae2 Author: Stephan Bergmann <stephan.bergm...@collabora.com> AuthorDate: Tue Jul 29 22:46:32 2025 +0200 Commit: Michael Stahl <michael.st...@collabora.com> CommitDate: Wed Jul 30 12:11:49 2025 +0200 Emscripten: Use unique_ptr for any and sequence values returned from JS to C++ ...improving the code introduced in 04658a706757dabbedfd87717e6f1f354b4c8961 "Embind: Fix lifecycle of UNO any and sequence values returned from JS to C++" and 4b80b643c142d3e5c9e47c091c95155246d6d0e3 "Embind: Add the lifecylce fix also for attribute getter return value" (and which had started to cause compilation failures with Emscripten 4.0.11, see <https://github.com/emscripten-core/emscripten/issues/24801> "'[emval] Prevent creating lvalue refs from thin air (#24606)' breaks existing code") Change-Id: I1af74be31bfde2e5fa09c1690e23a4c9cc941bc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188560 Reviewed-by: Stephan Bergmann <stephan.bergm...@collabora.com> Tested-by: Jenkins (cherry picked from commit 271343a4bab926a9807d7b6ae0760b00e0354ebe) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188574 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Stahl <michael.st...@collabora.com> diff --git a/static/source/embindmaker/embindmaker.cxx b/static/source/embindmaker/embindmaker.cxx index 4956376bed16..fab555cbc52e 100644 --- a/static/source/embindmaker/embindmaker.cxx +++ b/static/source/embindmaker/embindmaker.cxx @@ -795,15 +795,9 @@ void dumpWrapperClassMembers(std::ostream& out, rtl::Reference<TypeManager> cons out << " get" << attr.name << "() override {"; if (attr.type == "any" || attr.type.startsWith("[]")) { - out << " " - " auto & the_ptr = call<"; + out << " return *call<std::unique_ptr<"; dumpType(out, manager, attr.type); - out << " const &>(\"get" << attr.name - << "\"); " - " auto const the_copy(the_ptr); " - " delete &the_ptr; " - " return the_copy; " - " } "; + out << ">>(\"get" << attr.name << "\"); } "; } else { @@ -904,19 +898,14 @@ void dumpWrapperClassMembers(std::ostream& out, rtl::Reference<TypeManager> cons out << ") override {"; if (meth.returnType == "any" || meth.returnType.startsWith("[]")) { - out << " " - " auto & the_ptr = call<"; + out << " return *call<std::unique_ptr<"; dumpType(out, manager, meth.returnType); - out << " const &>(\"" << meth.name << "\""; + out << ">>(\"" << meth.name << "\""; for (auto const& param : meth.parameters) { out << ", " << param.name; } - out << "); " - " auto const the_copy(the_ptr); " - " delete &the_ptr; " - " return the_copy; " - " } "; + out << "); } "; } else { @@ -1060,7 +1049,8 @@ SAL_IMPLEMENT_MAIN() std::cerr << "Cannot open \"" << cppPathname << "\" for writing "; std::exit(EXIT_FAILURE); } - cppOut << "#include <emscripten/bind.h> " + cppOut << "#include <memory> " + "#include <emscripten/bind.h> " "#include <com/sun/star/uno/Any.hxx> " "#include <com/sun/star/uno/Reference.hxx> " "#include <o3tl/unreachable.hxx> "