From f8b269e7999ddfabea0df8cd210bb1b3ee59367a Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Sat, 20 Sep 2025 22:49:48 -0400 Subject: [PATCH] nouveau/headers: Use previous method for default If a given generation hasn't removed any methods, then the default case can defer to the previous generation without changing the output at all. Reviewed-by: Mary Guillemard Part-of: --- src/nouveau/headers/class_parser.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/nouveau/headers/class_parser.py b/src/nouveau/headers/class_parser.py index feec5e3c552..51a99340635 100644 --- a/src/nouveau/headers/class_parser.py +++ b/src/nouveau/headers/class_parser.py @@ -170,11 +170,15 @@ TEMPLATE_C = Template("""\ <%def name="prev_cases()"> - %for mthd in methods: - %if prev_methods.get(mthd.name, None) == mthd: - ${cases(mthd)} - %endif - %endfor + %if any_method_removed: + %for mthd in methods: + %if prev_methods.get(mthd.name, None) == mthd: + ${cases(mthd)} + %endif + %endfor + %else: + default: + %endif %if prev_nvcl: @@ -211,8 +215,10 @@ P_PARSE_${nvcl}_MTHD(uint16_t idx) %endif %endfor +%if not prev_nvcl or any_method_removed: default: return "unknown method"; +%endif } } @@ -266,9 +272,11 @@ P_DUMP_${nvcl}_MTHD_DATA(FILE *fp, uint16_t idx, uint32_t data, %endfor break; %endfor +%if not prev_nvcl or any_method_removed: default: fprintf(fp, "%s.VALUE = 0x%x${bs}n", prefix, data); break; +%endif } } """) @@ -631,6 +639,8 @@ def main(): with open(args.prev_in_h, 'r', encoding='utf-8') as f: (prev_version, prev_methods) = parse_header(prev_nvcl, f) + any_method_removed = any(x not in methods for x in prev_methods) + environment = { 'clheader': clheader, 'nvcl': nvcl, @@ -639,6 +649,7 @@ def main(): 'prev_mod': prev_mod, 'prev_methods': prev_methods, 'prev_nvcl': prev_nvcl, + 'any_method_removed': any_method_removed, 'to_camel': to_camel, 'bs': '\\' }