diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-25 22:53:02 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-01-27 21:34:32 -0700 |
commit | baee9e79e3296332c400749644eb557d6bb8c2a6 (patch) | |
tree | cdfb9705fa2a490c2e4df739a437cf765b57fa1e | |
parent | 90254ad6e0477ff67e488958f0f297c5f85a4c56 (diff) |
lib9p: idl.gen: Obviate the join_lines function
-rwxr-xr-x | lib9p/idl.gen | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib9p/idl.gen b/lib9p/idl.gen index b179415..619c791 100755 --- a/lib9p/idl.gen +++ b/lib9p/idl.gen @@ -40,12 +40,8 @@ def add_prefix(p: str, s: str) -> str: return p + s -def join_lines(*args: str) -> str: - return "\n".join([a.rstrip() for a in args]).rstrip() + "\n" - - -def c_macro(*args: str) -> str: - full = join_lines(*args).rstrip() +def c_macro(full: str) -> str: + full = full.rstrip() assert "\n" in full lines = [l.rstrip() for l in full.split("\n")] width = max(len(l.expandtabs(tabsize=8)) for l in lines[:-1]) @@ -818,16 +814,16 @@ LM_ALWAYS_INLINE static bool marshal_8(struct _marshal_ctx *ctx, uint64_t *val) """ ret += c_macro( - f"#define _MSG_RECV(typ) [{idprefix.upper()}TYP_##typ/2] = {{", - f"\t\t.basesize = sizeof(struct {idprefix}msg_##typ),", - f"\t\t.validate = validate_##typ,", - f"\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_##typ,", - f"\t}}", + f"#define _MSG_RECV(typ) [{idprefix.upper()}TYP_##typ/2] = {{\n" + f"\t\t.basesize = sizeof(struct {idprefix}msg_##typ),\n" + f"\t\t.validate = validate_##typ,\n" + f"\t\t.unmarshal = (_unmarshal_fn_t)unmarshal_##typ,\n" + f"\t}}\n" ) ret += c_macro( - f"#define _MSG_SEND(typ) [{idprefix.upper()}TYP_##typ/2] = {{", - f"\t\t.marshal = (_marshal_fn_t)marshal_##typ,", - f"\t}}", + f"#define _MSG_SEND(typ) [{idprefix.upper()}TYP_##typ/2] = {{\n" + f"\t\t.marshal = (_marshal_fn_t)marshal_##typ,\n" + f"\t}}\n" ) ret += "\n" ret += msg_table("Tmsg", "recv", f"struct _{idprefix}recv_tentry", (0, 0x100, 2)) |