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 re | 9 import re |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 _frog_dom_custom_native_specs = { | 60 _frog_dom_custom_native_specs = { |
61 # Decorate the singleton Console object, if present (workers do not have a | 61 # Decorate the singleton Console object, if present (workers do not have a |
62 # console). | 62 # console). |
63 'Console': "=(typeof console == 'undefined' ? {} : console)", | 63 'Console': "=(typeof console == 'undefined' ? {} : console)", |
64 | 64 |
65 # DOMWindow aliased with global scope. | 65 # DOMWindow aliased with global scope. |
66 'DOMWindow': '@*DOMWindow', | 66 'DOMWindow': '@*DOMWindow', |
67 } | 67 } |
68 | 68 |
69 # | 69 # |
70 # Custom native bodies for frog implementations of dom operations that appear in | 70 # Custom native bodies for frog implementations of dom operations that |
71 # dart:dom and dart:html. This is used to work-around the lack of a 'rename' | 71 # appear in dart:dom_deprecated and dart:html. This is used to |
72 # feature in the 'native' string - the correct name is available on the DartName | 72 # work-around the lack of a 'rename' feature in the 'native' string - |
73 # extended attribute. See Issue 1814 | 73 # the correct name is available on the DartName extended |
| 74 # attribute. See Issue 1814 |
74 # | 75 # |
75 dom_frog_native_bodies = { | 76 dom_frog_native_bodies = { |
76 # Some JavaScript processors, especially tools like yuicompress and | 77 # Some JavaScript processors, especially tools like yuicompress and |
77 # JSCompiler, choke on 'this.continue' | 78 # JSCompiler, choke on 'this.continue' |
78 'IDBCursor.continueFunction': | 79 'IDBCursor.continueFunction': |
79 """ | 80 """ |
80 if (key == null) return this['continue'](); | 81 if (key == null) return this['continue'](); |
81 return this['continue'](key); | 82 return this['continue'](key); |
82 """, | 83 """, |
83 } | 84 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return element_type | 149 return element_type |
149 | 150 |
150 return None | 151 return None |
151 | 152 |
152 def MakeNativeSpec(javascript_binding_name): | 153 def MakeNativeSpec(javascript_binding_name): |
153 if javascript_binding_name in _frog_dom_custom_native_specs: | 154 if javascript_binding_name in _frog_dom_custom_native_specs: |
154 return _frog_dom_custom_native_specs[javascript_binding_name] | 155 return _frog_dom_custom_native_specs[javascript_binding_name] |
155 else: | 156 else: |
156 # Make the class 'hidden' so it is dynamically patched at runtime. This | 157 # Make the class 'hidden' so it is dynamically patched at runtime. This |
157 # is useful not only for browser compat, but to allow code that links | 158 # is useful not only for browser compat, but to allow code that links |
158 # against dart:dom to load in a worker isolate. | 159 # against dart:dom_deprecated to load in a worker isolate. |
159 return '*' + javascript_binding_name | 160 return '*' + javascript_binding_name |
160 | 161 |
161 | 162 |
162 def MatchSourceFilter(filter, thing): | 163 def MatchSourceFilter(filter, thing): |
163 if not filter: | 164 if not filter: |
164 return True | 165 return True |
165 else: | 166 else: |
166 return any(token in thing.annotations for token in filter) | 167 return any(token in thing.annotations for token in filter) |
167 | 168 |
168 | 169 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 '"SVGAnimatedListPropertyTearOff.h"', | 757 '"SVGAnimatedListPropertyTearOff.h"', |
757 '"SVGTransformListPropertyTearOff.h"', | 758 '"SVGTransformListPropertyTearOff.h"', |
758 '"SVGPathSegListPropertyTearOff.h"', | 759 '"SVGPathSegListPropertyTearOff.h"', |
759 ] | 760 ] |
760 | 761 |
761 def GetIDLTypeInfo(idl_type_name): | 762 def GetIDLTypeInfo(idl_type_name): |
762 match = re.match(r'sequence<(\w+)>$', idl_type_name) | 763 match = re.match(r'sequence<(\w+)>$', idl_type_name) |
763 if match: | 764 if match: |
764 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) | 765 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) |
765 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) | 766 return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name)) |
OLD | NEW |