Re: Duplicate Function in ominiidl-CPP generated code when using AMI for empty Interface

Duncan Grisby via omniORB-list <[email protected]> Sun, 12 Feb 2023 15:38:59 +0000
Newsgroups gmane.comp.corba.omniorb.user
Message-ID <[email protected]>
On Fri, 2023-02-03 at 16:50 +0100, Nico Lochner via omniORB-list wrote:


[...]
> the ominiidl Compiler generates two files, which both of them has the
> following code:
> 
>     class _0RL_poll__00000000 

[...]
> Usually this class gets a name with some random ID before of the
> 00000000 (like _0RL_poll_a8a3b903a412ba74_00000000) which might be
> generated from some kind of hash out of the functions in the
> interface. This makes it unique among the whole project.

Yes, it's based on a hash of the fully-scoped name of the first
operation defined in the file. Here there are no operations, so it
fails to populate the hash.

I've fixed it in the 4_3 branch. I've attached a patch that fixes it.

Thanks for reporting it.

Duncan.

-- 
Duncan Grisby <[email protected]>

_______________________________________________
omniORB-list mailing list
[email protected]
https://www.omniorb-support.com/mailman/listinfo/omniorb-list
poller_name.patch (text/x-patch, 1.5 KB)
Index: omniORB/src/lib/omniORB/python3/omniidl_be/cxx/descriptor.py
===================================================================
--- omniORB/src/lib/omniORB/python3/omniidl_be/cxx/descriptor.py	(revision 6640)
+++ omniORB/src/lib/omniORB/python3/omniidl_be/cxx/descriptor.py	(working copy)
@@ -94,8 +94,9 @@
 class HashVisitor(idlvisitor.AstVisitor):
 
     def __init__(self):
-        self.base_initialised = 0
-    
+        self.base_initialised   = 0
+        self.use_interface_name = 0
+
     def visitAST(self, node):
         for declaration in node.declarations():
             if self.base_initialised:
@@ -103,6 +104,16 @@
             if ast.shouldGenerateCodeForDecl(declaration):
                 declaration.accept(self)
 
+        if not self.base_initialised:
+            # No callables in the whole file!
+            self.use_interface_name = 1
+
+            for declaration in node.declarations():
+                if self.base_initialised:
+                    return
+                if ast.shouldGenerateCodeForDecl(declaration):
+                    declaration.accept(self)
+
     def visitModule(self, node):
         for definition in node.definitions():
             if self.base_initialised:
@@ -110,6 +121,11 @@
             definition.accept(self)
 
     def visitInterface(self, node):
+        if self.use_interface_name:
+            name = node.scopedName()
+            self.initialise_base(name)
+            return
+
         if node.callables() != []:
             name = node.scopedName()