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..c9f3f6c375ab2b2cadc2b9e4a765d395a3efc89d 100644 |
--- a/tools/json_schema_compiler/cc_generator.py |
+++ b/tools/json_schema_compiler/cc_generator.py |
@@ -213,7 +213,7 @@ class CCGenerator(object): |
""" |
c = Code() |
value_var = prop.unix_name + '_value' |
- c.Append('base::Value* %(value_var)s = NULL;') |
+ c.Append('const base::Value* %(value_var)s = NULL;') |
if prop.optional: |
(c.Sblock( |
'if (%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s)) {' |
@@ -453,7 +453,7 @@ class CCGenerator(object): |
) |
elif self._IsObjectOrObjectRef(prop): |
if prop.optional: |
- (c.Append('base::DictionaryValue* dictionary = NULL;') |
+ (c.Append('const base::DictionaryValue* dictionary = NULL;') |
.Append('if (!%(value_var)s->GetAsDictionary(&dictionary))') |
.Append(' return %(failure_value)s;') |
.Append('scoped_ptr<%(ctype)s> temp(new %(ctype)s());') |
@@ -462,7 +462,7 @@ class CCGenerator(object): |
.Append('%(dst)s->%(name)s = temp.Pass();') |
) |
else: |
- (c.Append('base::DictionaryValue* dictionary = NULL;') |
+ (c.Append('const base::DictionaryValue* dictionary = NULL;') |
.Append('if (!%(value_var)s->GetAsDictionary(&dictionary))') |
.Append(' return %(failure_value)s;') |
.Append( |
@@ -475,7 +475,7 @@ class CCGenerator(object): |
c.Append(self._any_helper.Init(prop, value_var, dst) + ';') |
elif self._IsArrayOrArrayRef(prop): |
# util_cc_helper deals with optional and required arrays |
- (c.Append('base::ListValue* list = NULL;') |
+ (c.Append('const base::ListValue* list = NULL;') |
.Append('if (!%(value_var)s->GetAsList(&list))') |
.Append(' return %(failure_value)s;')) |
if prop.item_type.type_ == PropertyType.ENUM: |
@@ -513,8 +513,8 @@ class CCGenerator(object): |
elif prop.type_ == PropertyType.BINARY: |
(c.Append('if (!%(value_var)s->IsType(%(value_type)s))') |
.Append(' return %(failure_value)s;') |
- .Append('base::BinaryValue* binary_value =') |
- .Append(' static_cast<base::BinaryValue*>(%(value_var)s);') |
+ .Append('const base::BinaryValue* binary_value =') |
+ .Append(' static_cast<const base::BinaryValue*>(%(value_var)s);') |
) |
if prop.optional: |
(c.Append('%(dst)s->%(name)s.reset(') |
@@ -554,7 +554,7 @@ class CCGenerator(object): |
c.Append('%(dst)s->%(name)s.reset(new std::vector<' + ( |
self._cpp_type_generator.GetType(prop.item_type) + '>);')) |
accessor = '->' |
- c.Sblock('for (ListValue::iterator it = list->begin(); ' |
+ c.Sblock('for (ListValue::const_iterator it = list->begin(); ' |
'it != list->end(); ++it) {') |
self._GenerateStringToEnumConversion(c, prop.item_type, |
'(*it)', 'enum_temp') |