pyloxi: uniquify padding member names
diff --git a/py_gen/codegen.py b/py_gen/codegen.py
index 211c71e..67529e0 100644
--- a/py_gen/codegen.py
+++ b/py_gen/codegen.py
@@ -92,6 +92,7 @@
length_member = None
type_members = []
+ pad_count = 0
for member in unified_class['members']:
if member['name'] in ['length', 'len']:
@@ -105,9 +106,12 @@
value=type_values[member['name']]))
else:
# HACK ensure member names are unique
- if member['name'] == "pad" and \
- [x for x in members if x.name == 'pad']:
- m_name = "pad2"
+ if member['name'].startswith("pad"):
+ if pad_count == 0:
+ m_name = 'pad'
+ else:
+ m_name = "pad%d" % pad_count
+ pad_count += 1
else:
m_name = member['name']
members.append(Member(name=m_name,
diff --git a/py_gen/tests.py b/py_gen/tests.py
index 68f8b52..251758c 100644
--- a/py_gen/tests.py
+++ b/py_gen/tests.py
@@ -737,11 +737,11 @@
eth_dst = cd:ef:01:23:45:67,
vlan_vid = 0x0,
vlan_pcp = 0x0,
- pad1 = 0x0,
+ pad = 0x0,
eth_type = 0x0,
ip_dscp = 0x0,
ip_proto = 0x0,
- pad2 = [ 0, 0 ],
+ pad1 = [ 0, 0 ],
ipv4_src = 192.168.3.127,
ipv4_dst = 255.255.255.255,
tcp_src = 0x0,
@@ -756,7 +756,7 @@
flags = 0x0,
actions = [
output { port = OFPP_FLOOD, max_len = 0x0 },
- nicira_dec_ttl { pad = 0x0, pad2 = 0x0 },
+ nicira_dec_ttl { pad = 0x0, pad1 = 0x0 },
bsn_set_tunnel_dst { dst = 0x0 }
]
}"""