Re: [Orbit-python-list] How to use IDL unions with orbit-python?
Status: Inactive
Brought to you by:
tack
From: Jochen V. <jv...@we...> - 2002-01-28 23:11:55
|
Hello, thank you for the quick fix. On Mon, Jan 28, 2002 at 09:02:01PM +0100, Johan Dahlin wrote: > m=E5n 2002-01-28 klockan 20.07 skrev Jochen Voss: > > Part of the problem may be the bug, which is > > described at > >=20 > > http://bugs.debian.org/123848 > >=20 > > The access to union members does not follow > > the CORBA python language mapping specification. > > This really should be fixed. > >=20 > Could you try the attached patch and see if it works better for you? Yes, I tried it and it is a big improvement. The _d and _u attributes have the correct names, now. But there are still problems left. I will use the following IDL file to explain. module TestUnion { interface Frosch { enum E2 { A, B }; union MyUnion switch (E2) { case A: long x; case B:=20 string s; }; attribute MyUnion U; }; }; Now, Section 1.3.5 of the CORBA python language mapping says: Union types are mapped to classes with two attributes. [ ... _d and _v are explained ... ] For each branch, there is an additional attribute, which can only be accessed if the branch has been set. This additional attribute seems to be no implemented: voss@tatonka [~/src/python/test-union] python Python 2.1.2 (#1, Jan 18 2002, 18:05:45)=20 [GCC 2.95.4 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import CORBA, TestUnion >>> x=3DTestUnion.Frosch.MyUnion(TestUnion.Frosch.B,"Hallo") >>> x <__main__.MyUnion instance at 0x80a606c> >>> x._d 1 >>> x._v 'Hallo' >>> x.s=20 Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: MyUnion instance has no attribute 's' The way I read section 1.3.5, x.s should have been 'hallo'. Next: the specification continues: [...] * If the discriminant is not listed [in a case label], and there is no default, the value is "None". This does not work, too: voss@tatonka [~/src/python/test-union] python Python 2.1.2 (#1, Jan 18 2002, 18:05:45)=20 [GCC 2.95.4 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import CORBA, TestUnion >>> x=3DTestUnion.Frosch.MyUnion() >>> x._d=3D2 AttributeError: MyUnion instance has no attribute '_v' >>> x._v Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: MyUnion instance has no attribute '_v' Even if it is simply not inplemented, the first error message looks strange. I hope this helps, Jochen --=20 Omm (0)-(0) http://www.mathematik.uni-kl.de/~wwwstoch/voss/privat.html |