@samitouri / QOSamiQemu / commits / 1f02e335e4

qapi/parser: add has_features property

Begin preparing to remove public access to the .features member by introducing a semantic "has features" property instead. Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20260611042332.482979-5-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>

John Snow committed Jun 11, 2026 at 00:23 UTC 1f02e335e42e5f607538eaa49d723c982b294ca2
1 file changed +6 -2
scripts/qapi/parser.py
+6 -2
@@ -555,7 +555,7 @@ class QAPISchemaParser:
555 break
556 # Non-blank line, first of a section
557 if line == 'Features:':
558 - if doc.features:
558 + if doc.has_features:
559 raise QAPIParseError(
560 self, "duplicated 'Features:' line")
561 self.accept(False)
@@ -570,7 +570,7 @@ class QAPISchemaParser:
570 if text:
571 doc.append_line(text)
572 line = self.get_doc_indented(doc)
573 - if not doc.features:
573 + if not doc.has_features:
574 raise QAPIParseError(
575 self, 'feature descriptions expected')
576 no_more_args = True
@@ -741,6 +741,10 @@ class QAPIDoc:
741 # "Since" section
742 self.since: Optional[QAPIDoc.Section] = None
743
744 + @property
745 + def has_features(self) -> bool:
746 + return bool(self.features)
747 +
748 def end(self) -> None:
749 for section in self.all_sections:
750 section.text = section.text.strip('\n')