This enables casting subtypes to their parent. Signed-off-by: Matt Coleman <m...@datto.com> --- scripts/hyperv_wmi_generator.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/scripts/hyperv_wmi_generator.py b/scripts/hyperv_wmi_generator.py index d72e5d8ca1..e5e961d2db 100755 --- a/scripts/hyperv_wmi_generator.py +++ b/scripts/hyperv_wmi_generator.py @@ -221,10 +221,10 @@ def report_error(message): def parse_class(block, number): - # expected format: class <name> + # expected format: class <name> : <optional parent> header_items = block[0][1].split() - if len(header_items) != 2: + if len(header_items) not in [2, 4]: report_error("line %d: invalid block header" % (number)) assert header_items[0] == "class" @@ -234,7 +234,13 @@ def parse_class(block, number): if name in wmi_classes_by_name: report_error("class '%s' has already been defined" % name) - properties = [] + if len(header_items) == 4: + parent_class = header_items[3] + if parent_class not in wmi_classes_by_name: + report_error("nonexistent parent class specified: %s" % parent_class) + properties = wmi_classes_by_name[parent_class].properties.copy() + else: + properties = [] for line in block[1:]: # expected format: <type> <name> -- 2.30.0