diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-02-28 14:57:35 +0100 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-02-29 07:53:54 +0100 |
commit | 6064939d40119877eb65d5f0ce80f65d9fac53da (patch) | |
tree | 91022f0a4dea376941550f191a88e839a21eb1f4 /unotest/source | |
parent | 08d265144421deed247c23af36b0a6d41c35bf1f (diff) |
Embind support for constant groups
The constants are only reflected directly as JS values in the generated *.js
file. Reflecting them via emscripten::constant in the generated *.cxx did not
work well: Most importantly, emscripten::constant (and its underlying
_embind_register_constant) coerce all values to double, so UNO (unsigned) hyper
would not survive as JS BigInt, which would then cause e.g.
> console.assert(test.isHyper(uno.org.libreoffice.embindtest.Constants.Hyper));
passing such a (JS number, not BigInt) value into the
org.libreoffice.embindtest.XTest::isHyper method (which expects a UNO hyper) to
fail. (Also, constants of UNO boolean type would be represented as numbers 0/1
rather than as false/true.)
Change-Id: I056db0ccce0bf40eb53728fd439cc74964eb6951
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164097
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'unotest/source')
-rw-r--r-- | unotest/source/embindtest/embindtest.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js index 146be3fa545a..4eb9e60832e6 100644 --- a/unotest/source/embindtest/embindtest.js +++ b/unotest/source/embindtest/embindtest.js @@ -247,6 +247,26 @@ Module.addOnPostRun(function() { console.assert(test.isSequenceStruct(v)); v.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); + console.assert(test.isByte(uno.org.libreoffice.embindtest.Constants.Byte)); + console.assert(uno.org.libreoffice.embindtest.Constants.Short === -1234); + console.assert(test.isShort(uno.org.libreoffice.embindtest.Constants.Short)); + console.assert(uno.org.libreoffice.embindtest.Constants.UnsignedShort === 54321); + console.assert(test.isUnsignedShort(uno.org.libreoffice.embindtest.Constants.UnsignedShort)); + console.assert(uno.org.libreoffice.embindtest.Constants.Long === -123456); + console.assert(test.isLong(uno.org.libreoffice.embindtest.Constants.Long)); + console.assert(uno.org.libreoffice.embindtest.Constants.UnsignedLong === 3456789012); + console.assert(test.isUnsignedLong(uno.org.libreoffice.embindtest.Constants.UnsignedLong)); + console.assert(uno.org.libreoffice.embindtest.Constants.Hyper === -123456789n); + console.assert(test.isHyper(uno.org.libreoffice.embindtest.Constants.Hyper)); + console.assert(uno.org.libreoffice.embindtest.Constants.UnsignedHyper === 9876543210n); + console.assert(test.isUnsignedHyper(uno.org.libreoffice.embindtest.Constants.UnsignedHyper)); + console.assert(uno.org.libreoffice.embindtest.Constants.Float === -10.25); + console.assert(test.isFloat(uno.org.libreoffice.embindtest.Constants.Float)); + console.assert(uno.org.libreoffice.embindtest.Constants.Double === 100.5); + console.assert(test.isDouble(uno.org.libreoffice.embindtest.Constants.Double)); }); /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |