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

Side by Side Diff: Source/bindings/scripts/idl_types.py

Issue 1047993002: bindings: Add validation for enum Sequence or Array (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 """IDL type handling. 4 """IDL type handling.
5 5
6 Classes: 6 Classes:
7 IdlTypeBase 7 IdlTypeBase
8 IdlType 8 IdlType
9 IdlUnionType 9 IdlUnionType
10 IdlArrayOrSequenceType 10 IdlArrayOrSequenceType
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return self.base_type in IdlType.dictionaries 173 return self.base_type in IdlType.dictionaries
174 174
175 @property 175 @property
176 def is_enum(self): 176 def is_enum(self):
177 # FIXME: add an IdlEnumType class and a resolve_enums step at end of 177 # FIXME: add an IdlEnumType class and a resolve_enums step at end of
178 # IdlDefinitions constructor 178 # IdlDefinitions constructor
179 return self.name in IdlType.enums 179 return self.name in IdlType.enums
180 180
181 @property 181 @property
182 def enum_values(self): 182 def enum_values(self):
183 return IdlType.enums[self.name] 183 return IdlType.enums.get(self.name)
184 184
185 @property 185 @property
186 def is_integer_type(self): 186 def is_integer_type(self):
187 return self.base_type in INTEGER_TYPES 187 return self.base_type in INTEGER_TYPES
188 188
189 @property 189 @property
190 def is_numeric_type(self): 190 def is_numeric_type(self):
191 return self.base_type in NUMERIC_TYPES 191 return self.base_type in NUMERIC_TYPES
192 192
193 @property 193 @property
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 self.element_type = state['element_type'] 338 self.element_type = state['element_type']
339 339
340 def resolve_typedefs(self, typedefs): 340 def resolve_typedefs(self, typedefs):
341 self.element_type = self.element_type.resolve_typedefs(typedefs) 341 self.element_type = self.element_type.resolve_typedefs(typedefs)
342 return self 342 return self
343 343
344 @property 344 @property
345 def is_array_or_sequence_type(self): 345 def is_array_or_sequence_type(self):
346 return True 346 return True
347 347
348 @property
349 def enum_values(self):
350 return self.element_type.enum_values
351
348 352
349 class IdlArrayType(IdlArrayOrSequenceType): 353 class IdlArrayType(IdlArrayOrSequenceType):
350 def __init__(self, element_type): 354 def __init__(self, element_type):
351 super(IdlArrayType, self).__init__(element_type) 355 super(IdlArrayType, self).__init__(element_type)
352 356
353 def __str__(self): 357 def __str__(self):
354 return '%s[]' % self.element_type 358 return '%s[]' % self.element_type
355 359
356 @property 360 @property
357 def name(self): 361 def name(self):
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 def is_nullable(self): 406 def is_nullable(self):
403 return True 407 return True
404 408
405 @property 409 @property
406 def name(self): 410 def name(self):
407 return self.inner_type.name + 'OrNull' 411 return self.inner_type.name + 'OrNull'
408 412
409 def resolve_typedefs(self, typedefs): 413 def resolve_typedefs(self, typedefs):
410 self.inner_type = self.inner_type.resolve_typedefs(typedefs) 414 self.inner_type = self.inner_type.resolve_typedefs(typedefs)
411 return self 415 return self
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698