Browse Source

bolt-gen: small cleanups

we were incorrectly printing the references for a subtype case, plus
some errant styling,readability changes
pull/2938/head
lisa neigut 6 years ago
committed by Rusty Russell
parent
commit
12125ec8dc
  1. 11
      tools/gen/impl_template
  2. 2
      tools/generate-bolts.py

11
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
}

2
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

Loading…
Cancel
Save