scripts: use build_ prefix for string not piped through cgen()

The gen_ prefix is awkward. Generated C should go through cgen()
exactly once (see commit 1f9a7a1). The common way to get this wrong is
passing a foo=gen_foo() keyword argument to mcgen(). I'd like us to
adopt a naming convention where gen_ means "something that's been piped
through cgen(), and thus must not be passed to cgen() or mcgen()".
Requires renaming gen_params(), gen_marshal_proto() and
gen_event_send_proto().

Backports commit 086ee7a6200fa5ad795b12110b5b3d5a93dcac3e from qemu
This commit is contained in:
Marc-André Lureau 2018-03-03 22:11:21 -05:00 committed by Lioncash
parent 8daabd339e
commit 9926281c05
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 6 additions and 6 deletions

View file

@ -13,7 +13,7 @@
from qapi import *
def gen_event_send_proto(name, arg_type, boxed):
def build_event_send_proto(name, arg_type, boxed):
return 'void qapi_event_send_%(c_name)s(%(param)s)' % {
'c_name': c_name(name.lower()),
'param': gen_params(arg_type, boxed, 'Error **errp')}
@ -24,10 +24,10 @@ def gen_event_send_decl(name, arg_type, boxed):
%(proto)s;
''',
proto=gen_event_send_proto(name, arg_type, boxed))
proto=build_event_send_proto(name, arg_type, boxed))
# Declare and initialize an object 'qapi' using parameters from gen_params()
# Declare and initialize an object 'qapi' using parameters from build_params()
def gen_param_var(typ):
assert not typ.variants
ret = mcgen('''
@ -41,7 +41,7 @@ def gen_param_var(typ):
if memb.optional:
ret += 'has_' + c_name(memb.name) + sep
if memb.type.name == 'str':
# Cast away const added in gen_params()
# Cast away const added in build_params()
ret += '(char *)'
ret += c_name(memb.name)
ret += mcgen('''
@ -71,7 +71,7 @@ def gen_event_send(name, arg_type, boxed):
Error *err = NULL;
QMPEventFuncEmit emit;
''',
proto=gen_event_send_proto(name, arg_type, boxed))
proto=build_event_send_proto(name, arg_type, boxed))
if arg_type and not arg_type.is_empty():
assert not arg_type.variants

View file

@ -1897,7 +1897,7 @@ extern const char *const %(c_name)s_lookup[];
return ret
def gen_params(arg_type, boxed, extra):
def build_params(arg_type, boxed, extra):
if not arg_type:
assert not boxed
return extra