Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Side by Side Diff: lib/dom/scripts/systemhtml.py

Issue 10541029: Do not merge IDL interfaces in dartdomgenerator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed shadowing. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 from systemfrog import * 9 from systemfrog import *
10 from systeminterface import * 10 from systeminterface import *
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 "IFrameElement.get:contentDocument", 254 "IFrameElement.get:contentDocument",
255 "Window.get:frameElement", 255 "Window.get:frameElement",
256 ]) 256 ])
257 257
258 _html_library_custom = set([ 258 _html_library_custom = set([
259 'IFrameElement.get:contentWindow', 259 'IFrameElement.get:contentWindow',
260 'Window.get:document', 260 'Window.get:document',
261 'Window.get:top', 261 'Window.get:top',
262 ]) 262 ])
263 263
264 _merged_html_interfaces = {
sra1 2012/06/07 19:31:07 This needs an essay. Add comment what this means
podivilov 2012/06/08 17:02:21 Done.
265 'Document': 'HTMLDocument',
266 'Element': 'HTMLElement'
267 }
268
264 # Events without onEventName attributes in the IDL we want to support. 269 # Events without onEventName attributes in the IDL we want to support.
265 # We can automatically extract most event event names by checking for 270 # We can automatically extract most event event names by checking for
266 # onEventName methods in the IDL but some events aren't listed so we need 271 # onEventName methods in the IDL but some events aren't listed so we need
267 # to manually add them here so that they are easy for users to find. 272 # to manually add them here so that they are easy for users to find.
268 _html_manual_events = { 273 _html_manual_events = {
269 'Element': ['touchleave', 'touchenter', 'webkitTransitionEnd'], 274 'Element': ['touchleave', 'touchenter', 'webkitTransitionEnd'],
270 'Window': ['DOMContentLoaded'] 275 'Window': ['DOMContentLoaded']
271 } 276 }
272 277
273 # These event names must be camel case when attaching event listeners 278 # These event names must be camel case when attaching event listeners
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 templates, database, emitters, output_dir) 700 templates, database, emitters, output_dir)
696 self._dart_interface_file_paths = [] 701 self._dart_interface_file_paths = []
697 self._factory_provider_emitters = {} 702 self._factory_provider_emitters = {}
698 703
699 def InterfaceGenerator(self, 704 def InterfaceGenerator(self,
700 interface, 705 interface,
701 common_prefix, 706 common_prefix,
702 super_interface_name, 707 super_interface_name,
703 source_filter): 708 source_filter):
704 """.""" 709 """."""
710 if interface.id in _merged_html_interfaces.values():
711 return None
712
705 interface_name = interface.id 713 interface_name = interface.id
706 dart_interface_file_path = self._FilePathForDartInterface(interface_name) 714 dart_interface_file_path = self._FilePathForDartInterface(interface_name)
707 715
708 self._dart_interface_file_paths.append(dart_interface_file_path) 716 self._dart_interface_file_paths.append(dart_interface_file_path)
709 717
710 dart_interface_code = self._emitters.FileEmitter(dart_interface_file_path) 718 dart_interface_code = self._emitters.FileEmitter(dart_interface_file_path)
711 719
712 template_file = 'interface_%s.darttemplate' % interface_name 720 template_file = 'interface_%s.darttemplate' % interface_name
713 template = self._templates.TryLoad(template_file) 721 template = self._templates.TryLoad(template_file)
714 if not template: 722 if not template:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 TYPE=DartType(element_type)) 838 TYPE=DartType(element_type))
831 839
832 emit_events, events = self._shared.GetEventAttributes(self._interface) 840 emit_events, events = self._shared.GetEventAttributes(self._interface)
833 if not emit_events: 841 if not emit_events:
834 return 842 return
835 elif events: 843 elif events:
836 self.AddEventAttributes(events) 844 self.AddEventAttributes(events)
837 else: 845 else:
838 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface)) 846 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface))
839 847
848 if self._interface.id in _merged_html_interfaces:
849 merged_interface = _merged_html_interfaces[self._interface.id]
850 self.AddMembers(self._database.GetInterface(merged_interface))
840 851
841 def AddAttribute(self, getter, setter): 852 def AddAttribute(self, getter, setter):
842 dom_name = DartDomNameOfAttribute(getter) 853 dom_name = DartDomNameOfAttribute(getter)
843 html_getter_name = self._shared.RenameInHtmlLibrary( 854 html_getter_name = self._shared.RenameInHtmlLibrary(
844 self._interface.id, dom_name, 'get:') 855 self._interface.id, dom_name, 'get:')
845 html_setter_name = self._shared.RenameInHtmlLibrary( 856 html_setter_name = self._shared.RenameInHtmlLibrary(
846 self._interface.id, dom_name, 'set:') 857 self._interface.id, dom_name, 'set:')
847 858
848 if not html_getter_name or self._shared.IsPrivate(html_getter_name): 859 if not html_getter_name or self._shared.IsPrivate(html_getter_name):
849 getter = None 860 getter = None
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 1006
996 emit_events, events = self._shared.GetEventAttributes(self._interface) 1007 emit_events, events = self._shared.GetEventAttributes(self._interface)
997 if not emit_events: 1008 if not emit_events:
998 return 1009 return
999 elif events: 1010 elif events:
1000 self.AddEventAttributes(events) 1011 self.AddEventAttributes(events)
1001 else: 1012 else:
1002 parent_events_class = self._shared.GetParentEventsClass(self._interface) 1013 parent_events_class = self._shared.GetParentEventsClass(self._interface)
1003 self._EmitEventGetter('_' + parent_events_class + 'Impl') 1014 self._EmitEventGetter('_' + parent_events_class + 'Impl')
1004 1015
1016 if self._interface.id in _merged_html_interfaces:
1017 merged_interface = _merged_html_interfaces[self._interface.id]
1018 self.AddMembers(self._database.GetInterface(merged_interface))
1019
1005 def _EmitFactoryProvider(self, interface_name, constructor_info): 1020 def _EmitFactoryProvider(self, interface_name, constructor_info):
1006 template_file = 'factoryprovider_%s.darttemplate' % interface_name 1021 template_file = 'factoryprovider_%s.darttemplate' % interface_name
1007 template = self._system._templates.TryLoad(template_file) 1022 template = self._system._templates.TryLoad(template_file)
1008 if not template: 1023 if not template:
1009 template = self._system._templates.Load('factoryprovider.darttemplate') 1024 template = self._system._templates.Load('factoryprovider.darttemplate')
1010 1025
1011 factory_provider = '_' + interface_name + 'FactoryProvider' 1026 factory_provider = '_' + interface_name + 'FactoryProvider'
1012 emitter = self._system._ImplFileEmitter(factory_provider) 1027 emitter = self._system._ImplFileEmitter(factory_provider)
1013 emitter.Emit( 1028 emitter.Emit(
1014 template, 1029 template,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 if ((getter and html_getter_name != getter.id) or 1114 if ((getter and html_getter_name != getter.id) or
1100 (setter and html_setter_name != setter.id)): 1115 (setter and html_setter_name != setter.id)):
1101 if getter: 1116 if getter:
1102 self._AddRenamingGetter(getter, html_getter_name) 1117 self._AddRenamingGetter(getter, html_getter_name)
1103 if setter: 1118 if setter:
1104 self._AddRenamingSetter(setter, html_setter_name) 1119 self._AddRenamingSetter(setter, html_setter_name)
1105 return 1120 return
1106 1121
1107 # If the (getter, setter) pair is shadowing, we can't generate a shadowing 1122 # If the (getter, setter) pair is shadowing, we can't generate a shadowing
1108 # field (Issue 1633). 1123 # field (Issue 1633).
1109 (super_getter, super_getter_interface) = self._FindShadowedAttribute(getter) 1124 (super_getter, super_getter_interface) = self._FindShadowedAttribute(getter, _merged_html_interfaces)
1110 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter) 1125 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter, _merged_html_interfaces)
1111 if super_getter or super_setter: 1126 if super_getter or super_setter:
1112 if getter and not setter and super_getter and not super_setter: 1127 if getter and not setter and super_getter and not super_setter:
1113 if DartType(getter.type.id) == DartType(super_getter.type.id): 1128 if DartType(getter.type.id) == DartType(super_getter.type.id):
1114 # Compatible getter, use the superclass property. This works because 1129 # Compatible getter, use the superclass property. This works because
1115 # JavaScript will do its own dynamic dispatch. 1130 # JavaScript will do its own dynamic dispatch.
1116 output_type = getter and self._NarrowOutputType(getter.type.id) 1131 output_type = getter and self._NarrowOutputType(getter.type.id)
1117 self._members_emitter.Emit( 1132 self._members_emitter.Emit(
1118 '\n' 1133 '\n'
1119 ' // Use implementation from $SUPER.\n' 1134 ' // Use implementation from $SUPER.\n'
1120 ' // final $TYPE $NAME;\n', 1135 ' // final $TYPE $NAME;\n',
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 templates, database, emitters, output_dir) 1266 templates, database, emitters, output_dir)
1252 self._dart_frog_file_paths = [] 1267 self._dart_frog_file_paths = []
1253 self._factory_provider_emitters = {} 1268 self._factory_provider_emitters = {}
1254 1269
1255 def InterfaceGenerator(self, 1270 def InterfaceGenerator(self,
1256 interface, 1271 interface,
1257 common_prefix, 1272 common_prefix,
1258 super_interface_name, 1273 super_interface_name,
1259 source_filter): 1274 source_filter):
1260 """.""" 1275 """."""
1276 if interface.id in _merged_html_interfaces.values():
1277 return None
1278
1261 if IsPureInterface(interface.id): 1279 if IsPureInterface(interface.id):
1262 return 1280 return
1263 template_file = 'impl_%s.darttemplate' % interface.id 1281 template_file = 'impl_%s.darttemplate' % interface.id
1264 template = self._templates.TryLoad(template_file) 1282 template = self._templates.TryLoad(template_file)
1265 if not template: 1283 if not template:
1266 template = self._templates.Load('frog_impl.darttemplate') 1284 template = self._templates.Load('frog_impl.darttemplate')
1267 1285
1268 dart_code = self._ImplFileEmitter(interface.id) 1286 dart_code = self._ImplFileEmitter(interface.id)
1269 return HtmlFrogClassGenerator(self, interface, template, 1287 return HtmlFrogClassGenerator(self, interface, template,
1270 super_interface_name, dart_code, self._shared) 1288 super_interface_name, dart_code, self._shared)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 Collect(database.GetInterface(parent.type.id), 1370 Collect(database.GetInterface(parent.type.id),
1353 seen, collected) 1371 seen, collected)
1354 1372
1355 inheritance_closure = {} 1373 inheritance_closure = {}
1356 for interface in database.GetInterfaces(): 1374 for interface in database.GetInterfaces():
1357 seen = set() 1375 seen = set()
1358 collected = [] 1376 collected = []
1359 Collect(interface, seen, collected) 1377 Collect(interface, seen, collected)
1360 inheritance_closure[interface.id] = collected 1378 inheritance_closure[interface.id] = collected
1361 return inheritance_closure 1379 return inheritance_closure
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698