summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-04-17 15:48:17 +0200
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-04-17 20:40:54 +0200
commit89610c2176e1370a8075187e7637e5844fe5f3e3 (patch)
treef759b98dbbec8b20feb8a760a1a0f3110b50ce6e /unotest
parentdac30c44c606232ce23d52a423d0bf8010f25d4f (diff)
Embind: Clean up JS UNO obj implementation in embindtest.js
We don't need a dedicated implXInterface, any other interface derived from it works as well. But we should arguably implement css.lang.XTypeProvider. Which in turn requires two sequences, which need to be eventually .delete()'ed, so add impl* for them. And while at it, rename refcount to implRefcount for consistency. Change-Id: I8cfd0df74058383bd432e2a6a86f7f2039a87ffb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166181 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/embindtest/embindtest.js27
1 files changed, 20 insertions, 7 deletions
diff --git a/unotest/source/embindtest/embindtest.js b/unotest/source/embindtest/embindtest.js
index 67c0d2b77c13..8da18fbb7d96 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -545,10 +545,19 @@ Module.addOnPostRun(function() {
//TODO: console.assert(e.Message.startsWith('test'));
}
const obj = {
- refcount: 0,
+ implRefcount: 0,
+ implTypes: new Module.uno_Sequence_type([
+ Module.uno_Type.Interface('com.sun.star.lang.XTypeProvider'),
+ Module.uno_Type.Interface('com.sun.star.task.XJob'),
+ Module.uno_Type.Interface('com.sun.star.task.XJobExecutor')]),
+ implImplementationId: new Module.uno_Sequence_byte([]),
queryInterface(type) {
if (type == 'com.sun.star.uno.XInterface') {
- return new Module.uno_Any(type, css.uno.XInterface.reference(this.implXInterface));
+ return new Module.uno_Any(
+ type, css.uno.XInterface.reference(this.implXTypeProvider));
+ } else if (type == 'com.sun.star.lang.XTypeProvider') {
+ return new Module.uno_Any(
+ type, css.lang.XTypeProvider.reference(this.implXTypeProvider));
} else if (type == 'com.sun.star.task.XJob') {
return new Module.uno_Any(type, css.task.XJob.reference(this.implXJob));
} else if (type == 'com.sun.star.task.XJobExecutor') {
@@ -558,27 +567,31 @@ Module.addOnPostRun(function() {
return new Module.uno_Any(Module.uno_Type.Void(), undefined);
}
},
- acquire() { ++this.refcount; },
+ acquire() { ++this.implRefcount; },
release() {
- if (--this.refcount === 0) {
- this.implXInterface.delete();
+ if (--this.implRefcount === 0) {
+ this.implXTypeProvider.delete();
this.implXJob.delete();
this.implXJobExecutor.delete();
+ this.implTypes.delete();
+ this.implImplementationId.delete();
}
},
+ getTypes() { return this.implTypes; },
+ getImplementationId() { return this.implImplementationId; },
execute(args) {
console.log('Hello ' + args.get(0).Value.get());
return new Module.uno_Any(Module.uno_Type.Void(), undefined);
},
trigger(event) { console.log('Ola ' + event); }
};
- obj.implXInterface = css.uno.XInterface.implement(obj);
+ obj.implXTypeProvider = css.lang.XTypeProvider.implement(obj);
obj.implXJob = css.task.XJob.implement(obj);
obj.implXJobExecutor = css.task.XJobExecutor.implement(obj);
obj.acquire();
test.passJob(css.task.XJob.reference(obj.implXJob));
test.passJobExecutor(css.task.XJobExecutor.reference(obj.implXJobExecutor));
- test.passInterface(css.uno.XInterface.reference(obj.implXInterface));
+ test.passInterface(css.uno.XInterface.reference(obj.implXTypeProvider));
obj.release();
});