summaryrefslogtreecommitdiff
path: root/lib9p/protogen/h.py
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-28 10:03:44 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-28 11:40:22 -0600
commita492c4a31f1c8b2a0d58e24ab957ef3c8f9edfd2 (patch)
tree3af2acfb87cec927da720d1541bac89730cd45b5 /lib9p/protogen/h.py
parentd67db573786da4780653e72879033b9e24e83e28 (diff)
lib9p: idl: Touch up the *.9p files
Diffstat (limited to 'lib9p/protogen/h.py')
-rw-r--r--lib9p/protogen/h.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib9p/protogen/h.py b/lib9p/protogen/h.py
index c84ff02..a9f0b39 100644
--- a/lib9p/protogen/h.py
+++ b/lib9p/protogen/h.py
@@ -361,10 +361,14 @@ enum {c9util.ident('version')} {{
def gen_number(typ: idl.Number) -> str:
ret = f"typedef {c9util.typename(typ.prim)} {c9util.typename(typ)};\n"
- prefix = f"{c9util.IDENT(typ.typname)}_"
- namewidth = max(len(name) for name in typ.vals)
+
+ def cname(base: str) -> str:
+ prefix = f"{typ.typname}_".upper()
+ return c9util.Ident(c9util.add_prefix(prefix, base))
+
+ namewidth = max(len(cname(name)) for name in typ.vals)
for name, val in typ.vals.items():
- ret += f"#define {prefix}{name:<{namewidth}} (({c9util.typename(typ)})UINT{typ.static_size*8}_C({val}))\n"
+ ret += f"#define {cname(name):<{namewidth}} (({c9util.typename(typ)})UINT{typ.static_size*8}_C({val}))\n"
return ret