summaryrefslogtreecommitdiffhomepage
path: root/tools/pyang_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pyang_plugins')
-rw-r--r--tools/pyang_plugins/bgpyang2golang.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/pyang_plugins/bgpyang2golang.py b/tools/pyang_plugins/bgpyang2golang.py
index bf648124..3c09a356 100644
--- a/tools/pyang_plugins/bgpyang2golang.py
+++ b/tools/pyang_plugins/bgpyang2golang.py
@@ -273,9 +273,19 @@ def emit_typedef(ctx, module):
const_prefix = convert_const_prefix(type_name_org)
print >> o, 'const ('
- print >> o, ' _ = iota'
+
+ already_added_iota = False
for sub in t.substmts:
- print >> o, ' %s_%s' % (const_prefix, sub.arg)
+ if sub.search_one('value'):
+ enum_value_part = " = "+sub.search_one('value').arg
+ else:
+ if already_added_iota:
+ enum_value_part = ""
+ else:
+ enum_value_part = " = iota"
+ already_added_iota = True
+
+ print >> o, ' %s_%s%s' % (const_prefix, sub.arg, enum_value_part)
print >> o, ')'
elif t.arg == 'union':
print >> o, '// typedef for typedef %s:%s'\