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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 parent, | 176 parent, |
177 name, | 177 name, |
178 json, | 178 json, |
179 namespace, | 179 namespace, |
180 origin): | 180 origin): |
181 self.name = name | 181 self.name = name |
182 self.namespace = namespace | 182 self.namespace = namespace |
183 self.simple_name = _StripNamespace(self.name, namespace) | 183 self.simple_name = _StripNamespace(self.name, namespace) |
184 self.unix_name = UnixName(self.name) | 184 self.unix_name = UnixName(self.name) |
185 self.description = json.get('description', None) | 185 self.description = json.get('description', None) |
| 186 self.jsexterns = json.get('jsexterns', None) |
186 self.origin = origin | 187 self.origin = origin |
187 self.parent = parent | 188 self.parent = parent |
188 self.instance_of = json.get('isInstanceOf', None) | 189 self.instance_of = json.get('isInstanceOf', None) |
189 | 190 |
190 # TODO(kalman): Only objects need functions/events/properties, but callers | 191 # TODO(kalman): Only objects need functions/events/properties, but callers |
191 # assume that all types have them. Fix this. | 192 # assume that all types have them. Fix this. |
192 self.functions = _GetFunctions(self, json, namespace) | 193 self.functions = _GetFunctions(self, json, namespace) |
193 self.events = _GetEvents(self, json, namespace) | 194 self.events = _GetEvents(self, json, namespace) |
194 self.properties = _GetProperties(self, json, namespace, origin) | 195 self.properties = _GetProperties(self, json, namespace, origin) |
195 | 196 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 self.supports_listeners = options.get('supportsListeners', True) | 311 self.supports_listeners = options.get('supportsListeners', True) |
311 self.supports_rules = options.get('supportsRules', False) | 312 self.supports_rules = options.get('supportsRules', False) |
312 self.supports_dom = options.get('supportsDom', False) | 313 self.supports_dom = options.get('supportsDom', False) |
313 | 314 |
314 def GeneratePropertyFromParam(p): | 315 def GeneratePropertyFromParam(p): |
315 return Property(self, p['name'], p, namespace, origin) | 316 return Property(self, p['name'], p, namespace, origin) |
316 | 317 |
317 self.filters = [GeneratePropertyFromParam(filter_instance) | 318 self.filters = [GeneratePropertyFromParam(filter_instance) |
318 for filter_instance in json.get('filters', [])] | 319 for filter_instance in json.get('filters', [])] |
319 callback_param = None | 320 callback_param = None |
320 for param in json.get('parameters', []): | 321 params = json.get('parameters', []) |
321 if param.get('type') == 'function': | 322 for i, param in enumerate(params): |
| 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 |