static/source/unoembindhelpers/PrimaryBindings.cxx |   26 +++++++++---
 unotest/source/embindtest/embindtest.js            |   44 ++++++++++-----------
 2 files changed, 42 insertions(+), 28 deletions(-)

New commits:
commit 2995a0e0785911322c9d57e98b925073ff6cb6bd
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Mon Mar 11 10:13:18 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Mon Mar 11 13:36:24 2024 +0100

    Embind construction of UNO Any sequence/struct/exception/interface
    
    Change-Id: I43d924126f4d34e0efbcea61dd5f4bd9be235426
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164650
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx 
b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 0aadc85f6086..c8d4717aa347 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -282,7 +282,17 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
                 case TypeClass_TYPE:
                     return css::uno::Any(rObject.as<css::uno::Type>());
                 case TypeClass_SEQUENCE:
-                    return {}; //TODO
+                case TypeClass_STRUCT:
+                case TypeClass_EXCEPTION:
+                case TypeClass_INTERFACE:
+                {
+                    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(
+                        emscripten::internal::fromGenericWireType<void 
const*>(result), rUnoType);
+                }
                 case TypeClass_ENUM:
                 {
                     emscripten::internal::EM_DESTRUCTORS destructors = nullptr;
@@ -294,12 +304,6 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
                             
emscripten::internal::fromGenericWireType<sal_Int32>(result)),
                         rUnoType);
                 }
-                case TypeClass_STRUCT:
-                    return {}; //TODO
-                case TypeClass_EXCEPTION:
-                    return {}; //TODO
-                case TypeClass_INTERFACE:
-                    return {}; //TODO
                 default:
                     throw std::invalid_argument("bad type class");
             }
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index 21c0e5cf098e..1b0cf8eb5fc6 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -258,9 +258,9 @@ Module.addOnPostRun(function() {
         console.assert(test.isAnySequence(v));
         v.delete();
         let s = new Module.uno_Sequence_string(["foo", "barr", "bazzz"]);
-        //TODO: let a = new 
Module.uno_Any(Module.uno_Type.Sequence(Module.uno_Type.String()), s);
-        //TODO: console.assert(test.isAnySequence(a));
-        //TODO: a.delete();
+        let a = new 
Module.uno_Any(Module.uno_Type.Sequence(Module.uno_Type.String()), s);
+        console.assert(test.isAnySequence(a));
+        a.delete();
         s.delete();
     }
     {
@@ -283,11 +283,11 @@ Module.addOnPostRun(function() {
         console.assert(v.get().m3 === 'hä');
         console.assert(test.isAnyStruct(v));
         v.delete();
-        //TODO: let a = new Module.uno_Any(
-        //TODO:     
Module.uno_Type.Struct('org.libreoffice.embindtest.Struct'),
-        //TODO:     {m1: -123456, m2: 100.5, m3: 'hä'});
-        //TODO: console.assert(test.isAnyStruct(a));
-        //TODO: a.delete();
+        let a = new Module.uno_Any(
+            Module.uno_Type.Struct('org.libreoffice.embindtest.Struct'),
+            {m1: -123456, m2: 100.5, m3: 'hä'});
+        console.assert(test.isAnyStruct(a));
+        a.delete();
     }
     {
         let v = test.getAnyException();
@@ -299,11 +299,11 @@ Module.addOnPostRun(function() {
         console.assert(v.get().m3 === 'hä');
         console.assert(test.isAnyException(v));
         v.delete();
-        //TODO: let a = new Module.uno_Any(
-        //TODO:     
Module.uno_Type.Exception('org.libreoffice.embindtest.Exception'),
-        //TODO:     {Message: 'error', Context: null, m1: -123456, m2: 100.5, 
m3: 'hä'});
-        //TODO: console.assert(test.isAnyException(a));
-        //TODO: a.delete();
+        let a = new Module.uno_Any(
+            Module.uno_Type.Exception('org.libreoffice.embindtest.Exception'),
+            {Message: 'error', Context: null, m1: -123456, m2: 100.5, m3: 
'hä'});
+        console.assert(test.isAnyException(a));
+        a.delete();
     }
     {
         let v = test.getAnyInterface();
@@ -311,10 +311,10 @@ Module.addOnPostRun(function() {
         console.assert(v.get().$equals(test.$query()));
         console.assert(test.isAnyInterface(v));
         v.delete();
-        //TODO: let a = new Module.uno_Any(
-        //TODO:     
Module.uno_Type.Inteface('org.libreoffice.embindtest.Test'), test);
-        //TODO: console.assert(test.isAnyInterface(a));
-        //TODO: a.delete();
+        let a = new Module.uno_Any(
+            Module.uno_Type.Interface('org.libreoffice.embindtest.XTest'), 
test);
+        console.assert(test.isAnyInterface(a));
+        a.delete();
     }
     {
         let v = test.getSequenceBoolean();
commit c35985a4b42d6a7d654b4fd1f99a966b75ee28a6
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Mon Mar 11 09:56:11 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Mon Mar 11 13:36:11 2024 +0100

    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.bergm...@allotropia.de>

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();

Reply via email to