mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
qapi: rename 'special_features' to 'features'
This updates the QAPI code generation to refer to 'features' instead of 'special_features', in preparation for generalizing their exposure. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250205123550.2754387-4-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Imports tidied up with isort] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
696ae1ac91
commit
ba27dccc04
4 changed files with 18 additions and 26 deletions
|
@ -25,7 +25,7 @@ from .gen import (
|
||||||
QAPIGenC,
|
QAPIGenC,
|
||||||
QAPISchemaModularCVisitor,
|
QAPISchemaModularCVisitor,
|
||||||
build_params,
|
build_params,
|
||||||
gen_special_features,
|
gen_features,
|
||||||
ifcontext,
|
ifcontext,
|
||||||
)
|
)
|
||||||
from .schema import (
|
from .schema import (
|
||||||
|
@ -298,7 +298,7 @@ def gen_register_command(name: str,
|
||||||
''',
|
''',
|
||||||
name=name, c_name=c_name(name),
|
name=name, c_name=c_name(name),
|
||||||
opts=' | '.join(options) or 0,
|
opts=' | '.join(options) or 0,
|
||||||
feats=gen_special_features(features))
|
feats=gen_features(features))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ from .schema import (
|
||||||
from .source import QAPISourceInfo
|
from .source import QAPISourceInfo
|
||||||
|
|
||||||
|
|
||||||
def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str:
|
def gen_features(features: Sequence[QAPISchemaFeature]) -> str:
|
||||||
special_features = [f"1u << {c_enum_const('qapi', feat.name)}"
|
featenum = [f"1u << {c_enum_const('qapi', feat.name)}"
|
||||||
for feat in features if feat.is_special()]
|
for feat in features if feat.is_special()]
|
||||||
return ' | '.join(special_features) or '0'
|
return ' | '.join(featenum) or '0'
|
||||||
|
|
||||||
|
|
||||||
class QAPIGen:
|
class QAPIGen:
|
||||||
|
|
|
@ -16,11 +16,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from .common import c_enum_const, c_name, mcgen
|
from .common import c_enum_const, c_name, mcgen
|
||||||
from .gen import (
|
from .gen import QAPISchemaModularCVisitor, gen_features, ifcontext
|
||||||
QAPISchemaModularCVisitor,
|
|
||||||
gen_special_features,
|
|
||||||
ifcontext,
|
|
||||||
)
|
|
||||||
from .schema import (
|
from .schema import (
|
||||||
QAPISchema,
|
QAPISchema,
|
||||||
QAPISchemaAlternatives,
|
QAPISchemaAlternatives,
|
||||||
|
@ -61,12 +57,12 @@ const QEnumLookup %(c_name)s_lookup = {
|
||||||
index=index, name=memb.name)
|
index=index, name=memb.name)
|
||||||
ret += memb.ifcond.gen_endif()
|
ret += memb.ifcond.gen_endif()
|
||||||
|
|
||||||
special_features = gen_special_features(memb.features)
|
features = gen_features(memb.features)
|
||||||
if special_features != '0':
|
if features != '0':
|
||||||
feats += mcgen('''
|
feats += mcgen('''
|
||||||
[%(index)s] = %(special_features)s,
|
[%(index)s] = %(features)s,
|
||||||
''',
|
''',
|
||||||
index=index, special_features=special_features)
|
index=index, features=features)
|
||||||
|
|
||||||
if feats:
|
if feats:
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
|
|
|
@ -21,11 +21,7 @@ from .common import (
|
||||||
indent,
|
indent,
|
||||||
mcgen,
|
mcgen,
|
||||||
)
|
)
|
||||||
from .gen import (
|
from .gen import QAPISchemaModularCVisitor, gen_features, ifcontext
|
||||||
QAPISchemaModularCVisitor,
|
|
||||||
gen_special_features,
|
|
||||||
ifcontext,
|
|
||||||
)
|
|
||||||
from .schema import (
|
from .schema import (
|
||||||
QAPISchema,
|
QAPISchema,
|
||||||
QAPISchemaAlternatives,
|
QAPISchemaAlternatives,
|
||||||
|
@ -103,15 +99,15 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
''',
|
''',
|
||||||
name=memb.name, has=has)
|
name=memb.name, has=has)
|
||||||
indent.increase()
|
indent.increase()
|
||||||
special_features = gen_special_features(memb.features)
|
features = gen_features(memb.features)
|
||||||
if special_features != '0':
|
if features != '0':
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
if (visit_policy_reject(v, "%(name)s", %(special_features)s, errp)) {
|
if (visit_policy_reject(v, "%(name)s", %(features)s, errp)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!visit_policy_skip(v, "%(name)s", %(special_features)s)) {
|
if (!visit_policy_skip(v, "%(name)s", %(features)s)) {
|
||||||
''',
|
''',
|
||||||
name=memb.name, special_features=special_features)
|
name=memb.name, features=features)
|
||||||
indent.increase()
|
indent.increase()
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {
|
if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) {
|
||||||
|
@ -120,7 +116,7 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
|
||||||
''',
|
''',
|
||||||
c_type=memb.type.c_name(), name=memb.name,
|
c_type=memb.type.c_name(), name=memb.name,
|
||||||
c_name=c_name(memb.name))
|
c_name=c_name(memb.name))
|
||||||
if special_features != '0':
|
if features != '0':
|
||||||
indent.decrease()
|
indent.decrease()
|
||||||
ret += mcgen('''
|
ret += mcgen('''
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue