static/source/unoembindhelpers/PrimaryBindings.cxx |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit d155febef6a3d9b469f78ed4c5e70730032e3d38
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Fri Jun 7 10:43:48 2024 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Fri Jun 7 12:09:22 2024 +0200

    Embind: Add some type-inquiry functions to uno_Type and uno_Any
    
    ...that proved useful in experiments wrapping a JS Proxy around the Embind
    representation of C++ UNO objects.
    
    Change-Id: Ia4018ec8dee2c222fb76ba8e2f529f4845f0134c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168518
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx 
b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 9f9a5cf588d5..a8c7acab9250 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -16,6 +16,7 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/RuntimeException.hpp>
 #include <com/sun/star/uno/Type.hxx>
+#include <com/sun/star/uno/TypeClass.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 #include <comphelper/processfactory.hxx>
 #include <cppuhelper/exc_hlp.hxx>
@@ -26,6 +27,7 @@
 #include <sal/log.hxx>
 #include <sfx2/viewsh.hxx>
 #include <static/unoembindhelpers/PrimaryBindings.hxx>
+#include <typelib/typeclass.h>
 #include <typelib/typedescription.h>
 #include <typelib/typedescription.hxx>
 #include <uno/data.h>
@@ -297,6 +299,24 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
                         +[](std::u16string const& name) {
                             return 
css::uno::Type(css::uno::TypeClass_INTERFACE, OUString(name));
                         })
+        .function("getTypeClass", +[](css::uno::Type const& self) { return 
self.getTypeClass(); })
+        .function(
+            "getSequenceComponentType",
+            +[](css::uno::Type const& self) {
+                if (self.getTypeClass() != css::uno::TypeClass_SEQUENCE)
+                {
+                    throw std::invalid_argument("bad non-sequence type");
+                }
+                css::uno::TypeDescription desc;
+                
self.getDescription(reinterpret_cast<typelib_TypeDescription**>(&desc));
+                if (!desc.is())
+                {
+                    throw std::invalid_argument("bad sequence type");
+                }
+                assert(desc.get()->eTypeClass == typelib_TypeClass_SEQUENCE);
+                return css::uno::Type(
+                    reinterpret_cast<typelib_IndirectTypeDescription 
const*>(desc.get())->pType);
+            })
         .function("toString", +[](css::uno::Type const& self) {
             auto const name = self.getTypeName();
             return std::u16string(name.getStr(), name.getLength());
@@ -305,6 +325,7 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
     // Any
     class_<Any>("uno_Any")
         .constructor(&constructAny)
+        .function("getType", &css::uno::Any::getValueType)
         .function("get", +[](css::uno::Any const& self) {
             switch (self.getValueType().getTypeClass())
             {

Reply via email to