diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-28 08:13:17 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-28 08:13:17 -0600 |
commit | f898850c2b4fef03f0d175ec052b3725bd406496 (patch) | |
tree | b7b3f7bde3c09cc32bfbe61d6d19d3ba26fe8281 /lib9p/types.gen | |
parent | 9d964629694d821b863a0cd6a6c416fe671d5944 (diff) |
tidy
Diffstat (limited to 'lib9p/types.gen')
-rwxr-xr-x | lib9p/types.gen | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/lib9p/types.gen b/lib9p/types.gen index 70f4697..15936e7 100755 --- a/lib9p/types.gen +++ b/lib9p/types.gen @@ -581,26 +581,23 @@ static inline bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) { ret += ";\n}\n" # vtables ################################################################## - def msg_entry(msg: Struct) -> str: - ret = "" - ret += f"\t\t[{idprefix.upper()}TYP_{msg.name}] = {{\n" - ret += f"\t\t\t.unmarshal_basesize = sizeof({c_typename(idprefix, msg)}),\n" - ret += f"\t\t\t.unmarshal_extrasize = checksize_{msg.name},\n" - ret += f"\t\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_{msg.name},\n" - ret += f"\t\t\t.marshal = (_marshal_fn_t)marshal_{msg.name},\n" - ret += "\t\t},\n" - return ret - ret += f""" /* vtables ********************************************************************/ +#define _MSG(typ) [{idprefix.upper()}TYP_##typ] = {{ \\ + .unmarshal_basesize = sizeof(struct {idprefix}msg_##typ), \\ + .unmarshal_extrasize = checksize_##typ, \\ + .unmarshal = (_unmarshal_fn_t)unmarshal_##typ, \\ + .marshal = (_marshal_fn_t)marshal_##typ, \\ + }} + struct _vtable_version _{idprefix}vtables[LIB9P_VER_NUM] = {{ """ ret += f"\t[{idprefix.upper()}VER_UNINITIALIZED] = {{ .msgs = {{\n" for msg in structs: if msg.name in ["Tversion", "Rversion", "Rerror"]: # SPECIAL - ret += msg_entry(msg) + ret += f"\t\t_MSG({msg.name}),\n" ret += "\t}},\n" for ver in sorted(versions): @@ -608,7 +605,7 @@ struct _vtable_version _{idprefix}vtables[LIB9P_VER_NUM] = {{ for msg in structs: if ver not in msg.msgver: continue - ret += msg_entry(msg) + ret += f"\t\t_MSG({msg.name}),\n" ret += "\t}},\n" ret += "};\n" |