| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
| 7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
| 8 | 8 |
| 9 import copy | 9 import copy |
| 10 import json | 10 import json |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 # factory provider. | 70 # factory provider. |
| 71 # | 71 # |
| 72 interface_factories = monitored.Dict('generator.interface_factories', { | 72 interface_factories = monitored.Dict('generator.interface_factories', { |
| 73 }) | 73 }) |
| 74 | 74 |
| 75 # | 75 # |
| 76 # Custom native specs for the dart2js dom. | 76 # Custom native specs for the dart2js dom. |
| 77 # | 77 # |
| 78 _dart2js_dom_custom_native_specs = monitored.Dict( | 78 _dart2js_dom_custom_native_specs = monitored.Dict( |
| 79 'generator._dart2js_dom_custom_native_specs', { | 79 'generator._dart2js_dom_custom_native_specs', { |
| 80 # Decorate the singleton Console object, if present (workers do not have a |
| 81 # console). |
| 82 'Console': "=(typeof console == 'undefined' ? {} : console)", |
| 80 | 83 |
| 81 # Nodes with different tags in different browsers can be listed as multiple | 84 # DOMWindow aliased with global scope. |
| 82 # tags here provided there is not conflict in usage (e.g. browser X has tag | 85 'Window': '@*DOMWindow', |
| 83 # T and no other browser has tag T). | |
| 84 | |
| 85 'DOMApplicationCache': | |
| 86 'ApplicationCache,DOMApplicationCache,OfflineResourceList', | |
| 87 | |
| 88 'MutationObserver': 'MutationObserver,WebkitMutationObserver', | |
| 89 | |
| 90 'TransitionEvent': 'TransitionEvent,WebkitTransitionEvent', | |
| 91 | |
| 92 'WheelEvent': 'WheelEvent,MouseWheelEvent,MouseScrollEvent', | |
| 93 | |
| 94 }, dart2jsOnly=True) | 86 }, dart2jsOnly=True) |
| 95 | 87 |
| 96 def IsRegisteredType(type_name): | 88 def IsRegisteredType(type_name): |
| 97 return type_name in _idl_type_registry | 89 return type_name in _idl_type_registry |
| 98 | 90 |
| 99 def MakeNativeSpec(javascript_binding_name): | 91 def MakeNativeSpec(javascript_binding_name): |
| 100 if javascript_binding_name in _dart2js_dom_custom_native_specs: | 92 if javascript_binding_name in _dart2js_dom_custom_native_specs: |
| 101 return _dart2js_dom_custom_native_specs[javascript_binding_name] | 93 return _dart2js_dom_custom_native_specs[javascript_binding_name] |
| 102 else: | 94 else: |
| 103 # Make the class 'hidden' so it is dynamically patched at runtime. This | 95 # Make the class 'hidden' so it is dynamically patched at runtime. This |
| 104 # is useful for browser compat. | 96 # is useful for browser compat. |
| 105 return javascript_binding_name | 97 return '*' + javascript_binding_name |
| 106 | 98 |
| 107 | 99 |
| 108 def MatchSourceFilter(thing): | 100 def MatchSourceFilter(thing): |
| 109 return 'WebKit' in thing.annotations or 'Dart' in thing.annotations | 101 return 'WebKit' in thing.annotations or 'Dart' in thing.annotations |
| 110 | 102 |
| 111 | 103 |
| 112 class ParamInfo(object): | 104 class ParamInfo(object): |
| 113 """Holder for various information about a parameter of a Dart operation. | 105 """Holder for various information about a parameter of a Dart operation. |
| 114 | 106 |
| 115 Attributes: | 107 Attributes: |
| (...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 type_name, type_data, dart_interface_name, self) | 1577 type_name, type_data, dart_interface_name, self) |
| 1586 | 1578 |
| 1587 if type_data.clazz == 'BasicTypedList': | 1579 if type_data.clazz == 'BasicTypedList': |
| 1588 dart_interface_name = self._renamer.RenameInterface( | 1580 dart_interface_name = self._renamer.RenameInterface( |
| 1589 self._database.GetInterface(type_name)) | 1581 self._database.GetInterface(type_name)) |
| 1590 return BasicTypedListIDLTypeInfo( | 1582 return BasicTypedListIDLTypeInfo( |
| 1591 type_name, type_data, dart_interface_name, self) | 1583 type_name, type_data, dart_interface_name, self) |
| 1592 | 1584 |
| 1593 class_name = '%sIDLTypeInfo' % type_data.clazz | 1585 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 1594 return globals()[class_name](type_name, type_data) | 1586 return globals()[class_name](type_name, type_data) |
| OLD | NEW |