| 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 8cea17b588af55ed93f5df205ca5076d9bf6080d..d7cb65434bac1af48543bb1500d16b7149d00997 100644
|
| --- a/tools/json_schema_compiler/cc_generator.py
|
| +++ b/tools/json_schema_compiler/cc_generator.py
|
| @@ -434,23 +434,55 @@ class CCGenerator(object):
|
|
|
| if self._IsFundamentalOrFundamentalRef(prop):
|
| if prop.optional:
|
| - (c.Append('%(ctype)s temp;')
|
| - .Append('if (!%s)' %
|
| - cpp_util.GetAsFundamentalValue(
|
| - self._cpp_type_generator.GetReferencedProperty(prop),
|
| - value_var,
|
| - '&temp'))
|
| - .Append(' return %(failure_value)s;')
|
| - .Append('%(dst)s->%(name)s.reset(new %(ctype)s(temp));')
|
| - )
|
| + if prop.serialized_type is None:
|
| + (c.Append('%(ctype)s temp;')
|
| + .Append('if (!%s)' %
|
| + cpp_util.GetAsFundamentalValue(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + value_var,
|
| + '&temp'))
|
| + .Append(' return %(failure_value)s;')
|
| + .Append('%(dst)s->%(name)s.reset(new %(ctype)s(temp));')
|
| + )
|
| + else:
|
| + (c.Append('%(ctype)s temp1;')
|
| + .Append('%(serialized_ctype)s temp2;')
|
| + .Append('if (!%s || !%s)' %
|
| + (cpp_util.GetAsFundamentalValue(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + value_var,
|
| + '&temp1'),
|
| + cpp_util.DoConversion(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + 'temp1',
|
| + '&temp2')))
|
| + .Append(' return %(failure_value)s;')
|
| + .Append('%(dst)s->%(name)s.reset(new %(serialized_ctype)s(temp2));')
|
| + )
|
| +
|
| else:
|
| - (c.Append('if (!%s)' %
|
| - cpp_util.GetAsFundamentalValue(
|
| - self._cpp_type_generator.GetReferencedProperty(prop),
|
| - value_var,
|
| - '&%s->%s' % (dst, prop.unix_name)))
|
| - .Append(' return %(failure_value)s;')
|
| - )
|
| + if prop.serialized_type is None:
|
| + (c.Append('if (!%s)' %
|
| + cpp_util.GetAsFundamentalValue(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + value_var,
|
| + '&%s->%s' % (dst, prop.unix_name)))
|
| + .Append(' return %(failure_value)s;')
|
| + )
|
| + else:
|
| + (c.Append('%(ctype)s temp;')
|
| + .Append('if (!%s || !%s)' %
|
| + (cpp_util.GetAsFundamentalValue(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + value_var,
|
| + '&temp'),
|
| + cpp_util.DoConversion(
|
| + self._cpp_type_generator.GetReferencedProperty(prop),
|
| + 'temp',
|
| + '&%s->%s' % (dst, prop.unix_name))))
|
| + .Append(' return %(failure_value)s;')
|
| + )
|
| +
|
| elif self._IsObjectOrObjectRef(prop):
|
| if prop.optional:
|
| (c.Append('base::DictionaryValue* dictionary = NULL;')
|
| @@ -536,6 +568,8 @@ class CCGenerator(object):
|
| }
|
| if prop.type_ not in (PropertyType.CHOICES, PropertyType.ANY):
|
| sub['ctype'] = self._cpp_type_generator.GetType(prop)
|
| + sub['serialized_ctype'] = self._cpp_type_generator.GetType(
|
| + prop, serialized=True)
|
| sub['value_type'] = cpp_util.GetValueType(self._cpp_type_generator
|
| .GetReferencedProperty(prop).type_)
|
| c.Substitute(sub)
|
|
|