[omniORB] Using omniidl and Windows COM

Duncan Grisby dgrisby@uk.research.att.com
Fri, 01 Mar 2002 16:05:38 +0000


On Wednesday 20 February, Craig Rodrigues wrote:

> - use the omniidl code to parse a list of CORBA idl files,
>   and somehow give me a list of all the valid interfaces
>   and the signatures of each interface.
>   This list could be given as plain text, or some kind
>   of data structure which I could manipulate

That's what omniidl does.

> - run this code within a Windows COM object, maybe using
>   the techniques outlined in:
> http://www.python.org/windows/win32com/COMTutorial/index.htm
> 
> - have a general Windows COM object which can be used to
>   parse CORBA IDL
> 
> What would I have to do with omniidl to get this to work?

It shouldn't be too hard. Look at
src/tool/omniidl/python/omniidl/main.py. That calls functions in the
_omniidl C++ extension module to do the parsing, and runs the
back-ends.

The main thing you need to do is implement the same functionality
wrapped up in a COM object, instead of as a command line program.
There are two complications. First, the omniidl scanner and parser are
not thread safe, so you can't allow more than one client to parse IDL
simultaneously.

The second complication is that on Windows, omniidl is an executable,
rather than a plain Python script like it is on most Unix platforms.
You can't just write a normal Python script that imports the COM stuff
and imports _omniidl, since _omniidl is only available inside the
environment created by omniidl.exe.

To do your COM thing, you'll either have to build omniidl as a Python
extension module (not hard -- look at the omniORBpy make rules to see
how, or use distutils), or tweak main.py to do something different.
That way, you would run omniidl with a new command line argument to
cause it to run your COM server code, rather than the normal omniidl
code.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --