summaryrefslogtreecommitdiff
path: root/lib9p/idl.gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/idl.gen')
-rwxr-xr-xlib9p/idl.gen24
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))