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 class ParseException(Exception): | 10 class ParseException(Exception): |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 return None | 166 return None |
167 self.choices = [ | 167 self.choices = [ |
168 Type(self, | 168 Type(self, |
169 generate_type_name(choice) or 'choice%s' % i, | 169 generate_type_name(choice) or 'choice%s' % i, |
170 choice, | 170 choice, |
171 namespace, | 171 namespace, |
172 origin) | 172 origin) |
173 for i, choice in enumerate(json['choices'])] | 173 for i, choice in enumerate(json['choices'])] |
174 elif json_type == 'object': | 174 elif json_type == 'object': |
175 if not ( | 175 if not ( |
| 176 'isInstanceOf' in json or |
176 'properties' in json or | 177 'properties' in json or |
177 'additionalProperties' in json or | 178 'additionalProperties' in json or |
178 'functions' in json or | 179 'functions' in json or |
179 'events' in json): | 180 'events' in json): |
180 raise ParseException(self, name + " has no properties or functions") | 181 raise ParseException(self, name + " has no properties or functions") |
181 self.property_type = PropertyType.OBJECT | 182 self.property_type = PropertyType.OBJECT |
182 additional_properties_json = json.get('additionalProperties', None) | 183 additional_properties_json = json.get('additionalProperties', None) |
183 if additional_properties_json is not None: | 184 if additional_properties_json is not None: |
184 self.additional_properties = Type(self, | 185 self.additional_properties = Type(self, |
185 'additionalProperties', | 186 'additionalProperties', |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 def _GetPlatforms(json): | 484 def _GetPlatforms(json): |
484 if 'platforms' not in json: | 485 if 'platforms' not in json: |
485 return None | 486 return None |
486 platforms = [] | 487 platforms = [] |
487 for platform_name in json['platforms']: | 488 for platform_name in json['platforms']: |
488 for platform_enum in _Enum.GetAll(Platforms): | 489 for platform_enum in _Enum.GetAll(Platforms): |
489 if platform_name == platform_enum.name: | 490 if platform_name == platform_enum.name: |
490 platforms.append(platform_enum) | 491 platforms.append(platform_enum) |
491 break | 492 break |
492 return platforms | 493 return platforms |
OLD | NEW |