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

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

Issue 9653009: Fix build breakage caused by commit 5196. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | client/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 PARENTS=', '.join( 721 PARENTS=', '.join(
722 self._shared.GetParentsEventsClasses(self._interface))) 722 self._shared.GetParentsEventsClasses(self._interface)))
723 723
724 for event_name in event_attrs: 724 for event_name in event_attrs:
725 if event_name in _html_event_names: 725 if event_name in _html_event_names:
726 events_members.Emit('\n EventListenerList get $NAME();\n', 726 events_members.Emit('\n EventListenerList get $NAME();\n',
727 NAME=_html_event_names[event_name]) 727 NAME=_html_event_names[event_name])
728 else: 728 else:
729 raise Exception('No known html even name for event: ' + event_name) 729 raise Exception('No known html even name for event: ' + event_name)
730 730
731 def _EmitEventGetter(self, interface): 731 def _EmitEventGetter(self, events_interface):
732 self._members_emitter.Emit('\n $TYPE get on();\n', 732 self._members_emitter.Emit('\n $TYPE get on();\n',
733 TYPE=interface) 733 TYPE=events_interface)
734 734
735 # ------------------------------------------------------------------------------ 735 # ------------------------------------------------------------------------------
736 736
737 # TODO(jmesserly): inheritance is probably not the right way to factor this long 737 # TODO(jmesserly): inheritance is probably not the right way to factor this long
738 # term, but it makes merging better for now. 738 # term, but it makes merging better for now.
739 class HtmlFrogClassGenerator(FrogInterfaceGenerator): 739 class HtmlFrogClassGenerator(FrogInterfaceGenerator):
740 """Generates a Frog class for the dart:html library from a DOM IDL 740 """Generates a Frog class for the dart:html library from a DOM IDL
741 interface. 741 interface.
742 """ 742 """
743 743
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 constructor_info = AnalyzeConstructor(interface) 792 constructor_info = AnalyzeConstructor(interface)
793 if constructor_info: 793 if constructor_info:
794 self._EmitFactoryProvider(interface_name, constructor_info) 794 self._EmitFactoryProvider(interface_name, constructor_info)
795 795
796 emit_events, events = self._shared.GetEventAttributes(self._interface) 796 emit_events, events = self._shared.GetEventAttributes(self._interface)
797 if not emit_events: 797 if not emit_events:
798 return 798 return
799 elif events: 799 elif events:
800 self.AddEventAttributes(events) 800 self.AddEventAttributes(events)
801 else: 801 else:
802 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface)) 802 parent_events_class = self._shared.GetParentEventsClass(self._interface)
803 self._EmitEventGetter('_' + parent_events_class + 'Impl')
803 804
804 def _EmitFactoryProvider(self, interface_name, constructor_info): 805 def _EmitFactoryProvider(self, interface_name, constructor_info):
805 template_file = 'factoryprovider_%s.darttemplate' % interface_name 806 template_file = 'factoryprovider_%s.darttemplate' % interface_name
806 template = self._system._templates.TryLoad(template_file) 807 template = self._system._templates.TryLoad(template_file)
807 if not template: 808 if not template:
808 template = self._system._templates.Load('factoryprovider.darttemplate') 809 template = self._system._templates.Load('factoryprovider.darttemplate')
809 810
810 factory_provider = '_' + interface_name + 'FactoryProvider' 811 factory_provider = '_' + interface_name + 'FactoryProvider'
811 emitter = self._system._ImplFileEmitter(factory_provider) 812 emitter = self._system._ImplFileEmitter(factory_provider)
812 emitter.Emit( 813 emitter.Emit(
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 for event_name in event_attrs: 1049 for event_name in event_attrs:
1049 if event_name in _html_event_names: 1050 if event_name in _html_event_names:
1050 events_members.Emit( 1051 events_members.Emit(
1051 "\n" 1052 "\n"
1052 " EventListenerList get $NAME() => _get('$RAWNAME');\n", 1053 " EventListenerList get $NAME() => _get('$RAWNAME');\n",
1053 RAWNAME=event_name, 1054 RAWNAME=event_name,
1054 NAME=_html_event_names[event_name]) 1055 NAME=_html_event_names[event_name])
1055 else: 1056 else:
1056 raise Exception('No known html even name for event: ' + event_name) 1057 raise Exception('No known html even name for event: ' + event_name)
1057 1058
1058 def _EmitEventGetter(self, interface): 1059 def _EmitEventGetter(self, events_class):
1059 self._members_emitter.Emit( 1060 self._members_emitter.Emit(
1060 '\n $TYPE get on() =>\n new $TYPE($EVENTTARGET);\n', 1061 '\n $TYPE get on() =>\n new $TYPE($EVENTTARGET);\n',
1061 TYPE=interface, 1062 TYPE=events_class,
1062 EVENTTARGET='_jsDocument' if self._interface.id == 'Document' 1063 EVENTTARGET='_jsDocument' if self._interface.id == 'Document'
1063 else 'this') 1064 else 'this')
1064 1065
1065 # ------------------------------------------------------------------------------ 1066 # ------------------------------------------------------------------------------
1066 1067
1067 class HtmlFrogSystem(HtmlSystem): 1068 class HtmlFrogSystem(HtmlSystem):
1068 1069
1069 def __init__(self, templates, database, emitters, output_dir, generator): 1070 def __init__(self, templates, database, emitters, output_dir, generator):
1070 super(HtmlFrogSystem, self).__init__( 1071 super(HtmlFrogSystem, self).__init__(
1071 templates, database, emitters, output_dir, generator) 1072 templates, database, emitters, output_dir, generator)
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 constructor_info = AnalyzeConstructor(interface) 1279 constructor_info = AnalyzeConstructor(interface)
1279 if constructor_info: 1280 if constructor_info:
1280 self._EmitFactoryProvider(interface_name, constructor_info) 1281 self._EmitFactoryProvider(interface_name, constructor_info)
1281 1282
1282 emit_events, events = self._shared.GetEventAttributes(self._interface) 1283 emit_events, events = self._shared.GetEventAttributes(self._interface)
1283 if not emit_events: 1284 if not emit_events:
1284 return 1285 return
1285 elif events: 1286 elif events:
1286 self.AddEventAttributes(events) 1287 self.AddEventAttributes(events)
1287 else: 1288 else:
1288 self._EmitEventGetter(self._shared.GetParentEventsClass(self._interface)) 1289 parent_events_class = self._shared.GetParentEventsClass(self._interface)
1290 self._EmitEventGetter('_' + parent_events_class + 'Impl')
1289 1291
1290 def _EmitFactoryProvider(self, interface_name, constructor_info): 1292 def _EmitFactoryProvider(self, interface_name, constructor_info):
1291 template_file = 'factoryprovider_%s.darttemplate' % interface_name 1293 template_file = 'factoryprovider_%s.darttemplate' % interface_name
1292 template = self._system._templates.TryLoad(template_file) 1294 template = self._system._templates.TryLoad(template_file)
1293 if not template: 1295 if not template:
1294 template = self._system._templates.Load('factoryprovider.darttemplate') 1296 template = self._system._templates.Load('factoryprovider.darttemplate')
1295 1297
1296 factory_provider = '_' + interface_name + 'FactoryProvider' 1298 factory_provider = '_' + interface_name + 'FactoryProvider'
1297 emitter = self._system._ImplFileEmitter(factory_provider) 1299 emitter = self._system._ImplFileEmitter(factory_provider)
1298 emitter.Emit( 1300 emitter.Emit(
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee 1766 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee
1765 # that Y = Z-X, so we need to check for Y. 1767 # that Y = Z-X, so we need to check for Y.
1766 true_code = emitter.Emit( 1768 true_code = emitter.Emit(
1767 '$(INDENT)if ($COND) {\n' 1769 '$(INDENT)if ($COND) {\n'
1768 '$!TRUE' 1770 '$!TRUE'
1769 '$(INDENT)}\n', 1771 '$(INDENT)}\n',
1770 COND=test, INDENT=indent) 1772 COND=test, INDENT=indent)
1771 self.GenerateDispatch( 1773 self.GenerateDispatch(
1772 true_code, info, indent + ' ', position + 1, positive) 1774 true_code, info, indent + ' ', position + 1, positive)
1773 return True 1775 return True
OLDNEW
« no previous file with comments | « no previous file | client/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698