Message ID | 20240604153242.251334-4-berrange@redhat.com |
---|---|
State | New |
Headers | show |
Series | Improve mechanism for configuring allowed commands | expand |
Daniel P. Berrangé <berrange@redhat.com> writes: > When we shortly allow custom special feature names to be defined, it > will be valid to include a '-', which must be translated to a '_' > when generating code. > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> > --- > scripts/qapi/gen.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py > index 9c590a1c2e..650efc59ed 100644 > --- a/scripts/qapi/gen.py > +++ b/scripts/qapi/gen.py > @@ -41,7 +41,7 @@ > > > def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str: > - special_features = [f"1u << QAPI_FEATURE_{feat.name.upper()}" > + special_features = [f"1u << QAPI_FEATURE_{feat.name.upper().replace('-','_')}" > for feat in features if feat.is_special()] > return ' | '.join(special_features) or '0' I'd prefer something like f"1 << {c_enum_const('QAPI_FEATURE', feat.name)}"
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 9c590a1c2e..650efc59ed 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -41,7 +41,7 @@ def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str: - special_features = [f"1u << QAPI_FEATURE_{feat.name.upper()}" + special_features = [f"1u << QAPI_FEATURE_{feat.name.upper().replace('-','_')}" for feat in features if feat.is_special()] return ' | '.join(special_features) or '0'
When we shortly allow custom special feature names to be defined, it will be valid to include a '-', which must be translated to a '_' when generating code. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- scripts/qapi/gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)