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 e2b069564fda592eeb5a740eb33193e403847c42..48a723e047246e4c54470a9b161a9cd1cfd002d9 100644 |
--- a/tools/json_schema_compiler/cc_generator.py |
+++ b/tools/json_schema_compiler/cc_generator.py |
@@ -420,13 +420,16 @@ class _Generator(object): |
c.Append('scoped_ptr<base::Value> result;') |
for choice in type_.choices: |
choice_var = 'as_%s' % choice.unix_name |
+ # Enums cannot be wrapped with scoped_ptr, but the XXX_NONE enum value |
+ # is equal to 0. |
(c.Sblock('if (%s) {' % choice_var) |
.Append('DCHECK(!result) << "Cannot set multiple choices for %s";' % |
type_.unix_name) |
.Cblock(self._CreateValueFromType('result.reset(%s);', |
choice.name, |
choice, |
- '*%s' % choice_var)) |
+ choice_var, |
+ True)) |
.Eblock('}') |
) |
(c.Append('DCHECK(result) << "Must set at least one choice for %s";' % |