mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
tools/generate-wire.py: add option to expose tlv_record_type
Next update adds TLV test vectors: without this, we get a warning about them being unused. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
9b88fd4c60
commit
b10e0e08bb
3 changed files with 11 additions and 1 deletions
|
@ -61,6 +61,12 @@ struct ${tlv.struct_name()} {
|
|||
|
||||
% for tlv in tlvs.values():
|
||||
struct ${tlv.struct_name()} *${tlv.struct_name()}_new(const tal_t *ctx);
|
||||
|
||||
% if tlv.name in options.expose_tlv_type:
|
||||
#define TLVS_${tlv.name.upper()}_ARRAY_SIZE ${len(tlv.messages)}
|
||||
extern const struct tlv_record_type tlvs_${tlv.name}[];
|
||||
|
||||
% endif
|
||||
% endfor
|
||||
% if options.expose_subtypes and bool(subtypes):
|
||||
% for subtype in subtypes:
|
||||
|
@ -87,4 +93,5 @@ u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.f
|
|||
bool fromwire_${msg.name}(${'const tal_t *ctx, ' if msg.needs_context() else ''}const void *p${''.join([f.arg_desc_from() for f in msg.fields.values()])});
|
||||
|
||||
% endfor
|
||||
|
||||
#endif /* LIGHTNING_${idem} */
|
||||
|
|
|
@ -200,7 +200,9 @@ static void fromwire_${msg.struct_name()}(const u8 **cursor, size_t *plen, void
|
|||
}
|
||||
% endfor
|
||||
|
||||
static const struct tlv_record_type tlvs_${tlv.name}[] = {
|
||||
<% static = '' if tlv.name in options.expose_tlv_type else 'static '
|
||||
%>\
|
||||
${static}const struct tlv_record_type tlvs_${tlv.name}[] = {
|
||||
% for msg in tlv.messages.values():
|
||||
{ ${msg.number}, towire_${msg.struct_name()}, fromwire_${msg.struct_name()} },
|
||||
% endfor
|
||||
|
|
|
@ -628,6 +628,7 @@ if __name__ == "__main__":
|
|||
parser.add_argument("-P", "--print_wire", help="generate wire printing source files",
|
||||
action="store_true", default=False)
|
||||
parser.add_argument("--page", choices=['header', 'impl'], help="page to print")
|
||||
parser.add_argument('--expose-tlv-type', action='append', default=[])
|
||||
parser.add_argument('header_filename', help='The filename of the header')
|
||||
parser.add_argument('enum_name', help='The name of the enum to produce')
|
||||
parser.add_argument("files", help='Files to read in (or stdin)', nargs=REMAINDER)
|
||||
|
|
Loading…
Add table
Reference in a new issue