[PATCH v2 10/16] scripts/qapi: add QAPISchemaType.is_predefined

Paolo Bonzini
2026-01-08T13:12:52Z

It is impossible to call is_implicit on an enum type from the visitor, because
the QAPISchemaEnumType has already been exploded into its costituent fields.
The Rust backend is also not modular (yet?) so it is not possible to filter
out the builtin module; add a way to query for implicit type names without
having the object itself.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/qapi/schema.py | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 848a7401251..15f5d97418f 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -1243,6 +1243,17 @@ def _def_builtin_type(
# schema.
self._make_array_type(name, None)

+ def is_predefined(self, name: str) -> bool:
+ # See QAPISchema._def_predefineds()
+ entity = self._entity_dict[name]
+ if isinstance(entity, QAPISchemaBuiltinType):
+ return True
+ if entity is self.the_empty_object_type:
+ return True
+ if name == 'QType':
+ return True
+ return False
+
def _def_predefineds(self) -> None:
for t in [('str', 'string', 'char' + POINTER_SUFFIX),
('number', 'number', 'double'),
--
2.52.0