summaryrefslogtreecommitdiff
path: root/static/source/unoembindhelpers
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-02-03 16:01:28 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-02-03 23:44:14 +0100
commit453049b93e82bed84ac08eea35930b8881a26672 (patch)
tree56f0d2ecd5b3182db4501e6fa23e60dd260bfd60 /static/source/unoembindhelpers
parentde1d9d8302e600e6cc3964f55790d954fd493df9 (diff)
First-class Embind JS support for OUString
Change-Id: Ic178737da802e17f87d0b5b09004a847b0fe91be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162956 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'static/source/unoembindhelpers')
-rw-r--r--static/source/unoembindhelpers/PrimaryBindings.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 91e6fba92f4c..fe3b6e29908f 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -16,6 +16,9 @@
#include <sfx2/viewsh.hxx>
#include <static/unoembindhelpers/PrimaryBindings.hxx>
+#include <cstdint>
+#include <typeinfo>
+
using namespace emscripten;
using namespace css::uno;
@@ -27,6 +30,8 @@ template <typename T> void registerInOutParam(char const* name)
"val", &unoembindhelpers::UnoInOutParam<T>::get, &unoembindhelpers::UnoInOutParam<T>::set);
}
+std::uintptr_t getOUStringRawType() { return reinterpret_cast<std::uintptr_t>(&typeid(OUString)); }
+
Reference<css::frame::XModel> getCurrentModelFromViewSh()
{
SfxViewShell* pSh = nullptr;
@@ -45,12 +50,6 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
enum_<unoembindhelpers::uno_Reference>("uno_Reference")
.value("FromAny", unoembindhelpers::uno_Reference::FromAny);
- class_<OUString>("OUString")
- .constructor(+[](const std::u16string& rString) -> OUString { return OUString(rString); })
- .function("toString", +[](const OUString& rSelf) -> std::u16string {
- return std::u16string(rSelf.getStr(), rSelf.getLength());
- });
-
// Any
class_<Any>("Any").constructor(+[](const val& rObject, const TypeClass& rUnoType) -> Any {
switch (rUnoType)
@@ -112,7 +111,10 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
registerInOutParam<char16_t>("uno_InOutParam_char");
function("getCurrentModelFromViewSh", &getCurrentModelFromViewSh);
+ function("getOUStringRawType", &getOUStringRawType);
function("getUnoComponentContext", &comphelper::getProcessComponentContext);
+ function("rtl_uString_release",
+ +[](std::uintptr_t ptr) { rtl_uString_release(reinterpret_cast<rtl_uString*>(ptr)); });
}
#endif