From 1bf2d3fa8ed016eaf71d8b3acc3fc779ee32e223 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 19 Apr 2024 10:35:14 +0200 Subject: [PATCH] Embind: Drop $equals, add sameUnoObject $equals was the last remaining special $... method that we added to the UNO interfaces, and it looks better anyway to turn it into a symmetric free function (that can be called with null for either argument) that is actually independent of specific interface types Change-Id: I22a1d08b8b15a0ed2dd37fa9fbc95f568641dec3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166317 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- static/source/embindmaker/embindmaker.cxx | 7 +------ static/source/unoembindhelpers/PrimaryBindings.cxx | 5 +++++ unotest/source/embindtest/embindtest.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/static/source/embindmaker/embindmaker.cxx b/static/source/embindmaker/embindmaker.cxx index f9540c1f006b..6c0017ccb8c2 100644 --- a/static/source/embindmaker/embindmaker.cxx +++ b/static/source/embindmaker/embindmaker.cxx @@ -1088,12 +1088,7 @@ SAL_IMPLEMENT_MAIN() " .class_function(\"reference\", +[](" << cppName(ifc) << " * the_interface) { return ::com::sun::star::uno::Reference(the_interface); " - "}, ::emscripten::allow_raw_pointers())\n" - " .function(\"$equals\", +[](::com::sun::star::uno::Reference<" - << cppName(ifc) - << "> const & the_self, " - "::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface> const & " - "the_other) { return the_self == the_other; })\n"; + "}, ::emscripten::allow_raw_pointers())\n"; if (bases.size() > 1) { std::set visitedBases; diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx b/static/source/unoembindhelpers/PrimaryBindings.cxx index 7abf88669d02..862cbb1101e2 100644 --- a/static/source/unoembindhelpers/PrimaryBindings.cxx +++ b/static/source/unoembindhelpers/PrimaryBindings.cxx @@ -13,8 +13,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -401,6 +403,9 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings) function("throwUnoException", +[](css::uno::Type const& type, emscripten::val const& value) { cppu::throwException(constructAny(type, value)); }); + function("sameUnoObject", + +[](css::uno::Reference const& ref1, + css::uno::Reference const& ref2) { return ref1 == ref2; }); function("rtl_uString_release", +[](std::uintptr_t ptr) { rtl_uString_release(reinterpret_cast(ptr)); }); diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js index 784530597392..6d89a728dbdf 100644 --- a/unotest/source/embindtest/embindtest.js +++ b/unotest/source/embindtest/embindtest.js @@ -308,7 +308,7 @@ Module.addOnPostRun(function() { { let v = test.getAnyInterface(); console.log(v); - console.assert(v.get().$equals(test)); + console.assert(Module.sameUnoObject(v.get(), test)); console.assert(test.isAnyInterface(v)); v.delete(); let a = new Module.uno_Any(