|
|
@ -194,13 +194,13 @@ class Field(object): |
|
|
|
fromwire_impl_templ = """bool fromwire_{name}({ctx}const void *p{args}) |
|
|
|
{{ |
|
|
|
{fields} |
|
|
|
const u8 *cursor = p; |
|
|
|
size_t plen = tal_len(p); |
|
|
|
const u8 *cursor = p; |
|
|
|
size_t plen = tal_len(p); |
|
|
|
|
|
|
|
if (fromwire_u16(&cursor, &plen) != {enum.name}) |
|
|
|
return false; |
|
|
|
if (fromwire_u16(&cursor, &plen) != {enum.name}) |
|
|
|
return false; |
|
|
|
{subcalls} |
|
|
|
return cursor != NULL; |
|
|
|
return cursor != NULL; |
|
|
|
}} |
|
|
|
""" |
|
|
|
|
|
|
@ -212,11 +212,11 @@ towire_header_templ = """u8 *towire_{name}(const tal_t *ctx{args}); |
|
|
|
towire_impl_templ = """u8 *towire_{name}(const tal_t *ctx{args}) |
|
|
|
{{ |
|
|
|
{field_decls} |
|
|
|
u8 *p = tal_arr(ctx, u8, 0); |
|
|
|
towire_u16(&p, {enumname}); |
|
|
|
u8 *p = tal_arr(ctx, u8, 0); |
|
|
|
towire_u16(&p, {enumname}); |
|
|
|
{subcalls} |
|
|
|
|
|
|
|
return memcheck(p, tal_count(p)); |
|
|
|
return memcheck(p, tal_count(p)); |
|
|
|
}} |
|
|
|
""" |
|
|
|
|
|
|
@ -226,7 +226,7 @@ printwire_impl_templ = """void printwire_{name}(const u8 *cursor) |
|
|
|
{{ |
|
|
|
size_t plen = tal_len(cursor); |
|
|
|
|
|
|
|
if (fromwire_u16(&cursor, &plen) != {enum.name}) {{ |
|
|
|
if (fromwire_u16(&cursor, &plen) != {enum.name}) {{ |
|
|
|
printf("WRONG TYPE?!\\n"); |
|
|
|
return; |
|
|
|
}} |
|
|
@ -620,14 +620,14 @@ impl_template = """/* This file was generated by generate-wire.py */ |
|
|
|
|
|
|
|
const char *{enumname}_name(int e) |
|
|
|
{{ |
|
|
|
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)]; |
|
|
|
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)]; |
|
|
|
|
|
|
|
switch ((enum {enumname})e) {{ |
|
|
|
{cases} |
|
|
|
}} |
|
|
|
switch ((enum {enumname})e) {{ |
|
|
|
{cases} |
|
|
|
}} |
|
|
|
|
|
|
|
sprintf(invalidbuf, "INVALID %i", e); |
|
|
|
return invalidbuf; |
|
|
|
sprintf(invalidbuf, "INVALID %i", e); |
|
|
|
return invalidbuf; |
|
|
|
}} |
|
|
|
|
|
|
|
{func_decls} |
|
|
@ -657,11 +657,11 @@ print_template = """/* This file was generated by generate-wire.py */ |
|
|
|
|
|
|
|
void print_message(const u8 *msg) |
|
|
|
{{ |
|
|
|
switch ((enum {enumname})fromwire_peektype(msg)) {{ |
|
|
|
{printcases} |
|
|
|
}} |
|
|
|
switch ((enum {enumname})fromwire_peektype(msg)) {{ |
|
|
|
{printcases} |
|
|
|
}} |
|
|
|
|
|
|
|
printf("UNKNOWN: %s\\n", tal_hex(msg, msg)); |
|
|
|
printf("UNKNOWN: %s\\n", tal_hex(msg, msg)); |
|
|
|
}} |
|
|
|
|
|
|
|
{func_decls} |
|
|
|