Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: tools/json_schema_compiler/cc_generator.py

Issue 10837044: Correct const accessors in base/values.(h|cc), Part II (ListValue) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: David's comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/protocol/proto_value_conversions_unittest.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from code import Code 5 from code import Code
6 from model import PropertyType 6 from model import PropertyType
7 import any_helper 7 import any_helper
8 import cpp_util 8 import cpp_util
9 import model 9 import model
10 import schema_util 10 import schema_util
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 c.Concat(self._InitializePropertyToDefault(param, 'params')) 413 c.Concat(self._InitializePropertyToDefault(param, 'params'))
414 414
415 for i, param in enumerate(function.params): 415 for i, param in enumerate(function.params):
416 # Any failure will cause this function to return. If any argument is 416 # Any failure will cause this function to return. If any argument is
417 # incorrect or missing, those following it are not processed. Note that 417 # incorrect or missing, those following it are not processed. Note that
418 # for optional arguments, we allow missing arguments and proceed because 418 # for optional arguments, we allow missing arguments and proceed because
419 # there may be other arguments following it. 419 # there may be other arguments following it.
420 failure_value = 'scoped_ptr<Params>()' 420 failure_value = 'scoped_ptr<Params>()'
421 c.Append() 421 c.Append()
422 value_var = param.unix_name + '_value' 422 value_var = param.unix_name + '_value'
423 (c.Append('base::Value* %(value_var)s = NULL;') 423 (c.Append('const base::Value* %(value_var)s = NULL;')
424 .Append('if (args.Get(%(i)s, &%(value_var)s) &&\n' 424 .Append('if (args.Get(%(i)s, &%(value_var)s) &&\n'
425 ' !%(value_var)s->IsType(base::Value::TYPE_NULL))') 425 ' !%(value_var)s->IsType(base::Value::TYPE_NULL))')
426 .Sblock('{') 426 .Sblock('{')
427 .Concat(self._GeneratePopulatePropertyFromValue( 427 .Concat(self._GeneratePopulatePropertyFromValue(
428 param, value_var, 'params', failure_value)) 428 param, value_var, 'params', failure_value))
429 .Eblock('}') 429 .Eblock('}')
430 ) 430 )
431 if not param.optional: 431 if not param.optional:
432 (c.Sblock('else {') 432 (c.Sblock('else {')
433 .Append('return %s;' % failure_value) 433 .Append('return %s;' % failure_value)
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 """ 835 """
836 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 836 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
837 PropertyType.ARRAY) 837 PropertyType.ARRAY)
838 838
839 def _IsFundamentalOrFundamentalRef(self, prop): 839 def _IsFundamentalOrFundamentalRef(self, prop):
840 """Determines if this property is a Fundamental type or is a ref to a 840 """Determines if this property is a Fundamental type or is a ref to a
841 Fundamental type. 841 Fundamental type.
842 """ 842 """
843 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. 843 return (self._cpp_type_generator.GetReferencedProperty(prop).type_.
844 is_fundamental) 844 is_fundamental)
OLDNEW
« no previous file with comments | « sync/protocol/proto_value_conversions_unittest.cc ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698