| 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 re | 10 import re |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 'Int8Array': '_TypedArrayFactoryProvider', | 49 'Int8Array': '_TypedArrayFactoryProvider', |
| 50 'Int16Array': '_TypedArrayFactoryProvider', | 50 'Int16Array': '_TypedArrayFactoryProvider', |
| 51 'Int32Array': '_TypedArrayFactoryProvider', | 51 'Int32Array': '_TypedArrayFactoryProvider', |
| 52 'Uint8Array': '_TypedArrayFactoryProvider', | 52 'Uint8Array': '_TypedArrayFactoryProvider', |
| 53 'Uint16Array': '_TypedArrayFactoryProvider', | 53 'Uint16Array': '_TypedArrayFactoryProvider', |
| 54 'Uint32Array': '_TypedArrayFactoryProvider', | 54 'Uint32Array': '_TypedArrayFactoryProvider', |
| 55 'Uint8ClampedArray': '_TypedArrayFactoryProvider', | 55 'Uint8ClampedArray': '_TypedArrayFactoryProvider', |
| 56 } | 56 } |
| 57 | 57 |
| 58 # | 58 # |
| 59 # Custom native specs for the Frog dom. | 59 # Custom native specs for the dart2js dom. |
| 60 # | 60 # |
| 61 _frog_dom_custom_native_specs = { | 61 _dart2js_dom_custom_native_specs = { |
| 62 # Decorate the singleton Console object, if present (workers do not have a | 62 # Decorate the singleton Console object, if present (workers do not have a |
| 63 # console). | 63 # console). |
| 64 'Console': "=(typeof console == 'undefined' ? {} : console)", | 64 'Console': "=(typeof console == 'undefined' ? {} : console)", |
| 65 | 65 |
| 66 # DOMWindow aliased with global scope. | 66 # DOMWindow aliased with global scope. |
| 67 'DOMWindow': '@*DOMWindow', | 67 'DOMWindow': '@*DOMWindow', |
| 68 } | 68 } |
| 69 | 69 |
| 70 # | 70 # |
| 71 # Custom native bodies for frog implementations of dom operations that | 71 # Custom native bodies for dart2js implementations of dom operations that |
| 72 # appear in dart:dom_deprecated and dart:html. This is used to | 72 # appear in dart:dom_deprecated and dart:html. This is used to |
| 73 # work-around the lack of a 'rename' feature in the 'native' string - | 73 # work-around the lack of a 'rename' feature in the 'native' string - |
| 74 # the correct name is available on the DartName extended | 74 # the correct name is available on the DartName extended |
| 75 # attribute. See Issue 1814 | 75 # attribute. See Issue 1814 |
| 76 # | 76 # |
| 77 dom_frog_native_bodies = { | 77 dom_dart2js_native_bodies = { |
| 78 # Some JavaScript processors, especially tools like yuicompress and | 78 # Some JavaScript processors, especially tools like yuicompress and |
| 79 # JSCompiler, choke on 'this.continue' | 79 # JSCompiler, choke on 'this.continue' |
| 80 'IDBCursor.continueFunction': | 80 'IDBCursor.continueFunction': |
| 81 """ | 81 """ |
| 82 if (key == null) return this['continue'](); | 82 if (key == null) return this['continue'](); |
| 83 return this['continue'](key); | 83 return this['continue'](key); |
| 84 """, | 84 """, |
| 85 } | 85 } |
| 86 | 86 |
| 87 def IsRegisteredType(type_name): | 87 def IsRegisteredType(type_name): |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 for parent in interface.parents: | 145 for parent in interface.parents: |
| 146 if database.HasInterface(parent.type.id): | 146 if database.HasInterface(parent.type.id): |
| 147 parent_interface = database.GetInterface(parent.type.id) | 147 parent_interface = database.GetInterface(parent.type.id) |
| 148 element_type = MaybeTypedArrayElementType(parent_interface) | 148 element_type = MaybeTypedArrayElementType(parent_interface) |
| 149 if element_type: | 149 if element_type: |
| 150 return element_type | 150 return element_type |
| 151 | 151 |
| 152 return None | 152 return None |
| 153 | 153 |
| 154 def MakeNativeSpec(javascript_binding_name): | 154 def MakeNativeSpec(javascript_binding_name): |
| 155 if javascript_binding_name in _frog_dom_custom_native_specs: | 155 if javascript_binding_name in _dart2js_dom_custom_native_specs: |
| 156 return _frog_dom_custom_native_specs[javascript_binding_name] | 156 return _dart2js_dom_custom_native_specs[javascript_binding_name] |
| 157 else: | 157 else: |
| 158 # Make the class 'hidden' so it is dynamically patched at runtime. This | 158 # Make the class 'hidden' so it is dynamically patched at runtime. This |
| 159 # is useful not only for browser compat, but to allow code that links | 159 # is useful not only for browser compat, but to allow code that links |
| 160 # against dart:dom_deprecated to load in a worker isolate. | 160 # against dart:dom_deprecated to load in a worker isolate. |
| 161 return '*' + javascript_binding_name | 161 return '*' + javascript_binding_name |
| 162 | 162 |
| 163 | 163 |
| 164 def MatchSourceFilter(thing): | 164 def MatchSourceFilter(thing): |
| 165 return 'WebKit' in thing.annotations or 'Dart' in thing.annotations | 165 return 'WebKit' in thing.annotations or 'Dart' in thing.annotations |
| 166 | 166 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 if match: | 835 if match: |
| 836 if type_name == 'DOMString[]': | 836 if type_name == 'DOMString[]': |
| 837 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) | 837 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) |
| 838 item_info = self.TypeInfo(match.group(1) or match.group(2)) | 838 item_info = self.TypeInfo(match.group(1) or match.group(2)) |
| 839 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) | 839 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) |
| 840 if not type_name in _idl_type_registry: | 840 if not type_name in _idl_type_registry: |
| 841 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 841 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) |
| 842 type_data = _idl_type_registry.get(type_name) | 842 type_data = _idl_type_registry.get(type_name) |
| 843 class_name = '%sIDLTypeInfo' % type_data.clazz | 843 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 844 return globals()[class_name](type_name, type_data) | 844 return globals()[class_name](type_name, type_data) |
| OLD | NEW |