summaryrefslogtreecommitdiff
path: root/lib9p/core_gen/h.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/core_gen/h.py')
-rw-r--r--lib9p/core_gen/h.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib9p/core_gen/h.py b/lib9p/core_gen/h.py
index 3defcb8..ff070c6 100644
--- a/lib9p/core_gen/h.py
+++ b/lib9p/core_gen/h.py
@@ -192,14 +192,21 @@ def gen_h(versions: set[str], typs: list[idl.UserType]) -> str:
ret += "\t#endif\n"
ret += "#endif\n"
+ # SPECIAL (convenience)
+ ret += "\n"
+ ret += f"#define _LIB9P_ENABLE_stat {c9util.ver_ifdef(next(typ for typ in typs if typ.typname == 'stat').in_versions)}\n"
+
ret += f"""
/* enum version ***************************************************************/
enum {c9util.ident('version')} {{
"""
- fullversions = ["unknown = 0", *sorted(versions)]
- verwidth = max(len(v) for v in fullversions)
- for ver in fullversions:
+ xversions = [
+ "unknown = 0",
+ *sorted(v for v in versions if v != "unknown"),
+ ] # SPECIAL (initialization)
+ verwidth = max(len(v) for v in xversions)
+ for ver in xversions:
if ver in versions:
ret += cutil.ifdef_push(1, c9util.ver_ifdef({ver}))
ret += f"\t{c9util.ver_enum(ver)},"