Skip to content

Commit

Permalink
Validator rollup (#36185)
Browse files Browse the repository at this point in the history
* cl/398081751 Use the proto message number instead of index for enums.

* cl/398323481 Two-way sync for PR #36085. No-op, or fixes merge conflicts, if any.

Co-authored-by: honeybadgerdontcare <sedano@google.com>
  • Loading branch information
banaag and honeybadgerdontcare committed Sep 28, 2021
1 parent a66a623 commit ed95c60
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ PASS
| </amp-story-page>
| </amp-story>
| </body>
| </html>
| </html>
16 changes: 16 additions & 0 deletions validator/validator_gen_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,22 @@ def PrintEnumFor(enum_desc, out):
(LocalModuleName(enum_desc.full_name), ','.join([
'%s.%s' % (LocalModuleName(enum_desc.full_name), n) for n in names
])))
out.Line('/** @type (!Object<%s, number>) */' %
LocalModuleName(enum_desc.full_name))
out.Line('%s_NumberByName = {' % LocalModuleName(enum_desc.full_name))
out.PushIndent(2)
for v in enum_desc.values:
out.Line("'%s': %s," % (v.name, v.number))
out.PopIndent()
out.Line('};')
out.Line('/** @type (!Object<number, %s>) */' %
LocalModuleName(enum_desc.full_name))
out.Line('%s_NameByNumber = {' % LocalModuleName(enum_desc.full_name))
out.PushIndent(2)
for v in enum_desc.values:
out.Line("%s: '%s'," % (v.number, v.name))
out.PopIndent()
out.Line('};')


def TagSpecName(tag_spec):
Expand Down

0 comments on commit ed95c60

Please sign in to comment.