Browse Source

wiregen: Add enums for TLV types so we can call them by their name

Suggested-by: Lisa Neigut <@niftynei>
Signed-off-by: Christian Decker <@cdecker>
paymod-01
Christian Decker 5 years ago
parent
commit
aaa8779bc0
  1. 12
      tools/gen/header_template

12
tools/gen/header_template

@ -119,6 +119,18 @@ bool ${tlv.name}_is_valid(const struct ${tlv.struct_name()} *record,
#define TLVS_${tlv.name.upper()}_ARRAY_SIZE ${len(tlv.messages)}
extern const struct tlv_record_type tlvs_${tlv.name}[];
<%!
def upper(text):
return text.upper()
%>
/* Define an enum with the constants */
enum ${tlv.name}_types {
% for msg in tlv.ordered_msgs():
${msg.struct_name()|upper} = ${msg.number},
% endfor
};
% endif
% endfor
% if options.expose_subtypes and bool(subtypes):

Loading…
Cancel
Save