Skip to content

Commit

Permalink
qapi/events: fix visit_event typing
Browse files Browse the repository at this point in the history
Actually, the arg_type can indeed be Optional.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210201193747.2169670-3-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
jnsnow authored and Markus Armbruster committed Feb 8, 2021
1 parent ec9697a commit 3cc01c5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/qapi/events.py
Expand Up @@ -12,7 +12,7 @@
See the COPYING file in the top-level directory.
"""

from typing import List
from typing import List, Optional

from .common import c_enum_const, c_name, mcgen
from .gen import QAPISchemaModularCVisitor, build_params, ifcontext
Expand All @@ -27,15 +27,15 @@


def build_event_send_proto(name: str,
arg_type: QAPISchemaObjectType,
arg_type: Optional[QAPISchemaObjectType],
boxed: bool) -> str:
return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
'c_name': c_name(name.lower()),
'param': build_params(arg_type, boxed)}


def gen_event_send_decl(name: str,
arg_type: QAPISchemaObjectType,
arg_type: Optional[QAPISchemaObjectType],
boxed: bool) -> str:
return mcgen('''
Expand Down Expand Up @@ -78,7 +78,7 @@ def gen_param_var(typ: QAPISchemaObjectType) -> str:


def gen_event_send(name: str,
arg_type: QAPISchemaObjectType,
arg_type: Optional[QAPISchemaObjectType],
boxed: bool,
event_enum_name: str,
event_emit: str) -> str:
Expand All @@ -99,6 +99,7 @@ def gen_event_send(name: str,
proto=build_event_send_proto(name, arg_type, boxed))

if have_args:
assert arg_type is not None
ret += mcgen('''
QObject *obj;
Visitor *v;
Expand All @@ -114,6 +115,7 @@ def gen_event_send(name: str,
name=name)

if have_args:
assert arg_type is not None
ret += mcgen('''
v = qobject_output_visitor_new(&obj);
''')
Expand Down Expand Up @@ -214,7 +216,7 @@ def visit_event(self,
info: QAPISourceInfo,
ifcond: List[str],
features: List[QAPISchemaFeature],
arg_type: QAPISchemaObjectType,
arg_type: Optional[QAPISchemaObjectType],
boxed: bool) -> None:
with ifcontext(ifcond, self._genh, self._genc):
self._genh.add(gen_event_send_decl(name, arg_type, boxed))
Expand Down

0 comments on commit 3cc01c5

Please sign in to comment.