OLD | NEW |
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 Loading... |
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 Loading... |
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) |
OLD | NEW |