qapi: cope with feature names containing a '-'

When we shortly expose all feature names to code, it will be valid to
include a '-', which must be translated to a '_' for the enum constants.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250205123550.2754387-2-berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2025-02-05 12:35:47 +00:00 committed by Markus Armbruster
parent 208bd43335
commit d8a22e69fe

View file

@ -24,6 +24,7 @@ from typing import (
)
from .common import (
c_enum_const,
c_fname,
c_name,
guardend,
@ -41,7 +42,7 @@ from .source import QAPISourceInfo
def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str:
special_features = [f"1u << QAPI_{feat.name.upper()}"
special_features = [f"1u << {c_enum_const('qapi', feat.name)}"
for feat in features if feat.is_special()]
return ' | '.join(special_features) or '0'