summaryrefslogtreecommitdiff
path: root/lib9p/protogen/h.py
diff options
context:
space:
mode:
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