From a492c4a31f1c8b2a0d58e24ab957ef3c8f9edfd2 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 28 Mar 2025 10:03:44 -0600 Subject: lib9p: idl: Touch up the *.9p files --- lib9p/protogen/h.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib9p/protogen') 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 -- cgit v1.2.3-2-g168b