On Thu, Aug 12, 2021 at 04:48:57PM +0200, Peter Krempa wrote:
Add a cross reference of the enum value name with the string
representation. This allows a quick cross-reference of the values
without having to open the header and implementation files separately.
To achieve this the python checker code at first obtains a list of the
flags and cross-references them when checking the grouping in
syntax-check, thus we are guaranteed to stay in sync.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
scripts/group-qemu-caps.py | 43 +-
src/qemu/qemu_capabilities.c | 816 +++++++++++++++++------------------
2 files changed, 448 insertions(+), 411 deletions(-)
diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py
index 6fad9afc5b..441f430b94 100755
--- a/scripts/group-qemu-caps.py
+++ b/scripts/group-qemu-caps.py
@@ -27,8 +27,33 @@ import subprocess
import sys
+def load_caps_flags(filename, start_regex, end_regex):
+ capsflags = []
+ game_on = False
+
+ with open(filename, "r") as fh:
+ for line in fh:
+ line = line.rstrip("\n")
+ if game_on:
+ if re.search(r'''.*/\* [0-9]+ \*/.*''', line):
+ continue
+ if re.search(r'''^\s*$''', line):
+ continue
+ match = re.search(r'''[ ]+([A-Z_]+)''', line)
Add 0-9 here as well, otherwise it will not work on some of the flags.
+
+ if match:
+ capsflags.append(match[1])
+
+ if re.search(start_regex, line):
+ game_on = True
+ elif game_on and re.search(end_regex, line):
+ game_on = False
+
+ return capsflags
+
+
def regroup_caps(check, filename, start_regex, end_regex,
- trailing_newline, counter_prefix):
+ trailing_newline, counter_prefix, capsflags):
step = 5
original = []
@@ -68,6 +93,12 @@ def regroup_caps(check, filename, start_regex, end_regex,
game_on = False
+ # ensure that flag names in the .c file have the correct flag in the comment
+ if game_on and capsflags:
+ flagname = re.search(r'''.*".*",''', line)
Maybe r'''\s*".*",''' but it does not matter, really.
Otherwise looks fine, except the wrong flags, but those will be fixed
together with the first regex.