summaryrefslogtreecommitdiff
path: root/unotest
AgeCommit message (Collapse)Author
2024-09-26cid#1619687 Not restoring ostream formatCaolán McNamara
Change-Id: Id47cdffca6e597f3bf60ac9def5e92916443b117 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173967 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-09-25cid#1619687 Not restoring ostream formatCaolán McNamara
Change-Id: Id46d2317a0eeef612836fc58dc9da18cf7ee99a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173894 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-09-24Surround printed struct/exception members with {...}Stephan Bergmann
Change-Id: I41d661e5d89c784715e4e07a3c7f7f27737ba3e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173831 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-09-23Best effort to print more details about caught UNO exceptionStephan Bergmann
Change-Id: Ia8f098e4e441b6aba0d76d7184dc6cec2210f793 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173813 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-09-10Demonstrate that Embind is not multi-threading capableStephan Bergmann
Enabling the line commented out with "TODO" in embindtest.js would fail with something like > Aborted(Assertion failed: invalid handle: 8) > worker.js onmessage() captured an uncaught exception: RuntimeError: unreachable > RuntimeError: unreachable > at soffice.wasm.__trap (http://localhost:6931/soffice.wasm:wasm-function[446445]:0x8f952b3) > at ___trap (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:16657:54) > at abort (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:1091:5) > at assert (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:731:5) > at HandleAllocator.get (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:7212:11) > at Object.toValue (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:7270:30) > at __emval_call_void_method (blob:http://localhost:6931/7e945427-df90-49c0-a2b5-28c5ecfbe1a5:10183:22) > at soffice.wasm.the_wrappers::com::sun::star::task::XJobExecutor::trigger(rtl::OUString const&) (http://localhost:6931/soffice.wasm:wasm-function[77042]:0xafbb24) > at soffice.wasm.(anonymous namespace)::JobExecutorThread::execute() (http://localhost:6931/soffice.wasm:wasm-function[243534]:0x43250b5) > at soffice.wasm.non-virtual thunk to salhelper::Thread::run() (http://localhost:6931/soffice.wasm:wasm-function[87641]:0xdff5cf) Change-Id: I4e35dc19c5c0f97de7158bf9c07fd31716ffff84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173132 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-08-26'use strict' is of no use here...Stephan Bergmann
...in snippets that are included with --pre-js/--post-js Change-Id: I928aa16b78284314796a0645479dce0dfc7b42cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172383 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-08-18Emscripten: Clean up SolarMutexStephan Bergmann
...before disappearing through the QApplication::exec() hole, or else the SolarMutex would remain locked forever on the application's main thread. This requires changing SalInstance::ReleaseYieldMutexAll() to SalInstance::ReleaseYieldMutex(bool all). (Further recursive locking of the SolarMutex via SolarMutexGuard instances that would be present on the call stack leading up to the call to QApplication::exec() would be released during the stack unwinding, so just undo the one acquiring done in InitVCL, not all of them.) Change-Id: I9ef57abb7da7f840999700e4eaeeefd2da784645 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171956 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-08-18Those XTest::is... methods return boolean, not anyStephan Bergmann
Change-Id: Ie76e3551cac714fee56a087aed6aa851c4569209 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171957 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-08-01pyuno,unotest,xmlsecurity: copy GPG test files for UITtestMichael Stahl
The problem was that running UITest_xmlsecurity_gpg changed the files in test/signing-keys/ ... prevent that by copying the directory in that test, which is more complicated than initially expected. Change-Id: Ie3be922e0b2e9dae49f9a70e35ad5270c90b4fc4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171322 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Tested-by: Jenkins
2024-07-30More exhaustive org.libreoffice.embindtest.StructStephan Bergmann
Change-Id: I91085ef8cd7cd80852c0d0ab4f87fd3226a10a00 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171236 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-30Embind: Missing support for UNO polymorphic struct typesStephan Bergmann
Change-Id: I6bb29a951e6e5a3ed7d825172ba7b92ef95a5619 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171228 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-29testtools, uitest, unotest: fix issues found by Ruff linterIlmari Lauhakangas
Change-Id: I4a848b0f1f114d1262b5242786e088eb50a33cef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171145 Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Tested-by: Jenkins
2024-07-27In embindtest, also test Any included in StructStephan Bergmann
Change-Id: Id268692c750873629c1ceaf232e1e61912164872 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171078 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-25Add a toDelete parameter to Module.throwUnoExceptionStephan Bergmann
...as there can be situations (cf. the newly added test code in embindtest.js) where objects that need to be deleted are passed as payload of the exception value to be thrown. So there now is a (mandatory, as Embind doesn't allow to implicitly pass undefined) third parameter now that must be an array of objects on which to call .delete(). (75fe059974dcb80c3f78110c73ab799afc6f4ca3 "Embind: throwUnoException from JS" had deliberately made throwUnoException take two arguments, because if it "directly took a css::uno::Any argument, JS client code would need to create one with `new Module.uno_Any(...)` and call .delete() on it, but there is no place where it could call .delete()". There now would be such a place, but it would probably still be tedious most of the time to explicitly construct a new uno_Any to pass into throwUnoException both as the exception and in the toDelete array. So keep that design decision to have throwUnoException take individual type and value arguments.) Change-Id: Idec029d9e500457b02d20d899b9a2328cd7a5d7e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171024 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-07-18Change from Module.intiUno() to Module.uno_init promiseStephan Bergmann
...that is resolved from within C++ Desktop::InitApplicationServiceManager once UNO is fully initialized, so client code can trigger on Module.uno_init.then(...) Change-Id: I2d4c542d9729d09f434502e3f966e9ee474e926c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170683 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-18make date/time single-arg constructors explicitNoel Grandin
Change-Id: I943f755d95b90ef8aeb7d5b339f617ff50db4e29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170673 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-07-17Missing gb_Library_use_libraries,embindtestStephan Bergmann
...which went unnoticed for this Emscripten-only library due to the static nature of the Emscripten build, but is probably better to do properly anyway Change-Id: Ie0e0b463057fbc60e17741f362a129f784f7154d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170603 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-16Embind: Implement UNO interface attributes as JS accessor propertiesStephan Bergmann
Change-Id: I39b1f5676b2e5ba6071b39bf031c10d9c85f1ad1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170566 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-16Add test code for UNO attributes implemented in JSStephan Bergmann
Change-Id: I74f5ef53e7850ab783ae4cd94525a55c63512bd3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170544 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-16Test calling directly from JS a UNO method implemented in JSStephan Bergmann
Change-Id: I46855474d2c183db9204bfea68cac94112e7766a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170543 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-07-12Turn org.libreoffice.embindtest.Test from singleton to serviceStephan Bergmann
...so that testing its StringAttribute stars out with a known state. And which revealed that the test code in unotest/source/embindtest/embindtest.js was actually wrong in assuming that that UNO attribute would be represented by a JS accessor property, when actually it is represented by a pair of get-/setStringAttribute member functions. Change-Id: I1a6e7c9f26e9a08cd089b7972a23f4c608c6b1bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170414 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-07-11Fully implement the Wasm UNO bridge cpp2uno directionStephan Bergmann
...after 875997c8962da7f6b72950b201186a19b3c20d3a "Properly implement cppu::throwException for Emscripten" had implemented only those parts that were absolutely necessary for that exception throwing. As detailed in the commit message there, wasmcallgen has been extended to additionally generate all the required vtable slot call trampoline code (which cannot be generated on the fly for Wasm, as would be done for other platforms). Consequently, some of the "callvirtualfunction"-centric file names have been changed to "generated" as the output of wasmcallgen is now more general. (And wasmcallgen itself should also be renamed, in a follow-up commit. And when adding to the wasmcallgen code here, some existing parts of its implementation have been cleaned up, too.) There is no direct way to test this half of the Wasm UNO bridge directly from unotest/source/embindtest/embindtest.js, so a new org.libreoffice.embindtest.BridgeTest singleton has been added, which triggers new test code in unotest/source/embindtest/embindtest.cxx that tests the bridge in a way similar to testtools' bridgetest machinery. Change-Id: I521a1d6c2160aedc814f7603b0b99861e5fbd1eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170374 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-28Fix "lets" -> "let's"Andrea Gelmini
Change-Id: Ibe6cbbd618aab5c145913235dc90fec3c98cd504 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169723 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2024-06-21Embind: Fix C++ UNO exception catchingStephan Bergmann
...with a new Module.catchUnoException JS function that can be used in a JS catch block to provide the thrown UNO exception as an Any. (For a non-C++ exception, it rethrows the exception, and for a non-UNO C++ exception it maps it to css.uno.RuntimeException.) The implementation reuses parts of bridges/source/cpp_uno/gcc3_wasm/, which have been moved to a new StaticLibrary_emscriptencxxabi. Change-Id: I708fe6121c43a1b9736de5dff449f6c4f32a45f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169325 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-19Consistently 'use strict' for JS codeStephan Bergmann
Change-Id: I6f6e06ad32ffa87242f5a0f41c176149b754e2ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169187 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-06-17Embind: Fix lifecycle of UNO any and sequence values returned from JS to C++Stephan Bergmann
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::star::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-12Embind: Let unoObject return a css.uno.XInterface referenceStephan Bergmann
...and confine the _impl map to an internal detail. Client code should have no need to access that _impl map (renamed here to impl_interfaces), nor the Module.uno_Type_*.reference functions (nor the Module.uno_Type_*.implement functions). Change-Id: Ic9c74f22cedb9b5eeecb42d7c13ee0555e92690d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168732 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-06-12Embind: Centrally initialize via Module.initUno() in a new uno.jsStephan Bergmann
...so that the unoObject function can be moved there too (so that other code outside embindtest.js can reuse it) Change-Id: Id3edb7cede56321db29ba435f221cb7702a3513c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168700 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-06-12Embind: A nicer unoObject construction functionStephan Bergmann
Change-Id: Ied532cf271644f424fbf9661a0b8d246124ca324 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168689 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-05-30Implement attribute handlingStephan Bergmann
Change-Id: Ic30d2de582f952555ec672984da78a07a9319443 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168224 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-05-29Implement exception catchingStephan Bergmann
(Without 22ce8ed05be37d676739a578b05cc5217109fd87 "Emscripten: Unconditional --enable-wasm-exceptions", this would have failed to link due to missing __cxa_current_exception_type and __cxa_get_globals.) Change-Id: If89a3c62e4d2ac24d68f867b2fd7a4cd813d5a39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168176 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-29Emscripten: Unconditional --enable-wasm-exceptionsStephan Bergmann
(...which will be beneficial, in turn, to implement exception handling in the work-in-progress bridges/source/cpp_uno/gcc3_wasm UNO bridge). As per <https://developer.mozilla.org/en-US/docs/WebAssembly#browser_compatibility>, Wasm exceptions appear to be supported by most if not all relevant engines by now. * Lets see whether the "Note that to really use WASM exceptions everywhere" for external libraries in solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk does have any practical consequences (but ignoring it for now). * This change depends on the preceding 77129fbb74bcefde4551d494f029169e7c6026e3 "Emscripten: Add hack to prepare for --enable-wasm-exceptions" to work around the issue that was mentioned in static/README.wasm.md. * In unotest/source/embindtest/embindtest.js, getExceptionMessage started to work now, no longer exhibiting the RuntimeError that had been documented there for non-Wasm-based exceptions. Change-Id: Ifa2165b62208cc927844684911ddf21a4a2b624f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168169 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-28Emscripten: Document failing getExceptionMessageStephan Bergmann
(and add a console.assert(false) to verify that an exception actually gets thrown) Change-Id: I885301a5730b54c817c8a9ed97e60f49f8c8baf9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168149 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-05-20loplugin:ostr in variousNoel Grandin
Change-Id: I9f399b3752da9df930e0647536ffcd4e82beb1ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167856 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-05-12WaE: C6011 Dereferencing NULL pointer warningsCaolán McNamara
Change-Id: Ieabea4a0ddf8f95ea01b8b0275be0924ad055694 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167524 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2024-05-09Fix missing UNO<->C++ argument/return value conversionsStephan Bergmann
Change-Id: I5ac6013d6c0bd72fe840a592628fd0d5b265b8ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167391 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-05-09Embind: Fix uno_Any.get for null interface valuesStephan Bergmann
...which had caused an additional getNull/isNull check for a469aea9c0b532d928cd41e389c9c51de1af06f0 "Emscripten: Towards a working C++ UNO bridge" to fail Change-Id: Ibe87ca05f795253c9ede8cab6f96da8fe4496f87 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167344 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-05-08Emscripten: Towards a working C++ UNO bridgeStephan Bergmann
...by making the general UNO -> C++ function call case work (modulo handling exceptions, which I'll look into later). Wasm call_indirect unfortunately needs to statically know the call target's signature, so we statically need to know all possible signatures. So introduce wasmcallgen helper to scan the existing UNOIDL API upfront and generate the relevant callvirtualfunction-wrapper.cxx and callvirtualfunction-inst.s code. (The good thing is that the number of different signatures is somewhat limited, each parameter can only be one of i32, i64, f32, or f64. So even if 3rd-party extensions bring along new UNOIDL interface methods, chances are relatively high that the signatures needed for them would already be covered by the existing ones.) Testing this can nicely be done in unotest/source/embindtest/embindtest.js via css.script.Invocation (which internally exercises the relevant code). (Instead of adding individual org.libreoffice.embindtest.StructLong/String etc., it would be nicer to introduce some polymorphic StructOne<T>, but the Emind UNO binding does not support polymorphic structs, so the embindtest.js code would not work.) Change-Id: If829c9e3772bfd27561f3ad743d38a71d11545b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167308 Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Tested-by: Jenkins
2024-04-30Embind: Fix out-param handlingStephan Bergmann
...by using UnoInOutParam in all cases. Some types whose Embind mappings don't employ any smart pointers (like any and sequence) would have worked directly with pointers, but others (like string and type) would have caused Embind errors at runtime. So consistently use UnoInOutParam in all cases (and generate bindings for all the used cases in embindmaker). Change-Id: If26551bf4e99d10748aec1597d6e99f994dfd86e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166854 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-20Embind: Test and Fix out-param handlingStephan Bergmann
(the types that are meant to be passed directly by pointer will need more thought, to make them actually work) Change-Id: Ia0f2e6f5335fad1140629477e89fc96121c2927e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166318 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-20Embind: Drop $equals, add sameUnoObjectStephan Bergmann
$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>
2024-04-20Embind: Don't use new when getting UNO singletonsStephan Bergmann
Change-Id: I23265f46b25cb88796267abe28aac1100523e71b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166298 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-19Embind: Consistently represent empty interface references as JS nullStephan Bergmann
The existing code had two issues: For one, e.g. calling a function that returned a null interface reference mapped that to JS null, while querying an object for a non-supported interface via `new css.uno.X...(y)` mapped that to an "empty" JS object instead. (So checking for a non-null reference needed to be done as either `x !=== null` or as `x.is()`, depending on context.) And for another, while calling $is() on a non-"empty" object worked fine, it failed on such an "empty" object (as the Embind internals of that object lacked the $$ property). So change the querying mechanism from the `new css.uno.X...(y)` constructor to a `css.uno.X....query(y)` function call syntax, which now returns JS null when querying for a non-supported interface. (And drop the broken $is method.) Change-Id: I8fa488ab2892423f2a461d9b72db47e1d4df3b8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166255 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-18Embind: throwUnoException from JSStephan Bergmann
(If throwUnoException directly took a css::uno::Any argument, JS client code would need to create one with `new Module.uno_Any(...)` and call .delete() on it, but there is no place where it could call .delete(), so make throwUnoException take two arguments instead and assemble the css::uno::Any on the C++ side.) Change-Id: Iae4ae6af804354d5cf752115e272b79d61427440 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166253 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-18Embind: call decrementExceptionRefcount upon catchingStephan Bergmann
The note at <https://emscripten.org/docs/porting/exceptions.html#handling-c-exceptions-from-javascript> is a bit vague whether decrementExceptionRefcount would only be needed for Wasm-based (-fwasm-exceptions) exceptions, or also for the JS-based (-fexceptions) ones that we currently use. (But it does state clearly that for the latter we need to manually call incrementExceptionRefcount first.) Change-Id: I7714935607c990385f68730d02e367e70fa0ea03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166250 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-17Embind: Clean up JS UNO obj implementation in embindtest.jsStephan Bergmann
We don't need a dedicated implXInterface, any other interface derived from it works as well. But we should arguably implement css.lang.XTypeProvider. Which in turn requires two sequences, which need to be eventually .delete()'ed, so add impl* for them. And while at it, rename refcount to implRefcount for consistency. Change-Id: I8cfd0df74058383bd432e2a6a86f7f2039a87ffb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166181 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-16Embind: No need for $queryStephan Bergmann
...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>
2024-04-12Embind: support .implement()-based JS UNO objectsStephan Bergmann
Change-Id: I3a8bf5986b91b886547cfe57e49275f7c79ddc11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166020 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-11Move org.libreoffice.embindtest from udkapi to offapiStephan Bergmann
...so it will be able to use e.g. css.task.XJob in its tests Change-Id: I15e50c07ee4b1b315d2687dc7e7ea0c00ccc638c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165998 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2024-04-08Fix indentationStephan Bergmann
Change-Id: I985562995714c04c569e3a794cf748443ed02865 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165886 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>