mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 06:54:30 +01:00
bolt-gen: handle csv inline comments
The bolts don't have in-line comments, but the internal wire message CSVs do. This adds the 'comments' back in to the generated docs.
This commit is contained in:
committed by
Rusty Russell
parent
d7a68b75f1
commit
fe3f4f52a0
@@ -14,10 +14,9 @@ ${i}
|
||||
% for enum_set in enum_sets:
|
||||
enum ${enum_set['name']} {
|
||||
% for msg in enum_set['set']:
|
||||
## TODO: add back comments for a message
|
||||
##% for comment in msg.comments:
|
||||
##/* ${comment} */
|
||||
##% endfor
|
||||
% for comment in msg.msg_comments:
|
||||
/* ${comment} */
|
||||
% endfor
|
||||
${msg.enum_name()} = ${msg.number},
|
||||
% endfor
|
||||
};
|
||||
@@ -32,6 +31,9 @@ const char *${enum_set['name']}_name(int e);
|
||||
% for struct in structs:
|
||||
struct ${struct.struct_name()} {
|
||||
% for f in struct.fields.values():
|
||||
% for c in f.field_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
% if bool(f.len_field_of):
|
||||
<% continue %>
|
||||
% endif
|
||||
@@ -59,11 +61,17 @@ struct ${tlv.name} {
|
||||
/* SUBTYPE: ${subtype.name.upper()} */
|
||||
void towire_${subtype.name}(u8 **p, const struct ${subtype.name} *${subtype.name});
|
||||
bool fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.has_len_fields() else '' }const u8 **cursor, size_t *plen, struct ${subtype.name} *${subtype.name});
|
||||
% for c in subtype.type_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
|
||||
% endfor
|
||||
% endif
|
||||
% for msg in messages:
|
||||
/* WIRE: ${msg.name.upper()} */
|
||||
% for c in msg.msg_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.fields.values() if not f.is_optional])});
|
||||
bool fromwire_${msg.name}(${'const tal_t *ctx, ' if msg.has_len_fields() else ''}const void *p${''.join([f.arg_desc_from() for f in msg.fields.values() if not f.is_optional])});
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ const char *${enum_set['name']}_name(int e)
|
||||
## (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})
|
||||
{
|
||||
@@ -37,7 +40,9 @@ ${static}void towire_${subtype.name}(u8 **p, const struct ${subtype.name} *${sub
|
||||
|
||||
## FIXME: abstract this out? (semi-shared with towire_msg, minus the optional bits)
|
||||
% for f in subtype.fields.values():
|
||||
## FIXME: add field level comments
|
||||
% for c in f.field_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
<%
|
||||
fieldname = '{}->{}'.format(subtype.name,f.name)
|
||||
%> \
|
||||
@@ -66,8 +71,10 @@ ${static}bool fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.has_len
|
||||
${f.type_obj.type_name()} ${f.name};
|
||||
% endfor
|
||||
|
||||
## FIXME: field level comments
|
||||
% for f in subtype.fields.values():
|
||||
% for c in f.field_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
<%
|
||||
fieldname = '{}->{}'.format(subtype.name,f.name)
|
||||
typename = f.type_obj.type_name()
|
||||
@@ -105,12 +112,15 @@ ${static}bool fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.has_len
|
||||
%endif
|
||||
% endfor
|
||||
|
||||
return cursor != NULL;
|
||||
return ${subtype.name};
|
||||
}
|
||||
|
||||
% endfor
|
||||
% for msg in messages:
|
||||
/* WIRE: ${msg.name.upper()} */
|
||||
% for c in msg.msg_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.fields.values() if not f.is_optional])})
|
||||
{
|
||||
## FIXME: we're ignoring TLV's rn
|
||||
@@ -121,7 +131,9 @@ u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.f
|
||||
|
||||
towire_u16(&p, ${msg.enum_name()});
|
||||
% for f in msg.fields.values():
|
||||
## FIXME: add field level comments
|
||||
% for c in f.field_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
% if f.is_array() or f.has_len_field(): ## multiples?
|
||||
% if f.type_obj.has_array_helper():
|
||||
towire_${f.type_obj.name}_array(&p, ${f.name}, ${f.size()});
|
||||
@@ -168,6 +180,9 @@ bool fromwire_${msg.name}(${'const tal_t *ctx, ' if msg.has_len_fields() else ''
|
||||
typename = typename + ' *'
|
||||
type_ = f.type_obj.name
|
||||
%> \
|
||||
% for c in f.field_comments:
|
||||
/* ${c} */
|
||||
% endfor
|
||||
% if f.has_len_field():
|
||||
// 2nd case ${f.name}
|
||||
*${f.name} = ${f.len_field} ? tal_arr(ctx, ${typename}, ${f.len_field}) : NULL;
|
||||
@@ -209,4 +224,3 @@ bool fromwire_${msg.name}(${'const tal_t *ctx, ' if msg.has_len_fields() else ''
|
||||
}
|
||||
|
||||
% endfor
|
||||
##${func_decls}
|
||||
|
||||
Reference in New Issue
Block a user