[omniORB] omniORBpy: Problem with enumerations

Duncan Grisby duncan at grisby.org
Tue Jan 6 15:22:03 GMT 2004


On Tuesday 6 January, Sebastian Rittau wrote:

> How does omniORB check whether the enum value is valid? Doesn't it use
> the value from EnumItem._v?

It makes sure the enum object belongs to the expected enum. Otherwise,
it wouldn't trap errors where you have two enums:

  enum A { one, two, three };
  enum B { four, five, six };

  void test(in A the_A);

If all omniORB did was check the _v value, I'd be able to call
test(five), and it would think I'd called test(two).

>   I personally I think that it would be nice
> to "fix" this. While I agree that it's generally better to just call
> importIDL once in a program (and this is how I'm changing my program
> now), it might be unavoidable to call it multiple times in certain
> circumstance, e.g. when using multiple modules that all want to parse
> the same IDL file for some reason.

In fact, I'd recommend not using importIDL at all, apart from for
interactive experimentation on the command line. In the vast majority
of cases, the programmer needs to know the IDL to write code that uses
it, so you might as well statically compile the IDL to Python. That
avoids this problem altogether.

> Anyway, I would suggest to document this issue in the section about
> Dynamic importing of IDL in the omniORBpy manual. Something along the
> lines of "Avoid importing the same IDL twice."

I'll add something that mentions it.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list