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

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

Issue 10217018: Alarm resolution changed to minutes and minimum delay added. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Made ValidateDelayTime global and used GetExtension instead. Created 8 years, 7 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
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 sys 10 import sys
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 prop: the property the code is populating. 448 prop: the property the code is populating.
449 value_var: a Value* that should represent |prop|. 449 value_var: a Value* that should represent |prop|.
450 dst: the object with |prop| as a member. 450 dst: the object with |prop| as a member.
451 failure_value: the value to return if |prop| cannot be extracted from 451 failure_value: the value to return if |prop| cannot be extracted from
452 |value_var| 452 |value_var|
453 check_type: if true, will check if |value_var| is the correct Value::Type 453 check_type: if true, will check if |value_var| is the correct Value::Type
454 """ 454 """
455 c = Code() 455 c = Code()
456 c.Sblock('{') 456 c.Sblock('{')
457 457
458 if check_type and prop.type_ not in (
459 PropertyType.CHOICES, PropertyType.ANY):
460 (c.Append('if (!%(value_var)s->IsType(%(value_type)s))')
461 .Append(' return %(failure_value)s;')
462 )
463
464 if prop.type_.is_fundamental: 458 if prop.type_.is_fundamental:
465 if prop.optional: 459 if prop.optional:
466 (c.Append('%(ctype)s temp;') 460 (c.Append('%(ctype)s temp;')
467 .Append('if (%s)' % 461 .Append('if (%s)' %
468 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp')) 462 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp'))
469 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));') 463 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));')
470 ) 464 )
471 else: 465 else:
472 (c.Append('if (!%s)' % 466 (c.Append('if (!%s)' %
473 cpp_util.GetAsFundamentalValue( 467 cpp_util.GetAsFundamentalValue(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 """Determines if this property is an Object or is a ref to an Object. 644 """Determines if this property is an Object or is a ref to an Object.
651 """ 645 """
652 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 646 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
653 PropertyType.OBJECT) 647 PropertyType.OBJECT)
654 648
655 def _IsArrayOrArrayRef(self, prop): 649 def _IsArrayOrArrayRef(self, prop):
656 """Determines if this property is an Array or is a ref to an Array. 650 """Determines if this property is an Array or is a ref to an Array.
657 """ 651 """
658 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 652 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
659 PropertyType.ARRAY) 653 PropertyType.ARRAY)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698