summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-11 09:56:11 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-03-11 13:36:11 +0100
commitc35985a4b42d6a7d654b4fd1f99a966b75ee28a6 (patch)
tree8b72ce44b2f71a0ed91559a2d8f7fed2919db116
parent36a169c10f0457c30a0d327fda585c4decb33532 (diff)
Embind construction of UNO Any enum
Change-Id: I1b2167e261f1020b228f8ca2618c7f0009ca1d3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164646 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--static/source/unoembindhelpers/PrimaryBindings.cxx12
-rw-r--r--unotest/source/embindtest/embindtest.js10
2 files changed, 16 insertions, 6 deletions
diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 8fb5ad39a6da..0aadc85f6086 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -17,6 +17,7 @@
#include <com/sun/star/uno/Type.hxx>
#include <comphelper/processfactory.hxx>
#include <o3tl/any.hxx>
+#include <o3tl/temporary.hxx>
#include <o3tl/unreachable.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -283,7 +284,16 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
case TypeClass_SEQUENCE:
return {}; //TODO
case TypeClass_ENUM:
- return {}; //TODO
+ {
+ emscripten::internal::EM_DESTRUCTORS destructors = nullptr;
+ emscripten::internal::EM_GENERIC_WIRE_TYPE result
+ = _emval_as(rObject.as_handle(), getTypeId(rUnoType), &destructors);
+ emscripten::internal::DestructorsRunner dr(destructors);
+ return css::uno::Any(
+ &o3tl::temporary(
+ emscripten::internal::fromGenericWireType<sal_Int32>(result)),
+ rUnoType);
+ }
case TypeClass_STRUCT:
return {}; //TODO
case TypeClass_EXCEPTION:
diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js
index 1c6cd5f2718e..21c0e5cf098e 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -269,11 +269,11 @@ Module.addOnPostRun(function() {
console.assert(v.get() === uno.org.libreoffice.embindtest.Enum.E_2);
console.assert(test.isAnyEnum(v));
v.delete();
- //TODO: let a = new Module.uno_Any(
- //TODO: Module.uno_Type.Enum('org.libreoffice.embindtest.Enum'),
- //TODO: uno.org.libreoffice.embindtest.Enum.E_2);
- //TODO: console.assert(test.isAnyEnum(a));
- //TODO: a.delete();
+ let a = new Module.uno_Any(
+ Module.uno_Type.Enum('org.libreoffice.embindtest.Enum'),
+ uno.org.libreoffice.embindtest.Enum.E_2);
+ console.assert(test.isAnyEnum(a));
+ a.delete();
}
{
let v = test.getAnyStruct();