mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-28 22:47:02 +00:00
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:
parent
8daabd339e
commit
9926281c05
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue