Chromium Code Reviews| Index: tools/json_schema_compiler/cc_generator.py |
| diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py |
| index aefae686cd245335494a69c6c71803664a4c8ad5..2d6d73d0db7db2672a545b0e49e1aa02598168b1 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -5,6 +5,7 @@ |
| from code import Code |
| from model import PropertyType |
| import cpp_util |
| +import re |
| import schema_util |
| import util_cc_helper |
| @@ -890,8 +891,13 @@ class _Generator(object): |
| (maybe_namespace, classname)) |
| c.Sblock('switch (enum_param) {') |
| for enum_value in self._type_helper.FollowRef(type_).enum_values: |
| + name = enum_value.name |
| + if 'camel_case_enum_to_string' in self._namespace.compiler_options: |
| + name = re.sub("_\S", |
|
not at google - send to devlin
2014/05/13 18:36:35
I don't know the re library well enough to tell wh
David Tseng
2014/05/13 20:10:17
I re-wrote this without re. Hopefully that's clear
|
| + lambda m: m.string[m.start() + 1 : m.end()].upper(), |
| + enum_value.name) |
| (c.Append('case %s: ' % self._type_helper.GetEnumValue(type_, enum_value)) |
| - .Append(' return "%s";' % enum_value.name)) |
| + .Append(' return "%s";' % name)) |
| (c.Append('case %s:' % self._type_helper.GetEnumNoneValue(type_)) |
| .Append(' return "";') |
| .Eblock('}') |