mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
tools/generate-wire.py: fix generation of array of assignable types.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
cb5ad91788
commit
a2ffccd740
@ -243,8 +243,8 @@ class Message(object):
|
|||||||
else:
|
else:
|
||||||
subcalls.append('\tfor (size_t i = 0; i < {}; i++)'
|
subcalls.append('\tfor (size_t i = 0; i < {}; i++)'
|
||||||
.format(num_elems))
|
.format(num_elems))
|
||||||
if f.is_assignable():
|
if f.fieldtype.is_assignable():
|
||||||
subcalls.append('\t\t{}[i] = fromwire_{}(&cursor, plen);'
|
subcalls.append('\t\t({})[i] = fromwire_{}(&cursor, plen);'
|
||||||
.format(name, basetype))
|
.format(name, basetype))
|
||||||
else:
|
else:
|
||||||
ctx = "ctx, " if basetype in varlen_structs else ""
|
ctx = "ctx, " if basetype in varlen_structs else ""
|
||||||
@ -319,8 +319,13 @@ class Message(object):
|
|||||||
.format(basetype, f.name, num_elems))
|
.format(basetype, f.name, num_elems))
|
||||||
else:
|
else:
|
||||||
subcalls.append('\tfor (size_t i = 0; i < {}; i++)\n'
|
subcalls.append('\tfor (size_t i = 0; i < {}; i++)\n'
|
||||||
'\t\ttowire_{}(&p, {} + i);'
|
.format(num_elems))
|
||||||
.format(num_elems, basetype, f.name))
|
if f.fieldtype.is_assignable():
|
||||||
|
subcalls.append('\t\ttowire_{}(&p, {}[i]);'
|
||||||
|
.format(basetype, f.name))
|
||||||
|
else:
|
||||||
|
subcalls.append('\t\ttowire_{}(&p, {} + i);'
|
||||||
|
.format(basetype, f.name))
|
||||||
|
|
||||||
def print_towire(self,is_header):
|
def print_towire(self,is_header):
|
||||||
template = towire_header_templ if is_header else towire_impl_templ
|
template = towire_header_templ if is_header else towire_impl_templ
|
||||||
|
Loading…
Reference in New Issue
Block a user