[omniORB] namespace handling when a compiler doesn't support it

David Byron dbyron@coactive.com
Mon, 04 Jan 1999 16:51:21 -0800


>> I am porting OmniORB2 to a compiler that doesn't support namespaces (Diab, 
>for
>> those interested).  The macros for dealing with namespaces when the compiler
>> doesn't put code for a particular namespace in a class.
>
>Orbix (pre-namespace circa ver. 2.2) handled this using concatenation of the 
>module name with the interface name, separated by '_'. This generates:
>
>class foo_yourclass : ...
>{
>  ...
>};
>
>This is similar to the COM mapping in the CORBA interoperability spec, chapter 
>13. However, I don't think that omniORB can support this without changes (don't 
>know how much would be required, but pretty sure you'd have to change omniORB 
>sources in omni2idl).
>
>Look in src/tool/omniidl2/omniORB2_be/o2be_interface.cc (and o2be_constant.cc, 
>etc). This is where the .hh and .cc generators are located.
>
>For instance:
>
>void o2be_interface::produce_hdr(std::fstream &s)
>{
>  ...
>  IND(s); s << "class " << uqname() << "_Helper {\n";
>  ...
>}
>
>See also o2be_name in src/tool/omniidl2/omniORB2_be/o2be.h.
>
>The method fqname() seems to return the fully qualified name (ie. scope name + 
>unqualified name).
>
>If you can change uqname() to test a flag (that indicates whether to use 
>concatenation), and return either the original value of uqname() or return 
>fqname(), it may be pretty simple.
>
>Hope this is helpful.

Thanks for the pointer.  This gets me very close to what I need.  I think the actual place I'll make the change is in o2be_module.cc in o2be_module::produce_hdr().  It generates a _CORBA_MODULE followed by the name of the module.  CORBA_sysdep.h does the 'right thing' depending on whether namespaces are supported or not.  It would be nice if I could make the macro in CORAB_sysdep.h really smart by using __FILE__, but it's inside quotes, and doesn't seem easily messed with, besides including the full path, etc.  To do this properly, I suppose I'd add a command line parameter to omniidl2 to tell it how to behave.  Unfortunately, it makes the generated code platform specific, instead of platform independent.  Or maybe, I'll add a script to my makefile that greps for _CORBA_MODULE and makes the change for me.

Has anyone else run into this problem, and found another solution?

-DB
---
David Byron                     dbyron@coactive.com
Coactive Networks, Inc.         http://www.coactive.com
4000 Bridgeway, Suite 303       voice:(415)289-1722
Sausalito, CA  94965            fax:(415)289-1320