mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-29 05:13:54 -06:00
qapi: Replace List[str] with Sequence[str] for ifcond
It does happen to be a list (as of now), but we can describe it in more general terms with no loss in accuracy to allow tuples and other constructs. In the future, we can write "ifcond: Sequence[str] = ()" as a default parameter, which we could not do safely with a Mutable type like a List. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210216021809.134886-2-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
91416a4254
commit
2184bca7b1
5 changed files with 21 additions and 20 deletions
|
@ -13,7 +13,7 @@ This work is licensed under the terms of the GNU GPL, version 2.
|
|||
See the COPYING file in the top-level directory.
|
||||
"""
|
||||
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Sequence
|
||||
|
||||
from .common import (
|
||||
c_enum_const,
|
||||
|
@ -337,7 +337,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
|||
def visit_enum_type(self,
|
||||
name: str,
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: List[str],
|
||||
ifcond: Sequence[str],
|
||||
features: List[QAPISchemaFeature],
|
||||
members: List[QAPISchemaEnumMember],
|
||||
prefix: Optional[str]) -> None:
|
||||
|
@ -348,7 +348,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
|||
def visit_array_type(self,
|
||||
name: str,
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: List[str],
|
||||
ifcond: Sequence[str],
|
||||
element_type: QAPISchemaType) -> None:
|
||||
with ifcontext(ifcond, self._genh, self._genc):
|
||||
self._genh.add(gen_visit_decl(name))
|
||||
|
@ -357,7 +357,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
|||
def visit_object_type(self,
|
||||
name: str,
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: List[str],
|
||||
ifcond: Sequence[str],
|
||||
features: List[QAPISchemaFeature],
|
||||
base: Optional[QAPISchemaObjectType],
|
||||
members: List[QAPISchemaObjectTypeMember],
|
||||
|
@ -379,7 +379,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor):
|
|||
def visit_alternate_type(self,
|
||||
name: str,
|
||||
info: Optional[QAPISourceInfo],
|
||||
ifcond: List[str],
|
||||
ifcond: Sequence[str],
|
||||
features: List[QAPISchemaFeature],
|
||||
variants: QAPISchemaVariants) -> None:
|
||||
with ifcontext(ifcond, self._genh, self._genc):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue