diff options
author | Hiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp> | 2015-01-29 18:32:20 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-29 21:43:51 +0900 |
commit | effb32153615fc6521a9f43fb637b6c925773281 (patch) | |
tree | 6e85436462a566db67db42985b60da042dee44b8 /tools/pyang_plugins | |
parent | a34228410e645d6e53c9752d8a9122cfa67310b9 (diff) |
config: support enum value and add ietf yang files
Diffstat (limited to 'tools/pyang_plugins')
-rw-r--r-- | tools/pyang_plugins/bgpyang2golang.py | 14 |
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'\ |