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

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

Issue 1006373003: Generate externs automatically from json/idl files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tyler's Created 5 years, 9 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 | « tools/json_schema_compiler/js_externs_generator.py ('k') | no next file » | 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 import os.path 5 import os.path
6 6
7 from json_parse import OrderedDict 7 from json_parse import OrderedDict
8 from memoize import memoize 8 from memoize import memoize
9 9
10 10
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 def __str__(self): 450 def __str__(self):
451 return repr(self) 451 return repr(self)
452 452
453 453
454 class _PropertyTypeInfo(_Enum): 454 class _PropertyTypeInfo(_Enum):
455 def __init__(self, is_fundamental, name): 455 def __init__(self, is_fundamental, name):
456 _Enum.__init__(self, name) 456 _Enum.__init__(self, name)
457 self.is_fundamental = is_fundamental 457 self.is_fundamental = is_fundamental
458 458
459 def __repr__(self):
460 return self.name
459 461
460 class PropertyType(object): 462 class PropertyType(object):
461 """Enum of different types of properties/parameters. 463 """Enum of different types of properties/parameters.
462 """ 464 """
463 ANY = _PropertyTypeInfo(False, "any") 465 ANY = _PropertyTypeInfo(False, "any")
464 ARRAY = _PropertyTypeInfo(False, "array") 466 ARRAY = _PropertyTypeInfo(False, "array")
465 BINARY = _PropertyTypeInfo(False, "binary") 467 BINARY = _PropertyTypeInfo(False, "binary")
466 BOOLEAN = _PropertyTypeInfo(True, "boolean") 468 BOOLEAN = _PropertyTypeInfo(True, "boolean")
467 CHOICES = _PropertyTypeInfo(False, "choices") 469 CHOICES = _PropertyTypeInfo(False, "choices")
468 DOUBLE = _PropertyTypeInfo(True, "double") 470 DOUBLE = _PropertyTypeInfo(True, "double")
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 # Sanity check: platforms should not be an empty list. 598 # Sanity check: platforms should not be an empty list.
597 if not json['platforms']: 599 if not json['platforms']:
598 raise ValueError('"platforms" cannot be an empty list') 600 raise ValueError('"platforms" cannot be an empty list')
599 platforms = [] 601 platforms = []
600 for platform_name in json['platforms']: 602 for platform_name in json['platforms']:
601 for platform_enum in _Enum.GetAll(Platforms): 603 for platform_enum in _Enum.GetAll(Platforms):
602 if platform_name == platform_enum.name: 604 if platform_name == platform_enum.name:
603 platforms.append(platform_enum) 605 platforms.append(platform_enum)
604 break 606 break
605 return platforms 607 return platforms
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/js_externs_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698