GNOME Bugzilla – Bug 95591
problem with order of types in typelib for union discriminators?
Last modified: 2004-12-22 21:47:04 UTC
In the everything.idl file, we have the following union definition: union EnumUnion switch (enum Colour { red, green, blue }) { case red: long x; case blue: boolean y; }; This results in the following types being listed by ORBit_small_get_types() in the following order: - IDL:orbit/test/EnumUnion/Colour:1.0 - IDL:orbit/test/EnumUnion:1.0 It would be more useful if the two types were returned in the other order. In my Python bindings, the following occurs while trying to build stubs for these types: 1. get "IDL:orbit/test/EnumUnion/Colour:1.0" typecode 2. create "orbit.test.EnumUnion" module to hold the enumeration. 3. put enum values into the "orbit.test.EnumUnion" module 4. get "IDL:orbit/test/EnumUnion:1.0" typecode 5. create stub and put it in the "orbit.test" module. The result is that the orbit.test.EnumUnion module gets overwritten by the EnumUnion stub. If the typecodes were returned in the opposite order, then the enumeration values would become attributes on the EnumUnion stub (as you would expect).
I think the order of definition in the IDL file, is quite a good order to define things in. Then again the order of container -> children is good as you say; so ... we could insert a special case for this - but we'd need a regression test to ensure that we didn't slip up on this. Feel free to commit a patch to fix it.
I am not too fussed if this gets closed as WONTFIX. I might check if other language binding authors have an opinion on this. It looks fairly trivial to make the change in the idl compiler. Similarly, it would be pretty easy to work around in PyORBit: if tc[i+1]->kind == union and tc[i+1]->discriminant == tc[i]: process tc[i+1] first As far as order of definitions go, the enum is defined at a lower level in the pass tree than the union, so the definition order depends on whether you are doing a pre-order or post-order traversal :)
attachment 11591 [details] [review] on bug 95791 includes a patch to change the type ordering.
Patch from bug 95791 committed to both HEAD and gnome-2-0 branches.