diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-04-16 10:17:08 +0200 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-04-16 20:35:22 +0200 |
commit | 0957ee9f5d379c80fca4027c187b471118d0490d (patch) | |
tree | 02b6ba6819815dbe343f63c055db9d0bc3f0dea6 /static | |
parent | 7897f1d9835f686dd042348c51f7d2326de71971 (diff) |
Embind: No need for $query
...to "upcast" from css::uno::Reference<T> to base
css::uno::Reference<css::uno::XInterface>. My understanding now is that due to
the sharing_policy::INTRUSIVE we specify for
emscripten::smart_ptr_trait<css::uno::Reference<T>>
(include/static/unoembindhelpers/PrimaryBindings.hxx), Embind can internally
"upcast" from a css::uno::Reference<T> to a base
css::uno::Reference<css::uno::XInterface> by just treating the encapsulated raw
pointer of type T* as a raw pointer of type css::uno::XInterface* (see the use
of that sharingPolicy in genericPointerToWireType in Emscripten's
src/embind/embind.js; though documentation of that Embind sharing_policy is
rather poor).
Change-Id: I6ed60a9c94af6aba6fc6119bf644da7f507a997f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166142
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'static')
-rw-r--r-- | static/README.wasm.md | 10 | ||||
-rw-r--r-- | static/source/embindmaker/embindmaker.cxx | 5 |
2 files changed, 5 insertions, 10 deletions
diff --git a/static/README.wasm.md b/static/README.wasm.md index 3cfe5f6c33c9..69176bb8acbc 100644 --- a/static/README.wasm.md +++ b/static/README.wasm.md @@ -228,11 +228,11 @@ Some usage examples through javascript of the current implementation: let uno = init_unoembind_uno(Module); let css = uno.com.sun.star; xModel = Module.getCurrentModelFromViewSh(); -xTextDocument = new css.text.XTextDocument(xModel.$query()); +xTextDocument = new css.text.XTextDocument(xModel); xText = xTextDocument.getText(); -xSimpleText = new css.text.XSimpleText(xText.$query()); +xSimpleText = new css.text.XSimpleText(xText); xTextCursor = xSimpleText.createTextCursor(); -xTextRange = new css.text.XTextRange(xTextCursor.$query()); +xTextRange = new css.text.XTextRange(xTextCursor); xTextRange.setString("string here!"); xModel.delete(); xTextDocument.delete(); xText.delete(); xSimpleText.delete(); xTextCursor.delete(); xTextRange.delete(); ``` @@ -242,13 +242,13 @@ xModel.delete(); xTextDocument.delete(); xText.delete(); xSimpleText.delete(); x let uno = init_unoembind_uno(Module); let css = uno.com.sun.star; xModel = Module.getCurrentModelFromViewSh(); -xEnumAccess = new css.container.XEnumerationAccess(xText.$query()); +xEnumAccess = new css.container.XEnumerationAccess(xText); xParaEnumeration = xEnumAccess.createEnumeration(); while (xParaEnumeration.hasMoreElements()) { xParagraph = new css.text.XTextRange(xParaEnumeration.nextElement(), Module.uno_Reference.FromAny); if (xParagraph.$is()) { - xParaProps = new css.beans.XPropertySet(xParagraph.$query()); + xParaProps = new css.beans.XPropertySet(xParagraph); let color = new Module.uno_Any( Module.uno_Type.Long(), Math.floor(Math.random() * 0xFFFFFF)); xParaProps.setPropertyValue("CharColor", color); diff --git a/static/source/embindmaker/embindmaker.cxx b/static/source/embindmaker/embindmaker.cxx index 07214c289681..6d89f5a5ab10 100644 --- a/static/source/embindmaker/embindmaker.cxx +++ b/static/source/embindmaker/embindmaker.cxx @@ -1096,11 +1096,6 @@ SAL_IMPLEMENT_MAIN() " .function(\"$is\", +[](::com::sun::star::uno::Reference<" << cppName(ifc) << "> const & the_self) { return the_self.is(); })\n" - " .function(\"$query\", +[](::com::sun::star::uno::Reference<" - << cppName(ifc) - << "> const & the_self) { return " - "::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface>(the_" - "self); })\n" " .function(\"$equals\", +[](::com::sun::star::uno::Reference<" << cppName(ifc) << "> const & the_self, " |