| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 # | 60 # |
| 61 _dart2js_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 # | |
| 71 # Custom native bodies for dart2js implementations of dom operations that | |
| 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 - | |
| 74 # the correct name is available on the DartName extended | |
| 75 # attribute. See Issue 1814 | |
| 76 # | |
| 77 dom_dart2js_native_bodies = { | |
| 78 # Some JavaScript processors, especially tools like yuicompress and | |
| 79 # JSCompiler, choke on 'this.continue' | |
| 80 'IDBCursor.continueFunction': | |
| 81 """ | |
| 82 if (key == null) return this['continue'](); | |
| 83 return this['continue'](key); | |
| 84 """, | |
| 85 } | |
| 86 | |
| 87 def IsRegisteredType(type_name): | 70 def IsRegisteredType(type_name): |
| 88 return type_name in _idl_type_registry | 71 return type_name in _idl_type_registry |
| 89 | 72 |
| 90 def ListImplementationInfo(interface, database): | 73 def ListImplementationInfo(interface, database): |
| 91 """Returns a tuple (elment_type, requires_indexer). | 74 """Returns a tuple (elment_type, requires_indexer). |
| 92 If interface do not have to implement List, element_type is None. | 75 If interface do not have to implement List, element_type is None. |
| 93 Otherwise element_type is list element type and requires_indexer | 76 Otherwise element_type is list element type and requires_indexer |
| 94 is true iff this interface implementation must have indexer and | 77 is true iff this interface implementation must have indexer and |
| 95 false otherwise. False means that interface implementation | 78 false otherwise. False means that interface implementation |
| 96 inherits indexer and may just reuse it.""" | 79 inherits indexer and may just reuse it.""" |
| (...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 if match: | 817 if match: |
| 835 if type_name == 'DOMString[]': | 818 if type_name == 'DOMString[]': |
| 836 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) | 819 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) |
| 837 item_info = self.TypeInfo(match.group(1) or match.group(2)) | 820 item_info = self.TypeInfo(match.group(1) or match.group(2)) |
| 838 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) | 821 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) |
| 839 if not type_name in _idl_type_registry: | 822 if not type_name in _idl_type_registry: |
| 840 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) | 823 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) |
| 841 type_data = _idl_type_registry.get(type_name) | 824 type_data = _idl_type_registry.get(type_name) |
| 842 class_name = '%sIDLTypeInfo' % type_data.clazz | 825 class_name = '%sIDLTypeInfo' % type_data.clazz |
| 843 return globals()[class_name](type_name, type_data) | 826 return globals()[class_name](type_name, type_data) |
| OLD | NEW |