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 <stephan.bergmann@allotropia.de>
This commit is contained in:
Stephan Bergmann
2024-04-20 11:57:16 +02:00
parent 1c88938760
commit 1bf2d3fa8e
3 changed files with 7 additions and 7 deletions
+1 -6
View File
@@ -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<OUString> visitedBases;
@@ -13,8 +13,10 @@
#include <emscripten/bind.h>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Type.hxx>
#include <com/sun/star/uno/XInterface.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <o3tl/any.hxx>
@@ -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<css::uno::XInterface> const& ref1,
css::uno::Reference<css::uno::XInterface> const& ref2) { return ref1 == ref2; });
function("rtl_uString_release",
+[](std::uintptr_t ptr) { rtl_uString_release(reinterpret_cast<rtl_uString*>(ptr)); });
+1 -1
View File
@@ -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(