From 12125ec8dc401be747398cc4cecb5c9c26833a8a Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Fri, 19 Jul 2019 11:57:38 -0500 Subject: [PATCH] bolt-gen: small cleanups we were incorrectly printing the references for a subtype case, plus some errant styling,readability changes --- tools/gen/impl_template | 11 ++++++----- tools/generate-bolts.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/gen/impl_template b/tools/gen/impl_template index d106c4d61..518078615 100644 --- a/tools/gen/impl_template +++ b/tools/gen/impl_template @@ -24,18 +24,19 @@ const char *${enum_set['name']}_name(int e) snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e); return invalidbuf; } - % endfor - ## FIXME: extract out partials for the method declarations ## (shared between here and header_template) % for subtype in subtypes: + /* SUBTYPE: ${subtype.name.upper()} */ % for c in subtype.type_comments: /*${c} */ % endfor -<% static = '' if options.expose_subtypes else 'static ' %> -${static}void towire_${subtype.name}(u8 **p, const struct ${subtype.name} *${subtype.name}) +<% + static = '' if options.expose_subtypes else 'static ' +%>\ +${static}void towire_${subtype.name}(u8 **p, const ${subtype.type_name()} *${subtype.name}) { % for f in subtype.get_len_fields(): ${f.type_obj.type_name()} ${f.name} = tal_count(${subtype.name}->${f.len_field_of}); @@ -62,7 +63,7 @@ ${static}void towire_${subtype.name}(u8 **p, const struct ${subtype.name} *${sub % elif f.len_field_of: towire_${f.type_obj.name}(p, ${f.name}); % else: - towire_${f.type_obj.name}(&p, ${'' if f.type_obj.is_assignable() else '*'}${fieldname}); + towire_${f.type_obj.name}(p, ${'' if f.type_obj.is_assignable() else '&'}${fieldname}); % endif % endfor } diff --git a/tools/generate-bolts.py b/tools/generate-bolts.py index 1661b62cc..dc4e42657 100755 --- a/tools/generate-bolts.py +++ b/tools/generate-bolts.py @@ -522,7 +522,7 @@ def main(options, args=None, output=sys.stdout, lines=None): elif token_type.startswith('#'): comment_set.append(token_type[1:]) else: - raise ValueError('Unknown token type {} on line {}:{}'.format(token_type, ln, line)) + raise ValueError("Unknown token type {} on line {}:{}".format(token_type, ln, line)) except StopIteration: pass