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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 self.supports_listeners = options.get('supportsListeners', True) | 310 self.supports_listeners = options.get('supportsListeners', True) |
311 self.supports_rules = options.get('supportsRules', False) | 311 self.supports_rules = options.get('supportsRules', False) |
312 self.supports_dom = options.get('supportsDom', False) | 312 self.supports_dom = options.get('supportsDom', False) |
313 | 313 |
314 def GeneratePropertyFromParam(p): | 314 def GeneratePropertyFromParam(p): |
315 return Property(self, p['name'], p, namespace, origin) | 315 return Property(self, p['name'], p, namespace, origin) |
316 | 316 |
317 self.filters = [GeneratePropertyFromParam(filter_instance) | 317 self.filters = [GeneratePropertyFromParam(filter_instance) |
318 for filter_instance in json.get('filters', [])] | 318 for filter_instance in json.get('filters', [])] |
319 callback_param = None | 319 callback_param = None |
320 for param in json.get('parameters', []): | 320 params = json.get('parameters', []) |
321 if param.get('type') == 'function': | 321 for i in range(len(params)): |
Dan Beam
2017/01/04 03:19:49
params = json.get('parameters', [])
for i, param i
| |
322 param = params[i] | |
323 if param.get('type') == 'function' and i == len(params) - 1: | |
322 if callback_param: | 324 if callback_param: |
323 # No ParseException because the webstore has this. | 325 # No ParseException because the webstore has this. |
324 # Instead, pretend all intermediate callbacks are properties. | 326 # Instead, pretend all intermediate callbacks are properties. |
325 self.params.append(GeneratePropertyFromParam(callback_param)) | 327 self.params.append(GeneratePropertyFromParam(callback_param)) |
326 callback_param = param | 328 callback_param = param |
327 else: | 329 else: |
328 self.params.append(GeneratePropertyFromParam(param)) | 330 self.params.append(GeneratePropertyFromParam(param)) |
329 | 331 |
330 if callback_param: | 332 if callback_param: |
331 self.callback = Function(self, | 333 self.callback = Function(self, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 # Sanity check: platforms should not be an empty list. | 610 # Sanity check: platforms should not be an empty list. |
609 if not json['platforms']: | 611 if not json['platforms']: |
610 raise ValueError('"platforms" cannot be an empty list') | 612 raise ValueError('"platforms" cannot be an empty list') |
611 platforms = [] | 613 platforms = [] |
612 for platform_name in json['platforms']: | 614 for platform_name in json['platforms']: |
613 for platform_enum in _Enum.GetAll(Platforms): | 615 for platform_enum in _Enum.GetAll(Platforms): |
614 if platform_name == platform_enum.name: | 616 if platform_name == platform_enum.name: |
615 platforms.append(platform_enum) | 617 platforms.append(platform_enum) |
616 break | 618 break |
617 return platforms | 619 return platforms |
OLD | NEW |