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 26cab3635727ac31dac9973e08aa0d9366275bcf..5d5d21f27cda42d6274bd578819091c438dd0de9 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -946,7 +946,8 @@ class _Generator(object): |
| .Concat(self._GenerateStringToEnumConversion(item_type, |
| '(it)', |
| 'tmp', |
| - failure_value)) |
| + failure_value, |
| + is_ptr=False)) |
| .Append('%s%spush_back(tmp);' % (dst_var, accessor)) |
| .Eblock('}') |
| ) |
| @@ -956,7 +957,8 @@ class _Generator(object): |
| type_, |
| src_var, |
| dst_var, |
| - failure_value): |
| + failure_value, |
| + is_ptr=True): |
| """Returns Code that converts a string type in |src_var| to an enum with |
| type |type_| in |dst_var|. In the generated code, if |src_var| is not |
| a valid enum name then the function will return |failure_value|. |
| @@ -968,8 +970,11 @@ class _Generator(object): |
| cpp_type_namespace = '' |
| if type_.namespace != self._namespace: |
| cpp_type_namespace = '%s::' % type_.namespace.unix_name |
| + accessor = '->' if is_ptr else '.' |
| (c.Append('std::string %s;' % enum_as_string) |
| - .Sblock('if (!%s->GetAsString(&%s)) {' % (src_var, enum_as_string)) |
| + .Sblock('if (!%s%sGetAsString(&%s)) {' % (src_var, |
|
Devlin
2017/03/15 15:25:04
These changes look generally fine, but I'm a littl
jdoerrie
2017/03/24 08:54:37
I was surprised by this as well, but it looks like
|
| + accessor, |
| + enum_as_string)) |
| .Concat(self._GenerateError( |
| '"\'%%(key)s\': expected string, got " + ' + |
| self._util_cc_helper.GetValueTypeString('%%(src_var)s', True))) |
|
Devlin
2017/03/15 15:25:04
We should update this True here to be is_ptr.
jdoerrie
2017/03/24 08:54:37
Done.
|