[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 6 of 8] libxl: add KeyedUnion type
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1280829586 -3600 # Node ID 5d51a404379e3e91c08c07c8292abefa1440a655 # Parent c87dd259a8ed069d8786aadf9e1f6e555aa6778e libxl: add KeyedUnion type Use this to express the construct where a union is differentiated on a variable in the containing struct. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r c87dd259a8ed -r 5d51a404379e tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Tue Aug 03 10:59:46 2010 +0100 +++ b/tools/libxl/libxltypes.py Tue Aug 03 10:59:46 2010 +0100 @@ -35,12 +35,13 @@ class BitField(Type): class Field(Type): """An element of an Aggregate type""" - def __init__(self, type, name, const = False, comment = None): + def __init__(self, type, name, const = False, comment = None, keyvar_expr = None): Type.__init__(self,type.typename) self.type = type self.name = name self.const = const self.comment = comment + self.keyvar_expr = keyvar_expr class Aggregate(Type): """A type containing a collection of other types""" @@ -79,6 +80,19 @@ class KeyValueList(Type): Type.__init__(self, "char **", namespace = None) +class KeyedUnion(Aggregate): + """A union which is keyed of another variable""" + def __init__(self, name, keyvar_name, fields, comment = None): + self.keyvar = keyvar_name + Aggregate.__init__(self, "union", name, [], comment) + for f in fields: + # (name, keyvar_expr, type) + + # keyvar_expr must contain exactly one %s which will be replaced with the keyvar_name + + n, kve, ty = f + self.fields.append(Field(ty, n, False, None, kve)) + class Reference(Type): """A reference to another type""" def __init__(self, ty): @@ -199,26 +213,26 @@ libxl_domain_build_info = Struct("domain ("disable_migrate", bool), ("kernel", libxl_file_reference), ("hvm", integer), - ("u", Union(None, - [("hvm", Struct(None, - [("pae", bool), - ("apic", bool), - ("acpi", bool), - ("nx", bool), - ("viridian", bool), - ("timeoffset", string), - ("hpet", bool), - ("vpt_align", bool), - ("timer_mode", integer), - ])), - ("pv", Struct(None, - [("slack_memkb", uint32), - ("bootloader", string, True), - ("bootloader_args", string, True), - ("cmdline", string), - ("ramdisk", libxl_file_reference), - ("features", string, True), - ])), + ("u", KeyedUnion(None, "hvm", + [("hvm", "%s", Struct(None, + [("pae", bool), + ("apic", bool), + ("acpi", bool), + ("nx", bool), + ("viridian", bool), + ("timeoffset", string), + ("hpet", bool), + ("vpt_align", bool), + ("timer_mode", integer), + ])), + ("pv", "!%s", Struct(None, + [("slack_memkb", uint32), + ("bootloader", string, True), + ("bootloader_args", string, True), + ("cmdline", string), + ("ramdisk", libxl_file_reference), + ("features", string, True), + ])), ])), ], comment = _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |