Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 self.ref_type = json['$ref'] | 203 self.ref_type = json['$ref'] |
| 204 elif 'enum' in json and json_type == 'string': | 204 elif 'enum' in json and json_type == 'string': |
| 205 if not namespace.allow_inline_enums and not isinstance(parent, Namespace): | 205 if not namespace.allow_inline_enums and not isinstance(parent, Namespace): |
| 206 raise ParseException( | 206 raise ParseException( |
| 207 self, | 207 self, |
| 208 'Inline enum "%s" found in namespace "%s". These are not allowed. ' | 208 'Inline enum "%s" found in namespace "%s". These are not allowed. ' |
| 209 'See crbug.com/472279' % (name, namespace.name)) | 209 'See crbug.com/472279' % (name, namespace.name)) |
| 210 self.property_type = PropertyType.ENUM | 210 self.property_type = PropertyType.ENUM |
| 211 self.enum_values = [EnumValue(value) for value in json['enum']] | 211 self.enum_values = [EnumValue(value) for value in json['enum']] |
| 212 self.cpp_enum_prefix_override = json.get('cpp_enum_prefix_override', None) | 212 self.cpp_enum_prefix_override = json.get('cpp_enum_prefix_override', None) |
| 213 # TODO(tapted): Deprecate non-class enums, make is_class the default and | |
| 214 # delete the next line. See http://crbug.com/612382. | |
| 215 self.is_class = json.get('enum_class', False) | |
|
Devlin
2016/05/19 00:33:12
nit: here, too, I'd prefer this to be enum_class o
tapted
2016/05/19 12:22:33
Done.
| |
| 213 elif json_type == 'any': | 216 elif json_type == 'any': |
| 214 self.property_type = PropertyType.ANY | 217 self.property_type = PropertyType.ANY |
| 215 elif json_type == 'binary': | 218 elif json_type == 'binary': |
| 216 self.property_type = PropertyType.BINARY | 219 self.property_type = PropertyType.BINARY |
| 217 elif json_type == 'boolean': | 220 elif json_type == 'boolean': |
| 218 self.property_type = PropertyType.BOOLEAN | 221 self.property_type = PropertyType.BOOLEAN |
| 219 elif json_type == 'integer': | 222 elif json_type == 'integer': |
| 220 self.property_type = PropertyType.INTEGER | 223 self.property_type = PropertyType.INTEGER |
| 221 elif (json_type == 'double' or | 224 elif (json_type == 'double' or |
| 222 json_type == 'number'): | 225 json_type == 'number'): |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 # Sanity check: platforms should not be an empty list. | 611 # Sanity check: platforms should not be an empty list. |
| 609 if not json['platforms']: | 612 if not json['platforms']: |
| 610 raise ValueError('"platforms" cannot be an empty list') | 613 raise ValueError('"platforms" cannot be an empty list') |
| 611 platforms = [] | 614 platforms = [] |
| 612 for platform_name in json['platforms']: | 615 for platform_name in json['platforms']: |
| 613 for platform_enum in _Enum.GetAll(Platforms): | 616 for platform_enum in _Enum.GetAll(Platforms): |
| 614 if platform_name == platform_enum.name: | 617 if platform_name == platform_enum.name: |
| 615 platforms.append(platform_enum) | 618 platforms.append(platform_enum) |
| 616 break | 619 break |
| 617 return platforms | 620 return platforms |
| OLD | NEW |