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 from copy import copy | 5 from copy import copy |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import posixpath | 8 import posixpath |
| 9 | 9 |
| 10 from data_source import DataSource | 10 from data_source import DataSource |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 self._AddCommonProperties(function_dict, function) | 372 self._AddCommonProperties(function_dict, function) |
| 373 if function.returns: | 373 if function.returns: |
| 374 function_dict['returns'] = self._GenerateType(function.returns) | 374 function_dict['returns'] = self._GenerateType(function.returns) |
| 375 with self._current_node.Descend(function.simple_name): | 375 with self._current_node.Descend(function.simple_name): |
| 376 with self._current_node.Descend('parameters'): | 376 with self._current_node.Descend('parameters'): |
| 377 for param in function.params: | 377 for param in function.params: |
| 378 function_dict['parameters'].append(self._GenerateProperty(param)) | 378 function_dict['parameters'].append(self._GenerateProperty(param)) |
| 379 if function.callback is not None: | 379 if function.callback is not None: |
| 380 # Show the callback as an extra parameter. | 380 # Show the callback as an extra parameter. |
| 381 function_dict['parameters'].append( | 381 function_dict['parameters'].append( |
| 382 self._GenerateCallbackProperty(function.callback)) | 382 self._GenerateCallbackProperty(function.callback, |
| 383 function_dict['callback'])) | |
| 383 if len(function_dict['parameters']) > 0: | 384 if len(function_dict['parameters']) > 0: |
| 384 function_dict['parameters'][-1]['last'] = True | 385 function_dict['parameters'][-1]['last'] = True |
| 385 return function_dict | 386 return function_dict |
| 386 | 387 |
| 387 def _GenerateEvents(self, events): | 388 def _GenerateEvents(self, events): |
| 388 with self._current_node.Descend('events'): | 389 with self._current_node.Descend('events'): |
| 389 return [self._GenerateEvent(e) for e in events.values() | 390 return [self._GenerateEvent(e) for e in events.values() |
| 390 if not e.supports_dom] | 391 if not e.supports_dom] |
| 391 | 392 |
| 392 def _GenerateDomEvents(self, events): | 393 def _GenerateDomEvents(self, events): |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 419 # information stored in |event|. | 420 # information stored in |event|. |
| 420 if event.supports_listeners: | 421 if event.supports_listeners: |
| 421 callback_object = model.Function(parent=event, | 422 callback_object = model.Function(parent=event, |
| 422 name='callback', | 423 name='callback', |
| 423 json={}, | 424 json={}, |
| 424 namespace=event.parent, | 425 namespace=event.parent, |
| 425 origin='') | 426 origin='') |
| 426 callback_object.params = event.params | 427 callback_object.params = event.params |
| 427 if event.callback: | 428 if event.callback: |
| 428 callback_object.callback = event.callback | 429 callback_object.callback = event.callback |
| 429 callback_parameters = self._GenerateCallbackProperty(callback_object) | 430 callback = self._GenerateFunction(callback_object) |
| 431 callback_parameters = self._GenerateCallbackProperty(callback_object, | |
| 432 callback) | |
| 430 callback_parameters['last'] = True | 433 callback_parameters['last'] = True |
| 431 event_dict['byName']['addListener'] = { | 434 event_dict['byName']['addListener'] = { |
| 432 'name': 'addListener', | 435 'name': 'addListener', |
| 433 'callback': self._GenerateFunction(callback_object), | 436 'callback': callback, |
| 434 'parameters': [callback_parameters] | 437 'parameters': [callback_parameters] |
| 435 } | 438 } |
| 436 with self._current_node.Descend(event.simple_name, ignore=('properties',)): | 439 with self._current_node.Descend(event.simple_name, ignore=('properties',)): |
| 437 if event.supports_dom: | 440 if event.supports_dom: |
| 438 # Treat params as properties of the custom Event object associated with | 441 # Treat params as properties of the custom Event object associated with |
| 439 # this DOM Event. | 442 # this DOM Event. |
| 440 event_dict['properties'] += [self._GenerateProperty(param) | 443 event_dict['properties'] += [self._GenerateProperty(param) |
| 441 for param in event.params] | 444 for param in event.params] |
| 442 return event_dict | 445 return event_dict |
| 443 | 446 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 if value is not None: | 507 if value is not None: |
| 505 if isinstance(value, int): | 508 if isinstance(value, int): |
| 506 property_dict['value'] = _FormatValue(value) | 509 property_dict['value'] = _FormatValue(value) |
| 507 else: | 510 else: |
| 508 property_dict['value'] = value | 511 property_dict['value'] = value |
| 509 else: | 512 else: |
| 510 self._RenderTypeInformation(type_, property_dict) | 513 self._RenderTypeInformation(type_, property_dict) |
| 511 | 514 |
| 512 return property_dict | 515 return property_dict |
| 513 | 516 |
| 514 def _GenerateCallbackProperty(self, callback): | 517 def _GenerateCallbackProperty(self, callback, callback_dict): |
|
not at google - send to devlin
2014/07/23 03:25:03
kinda weird to be passing in |callback_dict| when
| |
| 515 property_dict = { | 518 property_dict = { |
| 516 'name': callback.simple_name, | 519 'name': callback.simple_name, |
| 517 'description': callback.description, | 520 'description': callback.description, |
| 518 'optional': callback.optional, | 521 'optional': callback.optional, |
| 519 'is_callback': True, | 522 'callback': callback_dict, |
| 520 'id': _CreateId(callback, 'property'), | 523 'id': _CreateId(callback, 'property'), |
| 521 'simple_type': 'function', | 524 'simple_type': 'function', |
| 522 } | 525 } |
| 523 if (callback.parent is not None and | 526 if (callback.parent is not None and |
| 524 not isinstance(callback.parent, model.Namespace)): | 527 not isinstance(callback.parent, model.Namespace)): |
| 525 property_dict['parentName'] = callback.parent.simple_name | 528 property_dict['parentName'] = callback.parent.simple_name |
| 526 return property_dict | 529 return property_dict |
| 527 | 530 |
| 528 def _RenderTypeInformation(self, type_, dst_dict): | 531 def _RenderTypeInformation(self, type_, dst_dict): |
| 529 with self._current_node.Descend(ignore=('types', 'properties')): | 532 with self._current_node.Descend(ignore=('types', 'properties')): |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 getter = lambda: 0 | 796 getter = lambda: 0 |
| 794 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() | 797 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() |
| 795 return getter | 798 return getter |
| 796 | 799 |
| 797 def Cron(self): | 800 def Cron(self): |
| 798 futures = [] | 801 futures = [] |
| 799 for platform in GetPlatforms(): | 802 for platform in GetPlatforms(): |
| 800 futures += [self._GetImpl(platform, name) | 803 futures += [self._GetImpl(platform, name) |
| 801 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] | 804 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] |
| 802 return Collect(futures, except_pass=FileNotFoundError) | 805 return Collect(futures, except_pass=FileNotFoundError) |
| OLD | NEW |