office-gobmx/unotest
Stephan Bergmann 04658a7067 Embind: Fix lifecycle of UNO any and sequence values returned from JS to C++
When a JS function implementing a UNO interface method returns any or a sequence
type (like queryInterface, getType, and getImplementationId in uno.js), it
could not create a new instance of that type and return it, as it would have
needed to call .delete() on that instance, but couldn't.  In uno.js, getType and
getImplementationId solved that by returning pre-instantiated instances that
were deleted in the final release call.  But that did not work for
queryInterface, as pre-instantiating the relevant any instances would have
caused cyclic references that would have caused the final release call never to
occur.

So redesign the C++ the_wrapper classes (used by the Embind allow_subclass
machinery):  If a UNO interface method returns any or a sequence type (i.e., a
type on which .delete() must be called), change the JS implemenation's return
type from by-value (which meant that the C++ code received a copy) to
by-reference---which means that now the C++ code can access the original
instance and delete it.  But which also means that the JS code must always
return a fresh instance now!

(Ideally, the embindmaker-generated code would use by-pointer rather than
by-reference for that return type, but that caused

> emsdk/upstream/emscripten/cache/sysroot/include/emscripten/wire.h:116:19: error: static assertion failed due to requirement '!std::is_pointer<com::sun::uno::Any *>::value': Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>
>   116 |     static_assert(!std::is_pointer<T*>::value, "Implicitly binding raw pointers is illegal.  Specify allow_raw_pointer<arg<?>>");
>       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~

errors with no obvious place where to put such allow_raw_pointer markers, so
lets go with this little hack at least for now.)

Change-Id: I3c37b79b8fbf09c19782c6532bc95d4d63505c63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169008
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-17 21:57:12 +02:00
..
source Embind: Fix lifecycle of UNO any and sequence values returned from JS to C++ 2024-06-17 21:57:12 +02:00
IwyuFilter_unotest.yaml
Jar_test-tools.mk
Jar_test.mk
Library_embindtest.mk Move org.libreoffice.embindtest from udkapi to offapi 2024-04-11 15:22:40 +02:00
Library_unobootstrapprotector.mk
Library_unoexceptionprotector.mk
Library_unotest.mk qa: call ProcessEventsToIdle inside dispatchCommand 2023-02-21 20:20:29 +00:00
Makefile
Module_unotest.mk Fold InternalUnoApi_embindtest into UnoApi_udkapi 2024-02-28 07:52:11 +01:00
README.md

Tests for UNO

Contains tests for UNO