diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 22:27:11 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 22:27:11 +0000 |
commit | a61890ebc4d1d6f558edfe8a03ba6a6c72a16689 (patch) | |
tree | dc8768892744a98ba9386583a1d27fa575e72a15 /tools/json_schema_compiler | |
parent | b39a8db3e8e31029e98075863a38f8c3b188529c (diff) | |
download | chromium_src-a61890ebc4d1d6f558edfe8a03ba6a6c72a16689.zip chromium_src-a61890ebc4d1d6f558edfe8a03ba6a6c72a16689.tar.gz chromium_src-a61890ebc4d1d6f558edfe8a03ba6a6c72a16689.tar.bz2 |
Correct const accessors in base/values.(h|cc)
For problem description and other info please see the BUG page.
This is for DictionaryValue.
BUG=138946
TEST=N/A (no fix & no new feature)
TBR=jar scottbyer achuith agl mnissler davemoore garykac akalin hans bulach phajdan.jr jamesr
Review URL: https://chromiumcodereview.appspot.com/10834004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148833 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler')
-rw-r--r-- | tools/json_schema_compiler/cc_generator.py | 14 | ||||
-rw-r--r-- | tools/json_schema_compiler/util.h | 8 |
2 files changed, 11 insertions, 11 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py index 021dce1..e9318dc 100644 --- a/tools/json_schema_compiler/cc_generator.py +++ b/tools/json_schema_compiler/cc_generator.py @@ -214,7 +214,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)) {' @@ -460,7 +460,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());') @@ -469,7 +469,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( @@ -485,7 +485,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: @@ -523,8 +523,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(') @@ -564,7 +564,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') diff --git a/tools/json_schema_compiler/util.h b/tools/json_schema_compiler/util.h index f0459dc..61148c6 100644 --- a/tools/json_schema_compiler/util.h +++ b/tools/json_schema_compiler/util.h @@ -67,7 +67,7 @@ bool PopulateArrayFromDictionary( const base::DictionaryValue& from, const std::string& name, std::vector<T>* out) { - base::ListValue* list = NULL; + const base::ListValue* list = NULL; if (!from.GetListWithoutPathExpansion(name, &list)) return false; @@ -102,16 +102,16 @@ bool PopulateOptionalArrayFromDictionary( const base::DictionaryValue& from, const std::string& name, scoped_ptr<std::vector<T> >* out) { - base::ListValue* list = NULL; + const base::ListValue* list = NULL; { - base::Value* maybe_list = NULL; + const base::Value* maybe_list = NULL; // Since |name| is optional, its absence is acceptable. However, anything // other than a ListValue is not. if (!from.GetWithoutPathExpansion(name, &maybe_list)) return true; if (!maybe_list->IsType(base::Value::TYPE_LIST)) return false; - list = static_cast<base::ListValue*>(maybe_list); + list = static_cast<const base::ListValue*>(maybe_list); } return PopulateOptionalArrayFromList(*list, out); |