core.git: offapi/org static/source unotest/source

2024-04-20 Thread Stephan Bergmann (via logerrit)
 offapi/org/libreoffice/embindtest/XTest.idl|4 +
 static/source/unoembindhelpers/PrimaryBindings.cxx |4 -
 unotest/source/embindtest/embindtest.cxx   |   18 
 unotest/source/embindtest/embindtest.js|   47 +
 4 files changed, 71 insertions(+), 2 deletions(-)

New commits:
commit e6ddfdf040f88d19e5ec9b4d10b8cccd79155ad1
Author: Stephan Bergmann 
AuthorDate: Fri Apr 19 17:05:31 2024 +0200
Commit: Stephan Bergmann 
CommitDate: Sat Apr 20 11:57:28 2024 +0200

Embind: Test and Fix out-param handling

(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 

diff --git a/offapi/org/libreoffice/embindtest/XTest.idl 
b/offapi/org/libreoffice/embindtest/XTest.idl
index 3dc1773c120a..38ac60a47618 100644
--- a/offapi/org/libreoffice/embindtest/XTest.idl
+++ b/offapi/org/libreoffice/embindtest/XTest.idl
@@ -114,6 +114,10 @@ interface XTest {
 boolean isSequenceStruct([in] sequence value);
 XTest getNull();
 boolean isNull([in] XTest value);
+void getOut(
+[out] boolean value1, [out] byte value2, [out] short value3, [out] 
unsigned short value4,
+[out] long value5, [out] unsigned long value6, [out] hyper value7,
+[out] unsigned hyper value8, [out] float value9, [out] double value10, 
[out] char value11);
 void throwRuntimeException();
 void passJob([in] com::sun::star::task::XJob object);
 void passJobExecutor([in] com::sun::star::task::XJobExecutor object);
diff --git a/static/source/unoembindhelpers/PrimaryBindings.cxx 
b/static/source/unoembindhelpers/PrimaryBindings.cxx
index 862cbb1101e2..6ae2e68323dc 100644
--- a/static/source/unoembindhelpers/PrimaryBindings.cxx
+++ b/static/source/unoembindhelpers/PrimaryBindings.cxx
@@ -386,7 +386,7 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
 };
 });
 
-registerInOutParam("uno_InOutParam_boolean");
+registerInOutParam("uno_InOutParam_boolean");
 registerInOutParam("uno_InOutParam_byte");
 registerInOutParam("uno_InOutParam_short");
 registerInOutParam("uno_InOutParam_unsigned_short");
@@ -396,7 +396,7 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
 registerInOutParam("uno_InOutParam_unsigned_hyper");
 registerInOutParam("uno_InOutParam_float");
 registerInOutParam("uno_InOutParam_double");
-registerInOutParam("uno_InOutParam_char");
+registerInOutParam("uno_InOutParam_char");
 
 function("getCurrentModelFromViewSh", );
 function("getUnoComponentContext", 
::getProcessComponentContext);
diff --git a/unotest/source/embindtest/embindtest.cxx 
b/unotest/source/embindtest/embindtest.cxx
index 9c10335ed704..bbc3496a7238 100644
--- a/unotest/source/embindtest/embindtest.cxx
+++ b/unotest/source/embindtest/embindtest.cxx
@@ -512,6 +512,24 @@ class Test : public 
cppu::WeakImplHelper
 return !value;
 }
 
+void SAL_CALL getOut(sal_Bool& value1, sal_Int8& value2, sal_Int16& 
value3, sal_uInt16& value4,
+ sal_Int32& value5, sal_uInt32& value6, sal_Int64& 
value7,
+ sal_uInt64& value8, float& value9, double& value10,
+ sal_Unicode& value11) override
+{
+value1 = true;
+value2 = -12;
+value3 = -1234;
+value4 = 54321;
+value5 = -123456;
+value6 = 3456789012;
+value7 = -123456789;
+value8 = 9876543210;
+value9 = -10.25;
+value10 = 100.5;
+value11 = u'Ö';
+}
+
 void SAL_CALL throwRuntimeException() override
 {
 throw css::uno::RuntimeException(u"test"_ustr);
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index 6d89a728dbdf..e4dccefa6537 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -528,6 +528,53 @@ Module.addOnPostRun(function() {
 console.log(v);
 console.assert(v === null);
 }
+{
+const v1 = new Module.uno_InOutParam_boolean;
+const v2 = new Module.uno_InOutParam_byte;
+const v3 = new Module.uno_InOutParam_short;
+const v4 = new Module.uno_InOutParam_unsigned_short;
+const v5 = new Module.uno_InOutParam_long;
+const v6 = new Module.uno_InOutParam_unsigned_long;
+const v7 = new Module.uno_InOutParam_hyper;
+const v8 = new Module.uno_InOutParam_unsigned_hyper;
+const v9 = new Module.uno_InOutParam_float;
+const v10 = new Module.uno_InOutParam_double;
+const v11 = new Module.uno_InOutParam_char;
+test.getOut(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
+console.log(v1.val);
+console.log(v2.val);
+console.log(v3.val);
+  

core.git: offapi/org static/source unotest/source

2024-04-12 Thread Stephan Bergmann (via logerrit)
 offapi/org/libreoffice/embindtest/XTest.idl |3 
 static/source/embindmaker/embindmaker.cxx   |  160 ++--
 unotest/source/embindtest/embindtest.cxx|   22 +++
 unotest/source/embindtest/embindtest.js |   36 ++
 4 files changed, 212 insertions(+), 9 deletions(-)

New commits:
commit 3454a73a11722c45016c9b5aa0d95402fc1196f0
Author: Stephan Bergmann 
AuthorDate: Fri Apr 12 08:57:44 2024 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Apr 12 20:52:54 2024 +0200

Embind: support .implement()-based JS UNO objects

Change-Id: I3a8bf5986b91b886547cfe57e49275f7c79ddc11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166020
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/offapi/org/libreoffice/embindtest/XTest.idl 
b/offapi/org/libreoffice/embindtest/XTest.idl
index b3b5237ce2b4..8817e94669fc 100644
--- a/offapi/org/libreoffice/embindtest/XTest.idl
+++ b/offapi/org/libreoffice/embindtest/XTest.idl
@@ -113,6 +113,9 @@ interface XTest {
 sequence getSequenceStruct();
 boolean isSequenceStruct([in] sequence value);
 void throwRuntimeException();
+void passJob([in] com::sun::star::task::XJob object);
+void passJobExecutor([in] com::sun::star::task::XJobExecutor object);
+void passInterface([in] com::sun::star::uno::XInterface object);
 };
 
 }; }; };
diff --git a/static/source/embindmaker/embindmaker.cxx 
b/static/source/embindmaker/embindmaker.cxx
index 4241d10b1575..07214c289681 100644
--- a/static/source/embindmaker/embindmaker.cxx
+++ b/static/source/embindmaker/embindmaker.cxx
@@ -501,7 +501,7 @@ void dumpAttributes(std::ostream& out, 
rtl::Reference const& manage
 }
 out << "->get" << attr.name << "(); }";
 }
-out << ")
";
+out << ", ::emscripten::pure_virtual())
";
 if (!attr.readOnly)
 {
 out << ".function(\"set" << attr.name << "\", ";
@@ -530,7 +530,7 @@ void dumpAttributes(std::ostream& out, 
rtl::Reference const& manage
 }
 out << "->set" << attr.name << "(the_value); }";
 }
-out << ")
";
+out << ", ::emscripten::pure_virtual())
";
 }
 }
 }
@@ -660,7 +660,7 @@ void dumpWrapper(std::ostream& out, 
rtl::Reference const& manager,
 {
 out << ", ::emscripten::allow_raw_pointers()";
 }
-out << ")
";
+out << ", ::emscripten::pure_virtual())
";
 }
 
 void dumpMethods(std::ostream& out, rtl::Reference const& manager,
@@ -676,18 +676,18 @@ void dumpMethods(std::ostream& out, 
rtl::Reference const& manager,
 else
 {
 out << ".function(\"" << meth.name << "\", &" << 
cppName(name)
-<< "::" << meth.name << ")
";
+<< "::" << meth.name << ", ::emscripten::pure_virtual())
";
 }
 }
 }
 
-rtl::Reference 
resolveBase(rtl::Reference const& manager,
-OUString const& name)
+rtl::Reference
+resolveInterface(rtl::Reference const& manager, OUString const& 
name)
 {
 auto const ent = manager->getManager()->findEntity(name);
 if (!ent.is() || ent->getSort() != unoidl::Entity::SORT_INTERFACE_TYPE)
 {
-throw CannotDumpException("bad interface base \"" + name + "\"");
+throw CannotDumpException("bad interface \"" + name + "\"");
 }
 return static_cast(ent.get());
 }
@@ -695,7 +695,7 @@ rtl::Reference 
resolveBase(rtl::Reference const& manager, OUString 
const& name,
 std::set& visitedBases)
 {
-auto const ent = resolveBase(manager, name);
+auto const ent = resolveInterface(manager, name);
 for (auto const& base : ent->getDirectMandatoryBases())
 {
 if (visitedBases.insert(base.name).second)
@@ -709,7 +709,7 @@ void dumpBase(std::ostream& out, 
rtl::Reference const& manager,
   OUString const& interface, OUString const& name, 
std::set& visitedBases,
   std::list const& baseTrail)
 {
-auto const ent = resolveBase(manager, name);
+auto const ent = resolveInterface(manager, name);
 for (auto const& base : ent->getDirectMandatoryBases())
 {
 if (visitedBases.insert(base.name).second)
@@ -723,6 +723,126 @@ void dumpBase(std::ostream& out, 
rtl::Reference const& manager,
 dumpMethods(out, manager, interface, ent, baseTrail);
 }
 
+void dumpWrapperClassMembers(std::ostream& out, rtl::Reference 
const& manager,
+ OUString const& interface, OUString const& name,
+ std::set& visitedBases)
+{
+auto const ent = resolveInterface(manager, name);
+for (auto const& base : ent->getDirectMandatoryBases())
+{
+if (visitedBases.insert(base.name).second)
+{
+dumpWrapperClassMembers(out, manager, interface, base.name, 
visitedBases);
+}
+}
+for (auto const& attr :