diff options
Diffstat (limited to 'lib9p/types.gen')
-rwxr-xr-x | lib9p/types.gen | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib9p/types.gen b/lib9p/types.gen index 1a2d45a..7d74558 100755 --- a/lib9p/types.gen +++ b/lib9p/types.gen @@ -343,8 +343,19 @@ enum {idprefix}version {{ ret += f"const char *{idprefix}version_str(enum {idprefix}version);\n" ret += """ -/* non-message structs ********************************************************/ +/* non-message types **********************************************************/ """ + for bf in just_bitfields(typs): + ret += "\n" + ret += f"typedef uint{bf.static_size*8}_t {c_typename(idprefix, bf)};\n" + vals = dict([ + *reversed([((k or f"_UNUSED_{v}"), f"1<<{v}") for (v, k) in enumerate(bf.bits)]), + *[(k, v) for (k, v) in bf.aliases.items() if v], + ]) + namewidth = max(len(name) for name in vals) + for name, val in vals.items(): + ret += f"#define {idprefix.upper()}{bf.name.upper()}_{name.ljust(namewidth)} (({c_typename(idprefix, bf)})({val}))\n" + for struct in just_structs_nonmsg(typs): all_the_same = len(struct.members) == 0 or all( m.ver == struct.members[0].ver for m in struct.members |