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.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib9p/protogen/h.py b/lib9p/protogen/h.py
index a9f0b39..b0d38bf 100644
--- a/lib9p/protogen/h.py
+++ b/lib9p/protogen/h.py
@@ -442,18 +442,16 @@ def gen_bitfield(typ: idl.Bitfield) -> str:
def gen_struct(typ: idl.Struct) -> str: # and idl.Message
ret = c9util.typename(typ) + " {"
- if not typ.members:
- ret += "};\n"
- return ret
- ret += "\n"
+ if typ.members:
+ ret += "\n"
- typewidth = max(len(c9util.typename(m.typ, m)) for m in typ.members)
+ typewidth = max(len(c9util.typename(m.typ, m)) for m in typ.members)
- for member in typ.members:
- if member.val:
- continue
- ret += cutil.ifdef_push(2, c9util.ver_ifdef(member.in_versions))
- ret += f"\t{c9util.typename(member.typ, member):<{typewidth}} {'*' if member.cnt else ' '}{member.membname};\n"
- ret += cutil.ifdef_pop(1)
+ for member in typ.members:
+ if member.val:
+ continue
+ ret += cutil.ifdef_push(2, c9util.ver_ifdef(member.in_versions))
+ ret += f"\t{c9util.typename(member.typ, member):<{typewidth}} {'*' if member.cnt else ' '}{member.membname};\n"
+ ret += cutil.ifdef_pop(1)
ret += "};\n"
return ret