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

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

Issue 15677003: Generate externs automatically from json/idl files. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 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
« 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 class ParseException(Exception): 10 class ParseException(Exception):
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return type(other) == type(self) and other.name == self.name 348 return type(other) == type(self) and other.name == self.name
349 349
350 def __ne__(self, other): 350 def __ne__(self, other):
351 return not (self == other) 351 return not (self == other)
352 352
353 class _PropertyTypeInfo(_Enum): 353 class _PropertyTypeInfo(_Enum):
354 def __init__(self, is_fundamental, name): 354 def __init__(self, is_fundamental, name):
355 _Enum.__init__(self, name) 355 _Enum.__init__(self, name)
356 self.is_fundamental = is_fundamental 356 self.is_fundamental = is_fundamental
357 357
358 def __repr__(self):
359 return self.name
360
358 class PropertyType(object): 361 class PropertyType(object):
359 """Enum of different types of properties/parameters. 362 """Enum of different types of properties/parameters.
360 """ 363 """
361 INTEGER = _PropertyTypeInfo(True, "integer") 364 INTEGER = _PropertyTypeInfo(True, "integer")
362 INT64 = _PropertyTypeInfo(True, "int64") 365 INT64 = _PropertyTypeInfo(True, "int64")
363 DOUBLE = _PropertyTypeInfo(True, "double") 366 DOUBLE = _PropertyTypeInfo(True, "double")
364 BOOLEAN = _PropertyTypeInfo(True, "boolean") 367 BOOLEAN = _PropertyTypeInfo(True, "boolean")
365 STRING = _PropertyTypeInfo(True, "string") 368 STRING = _PropertyTypeInfo(True, "string")
366 ENUM = _PropertyTypeInfo(False, "enum") 369 ENUM = _PropertyTypeInfo(False, "enum")
367 ARRAY = _PropertyTypeInfo(False, "array") 370 ARRAY = _PropertyTypeInfo(False, "array")
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 def _GetPlatforms(json): 471 def _GetPlatforms(json):
469 if 'platforms' not in json: 472 if 'platforms' not in json:
470 return None 473 return None
471 platforms = [] 474 platforms = []
472 for platform_name in json['platforms']: 475 for platform_name in json['platforms']:
473 for platform_enum in _Enum.GetAll(Platforms): 476 for platform_enum in _Enum.GetAll(Platforms):
474 if platform_name == platform_enum.name: 477 if platform_name == platform_enum.name:
475 platforms.append(platform_enum) 478 platforms.append(platform_enum)
476 break 479 break
477 return platforms 480 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