| Index: tools/json_schema_compiler/cpp_type_generator.py
|
| diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
|
| index 1a1821d96084fae325167821115e07d6a1431c9d..1de8d16ebc2388d83304e16477560abdc7991b0c 100644
|
| --- a/tools/json_schema_compiler/cpp_type_generator.py
|
| +++ b/tools/json_schema_compiler/cpp_type_generator.py
|
| @@ -119,6 +119,7 @@ class CppTypeGenerator(object):
|
| optional.
|
| """
|
| cpp_type = None
|
| + force_wrapping = False
|
| if prop.type_ == PropertyType.REF:
|
| dependency_namespace = self._ResolveTypeNamespace(prop.ref_type)
|
| if not dependency_namespace:
|
| @@ -156,13 +157,17 @@ class CppTypeGenerator(object):
|
| cpp_type = cpp_type % self.GetType(
|
| prop.item_type, pad_for_generics=True)
|
| elif prop.type_ == PropertyType.BINARY:
|
| + # Since base::BinaryValue's are immutable, we wrap them in a scoped_ptr to
|
| + # allow them to be modified after the fact.
|
| + force_wrapping = True
|
| cpp_type = 'base::BinaryValue'
|
| else:
|
| raise NotImplementedError(prop.type_)
|
|
|
| # Enums aren't wrapped because C++ won't allow it. Optional enums have a
|
| # NONE value generated instead.
|
| - if wrap_optional and prop.optional and prop.type_ != PropertyType.ENUM:
|
| + if force_wrapping or (wrap_optional and prop.optional and prop.type_ !=
|
| + PropertyType.ENUM):
|
| cpp_type = 'scoped_ptr<%s> ' % cpp_type
|
| if pad_for_generics:
|
| return cpp_type
|
|
|