mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
tools/generate-wire.py: handle optional variable-length fields.
We generated code which didn't compile (we never had one before though). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
7e7358ec1e
commit
eda5314cb5
@@ -453,8 +453,9 @@ class Message(object):
|
||||
# If we're handing a variable array, we need a ptr-to-ptr.
|
||||
if f.needs_ptr_to_ptr():
|
||||
ptrs += '*'
|
||||
# If each type is a variable length, we need a ptr to that.
|
||||
if f.fieldtype.base() in varlen_structs:
|
||||
# If each type is a variable length, we need a ptr to that,
|
||||
# unless it's already optional, so we got one above.
|
||||
if not f.optional and f.fieldtype.base() in varlen_structs:
|
||||
ptrs += '*'
|
||||
|
||||
args.append(', {} {}{}'.format(f.fieldtype.name, ptrs, f.name))
|
||||
@@ -500,7 +501,11 @@ class Message(object):
|
||||
else:
|
||||
if f.optional:
|
||||
assignable = f.fieldtype.is_assignable()
|
||||
deref = '*'
|
||||
# Optional varlens don't need to be derefed twice.
|
||||
if basetype in varlen_structs:
|
||||
deref = ''
|
||||
else:
|
||||
deref = '*'
|
||||
else:
|
||||
deref = ''
|
||||
assignable = f.is_assignable()
|
||||
|
||||
Reference in New Issue
Block a user