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

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: Created 8 years, 8 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 prop: the property the code is populating. 446 prop: the property the code is populating.
447 value_var: a Value* that should represent |prop|. 447 value_var: a Value* that should represent |prop|.
448 dst: the object with |prop| as a member. 448 dst: the object with |prop| as a member.
449 failure_value: the value to return if |prop| cannot be extracted from 449 failure_value: the value to return if |prop| cannot be extracted from
450 |value_var| 450 |value_var|
451 check_type: if true, will check if |value_var| is the correct Value::Type 451 check_type: if true, will check if |value_var| is the correct Value::Type
452 """ 452 """
453 c = Code() 453 c = Code()
454 c.Sblock('{') 454 c.Sblock('{')
455 455
456 if check_type and prop.type_ not in (
457 PropertyType.CHOICES, PropertyType.ANY):
458 (c.Append('if (!%(value_var)s->IsType(%(value_type)s))')
459 .Append(' return %(failure_value)s;')
460 )
Matt Perry 2012/04/25 19:11:06 Why this change?
Matt Tytel 2012/04/30 23:36:21 Ah, I meant to comment on this. This check is too
Matt Perry 2012/04/30 23:51:42 Makes sense, thanks!
461
462 if prop.type_.is_fundamental: 456 if prop.type_.is_fundamental:
463 if prop.optional: 457 if prop.optional:
464 (c.Append('%(ctype)s temp;') 458 (c.Append('%(ctype)s temp;')
465 .Append('if (%s)' % 459 .Append('if (%s)' %
466 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp')) 460 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp'))
467 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));') 461 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));')
468 ) 462 )
469 else: 463 else:
470 (c.Append('if (!%s)' % 464 (c.Append('if (!%s)' %
471 cpp_util.GetAsFundamentalValue( 465 cpp_util.GetAsFundamentalValue(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 """Determines if this property is an Object or is a ref to an Object. 642 """Determines if this property is an Object or is a ref to an Object.
649 """ 643 """
650 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 644 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
651 PropertyType.OBJECT) 645 PropertyType.OBJECT)
652 646
653 def _IsArrayOrArrayRef(self, prop): 647 def _IsArrayOrArrayRef(self, prop):
654 """Determines if this property is an Array or is a ref to an Array. 648 """Determines if this property is an Array or is a ref to an Array.
655 """ 649 """
656 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 650 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
657 PropertyType.ARRAY) 651 PropertyType.ARRAY)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698