| 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 the system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
| 8 from htmleventgenerator import use_idl_event_style |
| 8 | 9 |
| 9 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| 10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ | 11 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ |
| 11 IsPureInterface | 12 IsPureInterface |
| 12 | 13 |
| 13 # Types that are accessible cross-frame in a limited fashion. | 14 # Types that are accessible cross-frame in a limited fashion. |
| 14 # In these cases, the base type (e.g., Window) provides restricted access | 15 # In these cases, the base type (e.g., Window) provides restricted access |
| 15 # while the subtype (e.g., LocalWindow) provides full access to the | 16 # while the subtype (e.g., LocalWindow) provides full access to the |
| 16 # corresponding objects if there are from the same frame. | 17 # corresponding objects if there are from the same frame. |
| 17 _secure_base_types = { | 18 _secure_base_types = { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' | 52 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' |
| 52 ' @docsEditable true' | 53 ' @docsEditable true' |
| 53 '\n $TYPE get on =>\n new $TYPE(this);\n', | 54 '\n $TYPE get on =>\n new $TYPE(this);\n', |
| 54 TYPE=events_class_name) | 55 TYPE=events_class_name) |
| 55 | 56 |
| 56 def AddMembers(self, interface, declare_only=False): | 57 def AddMembers(self, interface, declare_only=False): |
| 57 for const in sorted(interface.constants, ConstantOutputOrder): | 58 for const in sorted(interface.constants, ConstantOutputOrder): |
| 58 self.AddConstant(const) | 59 self.AddConstant(const) |
| 59 | 60 |
| 60 for attr in sorted(interface.attributes, ConstantOutputOrder): | 61 for attr in sorted(interface.attributes, ConstantOutputOrder): |
| 61 if attr.type.id != 'EventListener': | 62 if attr.type.id != 'EventListener' or interface.id in use_idl_event_style: |
| 62 self.AddAttribute(attr, declare_only) | 63 self.AddAttribute(attr, declare_only) |
| 63 | 64 |
| 64 # The implementation should define an indexer if the interface directly | 65 # The implementation should define an indexer if the interface directly |
| 65 # extends List. | 66 # extends List. |
| 66 element_type = None | 67 element_type = None |
| 67 requires_indexer = False | 68 requires_indexer = False |
| 68 if self._interface_type_info.list_item_type(): | 69 if self._interface_type_info.list_item_type(): |
| 69 self.AddIndexer(self._interface_type_info.list_item_type()) | 70 self.AddIndexer(self._interface_type_info.list_item_type()) |
| 70 else: | 71 else: |
| 71 for parent in self._database.Hierarchy(self._interface): | 72 for parent in self._database.Hierarchy(self._interface): |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 walk(interface.parents) | 330 walk(interface.parents) |
| 330 else: | 331 else: |
| 331 walk(interface.parents[1:]) | 332 walk(interface.parents[1:]) |
| 332 return result | 333 return result |
| 333 | 334 |
| 334 def _DartType(self, type_name): | 335 def _DartType(self, type_name): |
| 335 return self._type_registry.DartType(type_name) | 336 return self._type_registry.DartType(type_name) |
| 336 | 337 |
| 337 def _IsPrivate(self, name): | 338 def _IsPrivate(self, name): |
| 338 return name.startswith('_') | 339 return name.startswith('_') |
| OLD | NEW |