Instead of emitting the comment for certain meta-types, simply emit it when introspection name and name differ.
This additionally emits it for arrays, which is fine. Signed-off-by: Markus Armbruster <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <[email protected]> --- docs/devel/qapi-code-gen.rst | 1 + scripts/qapi/introspect.py | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/devel/qapi-code-gen.rst b/docs/devel/qapi-code-gen.rst index 9bd5a3af28..1e89cbbcd7 100644 --- a/docs/devel/qapi-code-gen.rst +++ b/docs/devel/qapi-code-gen.rst @@ -2073,6 +2073,7 @@ Example:: { "name", QLIT_QSTR("30"), }, {} })), + /* "[32]" = UserDefOneList */ QLIT_QDICT(((QLitDictEntry[]) { { "element-type", QLIT_QSTR("32"), }, { "meta-type", QLIT_QSTR("array"), }, diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 644461560c..49d1ed2897 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -253,12 +253,12 @@ def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object], Will be omitted from the output if empty. """ comment: Optional[str] = None - if mtype not in ('command', 'event', 'builtin', 'array'): - if not self._unmask: - # Output a comment to make it easy to map masked names - # back to the source when reading the generated output. - comment = f'"{self._name(name)}" = {name}' - obj['name'] = self._name(name) + introspection_name = self._name(name) + if introspection_name != name: + # Output a comment to make it easy to map masked names + # back to the source when reading the generated output. + comment = f'"{introspection_name}" = {name}' + obj['name'] = introspection_name obj['meta-type'] = mtype if features: obj['features'] = self._gen_features(features) -- 2.55.0
