This is more logical than having keyvar_name and keyvar_type members.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
elif isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
if isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
elif isinstance(ty, idl.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
- s += "switch (%s) {\n" % (parent + ty.keyvar_name)
+ s += "switch (%s) {\n" % (parent + ty.keyvar.name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
s += "case %s:\n" % f.enumname
if not isinstance(keyvar_type, Enumeration):
raise ValueError
- self.keyvar_name = keyvar_name
- self.keyvar_type = keyvar_type
+ kv_kwargs = dict([(x.lstrip('keyvar_'),y) for (x,y) in kwargs.items() if x.startswith('keyvar_')])
+
+ self.keyvar = Field(keyvar_type, keyvar_name, **kv_kwargs)
for f in fields:
# (name, enum, type)
where the currently valid member of the union can be determined based
upon another member in the containing type.
- The KeyedUnion.keyvar_name must contain the name of the member of the
+ The KeyedUnion.keyvar contains an idl.type the member of the
containing type which determines the valid member of the union. The
- member referenced by KeyedUnion.keyvar_name has type
- KeyedUnion.keyvar_type which must be an instance of the Enumeration type.
+ must be an instance of the Enumeration type.
Standard Types
--------------