static/emscripten/uno.js                |   21 ++++++++++-----------
 unotest/source/embindtest/embindtest.js |    8 +++-----
 2 files changed, 13 insertions(+), 16 deletions(-)

New commits:
commit 5459254a88c89af173085e45f425fd739fd63f4e
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Wed Jun 12 14:54:06 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Wed Jun 12 16:30:46 2024 +0200

    Embind: Let unoObject return a css.uno.XInterface reference
    
    ...and confine the _impl map to an internal detail.  Client code should 
have no
    need to access that _impl map (renamed here to impl_interfaces), nor the
    Module.uno_Type_*.reference functions (nor the Module.uno_Type_*.implement
    functions).
    
    Change-Id: Ic9c74f22cedb9b5eeecb42d7c13ee0555e92690d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168732
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    Tested-by: Jenkins

diff --git a/static/emscripten/uno.js b/static/emscripten/uno.js
index fb2c7d591645..d728a27edc21 100644
--- a/static/emscripten/uno.js
+++ b/static/emscripten/uno.js
@@ -23,12 +23,12 @@ Module.unoObject = function(interfaces, obj) {
     }
     obj.impl_implementationId = new Module.uno_Sequence_byte([]);
     obj.queryInterface = function(type) {
-        for (const i in obj._types) {
+        for (const i in obj.impl_typemap) {
             if (i === type.toString()) {
                 return new Module.uno_Any(
                     type,
                     Module['uno_Type_' + i.replace(/\./g, '$')].reference(
-                        obj._impl[obj._types[i]]));
+                        obj.impl_interfaces[obj.impl_typemap[i]]));
             }
         }
         return new Module.uno_Any(Module.uno_Type.Void(), undefined);
@@ -36,7 +36,7 @@ Module.unoObject = function(interfaces, obj) {
     obj.acquire = function() { ++obj.impl_refcount; };
     obj.release = function() {
         if (--obj.impl_refcount === 0) {
-            for (const i in obj._impl) {
+            for (const i in obj.impl_interfaces) {
                 i.delete();
             }
             obj.impl_types.delete();
@@ -45,18 +45,18 @@ Module.unoObject = function(interfaces, obj) {
     };
     obj.getTypes = function() { return obj.impl_types; };
     obj.getImplementationId = function() { return obj.impl_implementationId; };
-    obj._impl = {};
+    obj.impl_interfaces = {};
     interfaces.forEach((i) => {
-        obj._impl[i] = Module['uno_Type_' + i.replace(/\./g, 
'$')].implement(obj);
+        obj.impl_interfaces[i] = Module['uno_Type_' + i.replace(/\./g, 
'$')].implement(obj);
     });
-    obj._types = {};
+    obj.impl_typemap = {};
     const walk = function(td, impl) {
         const name = td.getName();
-        if (!Object.hasOwn(obj._types, name)) {
+        if (!Object.hasOwn(obj.impl_typemap, name)) {
             if (td.getTypeClass() != 
Module.uno.com.sun.star.uno.TypeClass.INTERFACE) {
                 throw new Error('not a UNO interface type: ' + name);
             }
-            obj._types[name] = impl;
+            obj.impl_typemap[name] = impl;
             const bases = 
Module.uno.com.sun.star.reflection.XInterfaceTypeDescription2.query(td)
                   .getBaseTypes();
             for (let i = 0; i !== bases.size(); ++i) {
@@ -74,8 +74,8 @@ Module.unoObject = function(interfaces, obj) {
         td.delete();
     })
     tdmAny.delete();
-    obj.acquire();
-    return obj;
+    return Module.uno.com.sun.star.uno.XInterface.reference(
+        obj.impl_interfaces[obj.impl_typemap['com.sun.star.uno.XInterface']]);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/unotest/source/embindtest/embindtest.js 
b/unotest/source/embindtest/embindtest.js
index db6876a4d7c8..37a83fba9f4e 100644
--- a/unotest/source/embindtest/embindtest.js
+++ b/unotest/source/embindtest/embindtest.js
@@ -658,11 +658,9 @@ Module.addOnPostRun(function() {
             },
             trigger(event) { console.log('Ola ' + event); }
         });
-    test.passJob(css.task.XJob.reference(obj._impl['com.sun.star.task.XJob']));
-    test.passJobExecutor(
-        
css.task.XJobExecutor.reference(obj._impl['com.sun.star.task.XJobExecutor']));
-    
test.passInterface(css.uno.XInterface.reference(obj._impl['com.sun.star.lang.XTypeProvider']));
-    obj.release();
+    test.passJob(css.task.XJob.query(obj));
+    test.passJobExecutor(css.task.XJobExecutor.query(obj));
+    test.passInterface(obj);
     test.StringAttribute = 'hä';
     console.assert(test.StringAttribute === 'hä');
 
commit a17f27e77bef2262ffa9b4e769c71e1c4d4fa6c2
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Wed Jun 12 14:31:01 2024 +0200
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Wed Jun 12 16:30:36 2024 +0200

    Remove leftover work-in-progress line
    
    Change-Id: I0faf224ea51df733cba2edc5e52b1a71c0e96140
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168731
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/static/emscripten/uno.js b/static/emscripten/uno.js
index 4f3b2e69849d..fb2c7d591645 100644
--- a/static/emscripten/uno.js
+++ b/static/emscripten/uno.js
@@ -74,7 +74,6 @@ Module.unoObject = function(interfaces, obj) {
         td.delete();
     })
     tdmAny.delete();
-    obj._types['com.sun.star.uno.XInterface'] = 
'com.sun.star.lang.XTypeProvider';
     obj.acquire();
     return obj;
 };

Reply via email to