summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-04-19 17:05:31 +0200
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-04-20 11:57:28 +0200
commite6ddfdf040f88d19e5ec9b4d10b8cccd79155ad1 (patch)
tree56756042fea63acd5beddbf599603f37a035aa48
parent1bf2d3fa8ed016eaf71d8b3acc3fc779ee32e223 (diff)
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 <stephan.bergmann@allotropia.de>
-rw-r--r--offapi/org/libreoffice/embindtest/XTest.idl4
-rw-r--r--static/source/unoembindhelpers/PrimaryBindings.cxx4
-rw-r--r--unotest/source/embindtest/embindtest.cxx18
-rw-r--r--unotest/source/embindtest/embindtest.js47
4 files changed, 71 insertions, 2 deletions
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<Struct> 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<bool>("uno_InOutParam_boolean");
+ registerInOutParam<sal_Bool>("uno_InOutParam_boolean");
registerInOutParam<sal_Int8>("uno_InOutParam_byte");
registerInOutParam<sal_Int16>("uno_InOutParam_short");
registerInOutParam<sal_uInt16>("uno_InOutParam_unsigned_short");
@@ -396,7 +396,7 @@ EMSCRIPTEN_BINDINGS(PrimaryBindings)
registerInOutParam<sal_uInt64>("uno_InOutParam_unsigned_hyper");
registerInOutParam<float>("uno_InOutParam_float");
registerInOutParam<double>("uno_InOutParam_double");
- registerInOutParam<char16_t>("uno_InOutParam_char");
+ registerInOutParam<sal_Unicode>("uno_InOutParam_char");
function("getCurrentModelFromViewSh", &getCurrentModelFromViewSh);
function("getUnoComponentContext", &comphelper::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<org::libreoffice::embindtest::XTest>
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);
+ console.log(v4.val);
+ console.log(v5.val);
+ console.log(v6.val);
+ console.log(v7.val);
+ console.log(v8.val);
+ console.log(v9.val);
+ console.log(v10.val);
+ console.log(v11.val);
+ console.assert(v1.val === 1); //TODO: true
+ console.assert(v2.val === -12);
+ console.assert(v3.val === -1234);
+ console.assert(v4.val === 54321);
+ console.assert(v5.val === -123456);
+ console.assert(v6.val === 3456789012);
+ console.assert(v7.val === -123456789n);
+ console.assert(v8.val === 9876543210n);
+ console.assert(v9.val === -10.25);
+ console.assert(v10.val === 100.5);
+ console.assert(v11.val === 'Ö');
+ v1.delete();
+ v2.delete();
+ v3.delete();
+ v4.delete();
+ v5.delete();
+ v6.delete();
+ v7.delete();
+ v8.delete();
+ v9.delete();
+ v10.delete();
+ v11.delete();
+ }
console.assert(uno.org.libreoffice.embindtest.Constants.Boolean === true);
console.assert(test.isBoolean(uno.org.libreoffice.embindtest.Constants.Boolean));
console.assert(uno.org.libreoffice.embindtest.Constants.Byte === -12);