wire-gen: put tlv's after subtypes

in the output, we need tlv's to come after the subtype declarations
and structs so that a tlv can use a subtype without problems
This commit is contained in:
lisa neigut 2019-04-23 17:40:19 -07:00 committed by Christian Decker
parent 560f45cd7f
commit 8326f6a35c

View File

@ -1496,15 +1496,6 @@ else:
towire_decls = []
fromwire_decls = []
for tlv_field, tlv_messages in tlv_fields.items():
for m in tlv_messages:
towire_decls.append(m.print_towire(options.header, tlv_field))
fromwire_decls.append(m.print_fromwire(options.header, tlv_field))
if not options.header:
towire_decls += build_tlv_towires(tlv_fields)
fromwire_decls += build_tlv_fromwires(tlv_fields)
if not options.header or (options.header and options.subtypes):
subtype_towires = []
subtype_fromwires = []
@ -1516,6 +1507,15 @@ else:
towire_decls += subtype_towires
fromwire_decls += subtype_fromwires
for tlv_field, tlv_messages in tlv_fields.items():
for m in tlv_messages:
towire_decls.append(m.print_towire(options.header, tlv_field))
fromwire_decls.append(m.print_fromwire(options.header, tlv_field))
if not options.header:
towire_decls += build_tlv_towires(tlv_fields)
fromwire_decls += build_tlv_fromwires(tlv_fields)
towire_decls += [m.print_towire(options.header) for m in toplevel_messages + messages_with_option]
fromwire_decls += [m.print_fromwire(options.header) for m in toplevel_messages + messages_with_option]
decls = fromwire_decls + towire_decls
@ -1528,5 +1528,5 @@ print(template.format(
enumname=options.enumname,
formatted_hdr_enums=built_hdr_enums,
formatted_impl_enums=built_impl_enums,
gen_structs=tlv_structs + subtype_structs,
gen_structs=subtype_structs + tlv_structs,
func_decls='\n'.join(decls)))