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

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

Issue 10800104: Convert DOM and HTML frog to dart2js. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « lib/dom/scripts/systemfrog.py ('k') | lib/dom/src/dart2js_DOMImplementation.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 import emitter 9 import emitter
10 10
11 from systemfrog import * 11 from systemdart2js import *
12 from systeminterface import * 12 from systeminterface import *
13 13
14 _js_custom_members = set([ 14 _js_custom_members = set([
15 'IDBDatabase.transaction', 15 'IDBDatabase.transaction',
16 'IFrameElement.contentWindow', 16 'IFrameElement.contentWindow',
17 'Window.document', 17 'Window.document',
18 'Window.top', 18 'Window.top',
19 'Window.location', 19 'Window.location',
20 'Window.open', 20 'Window.open',
21 ]) 21 ])
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 pass 733 pass
734 734
735 def AddOperation(self, info, html_name): 735 def AddOperation(self, info, html_name):
736 pass 736 pass
737 737
738 738
739 # ------------------------------------------------------------------------------ 739 # ------------------------------------------------------------------------------
740 740
741 # TODO(jmesserly): inheritance is probably not the right way to factor this long 741 # TODO(jmesserly): inheritance is probably not the right way to factor this long
742 # term, but it makes merging better for now. 742 # term, but it makes merging better for now.
743 class HtmlFrogClassGenerator(FrogInterfaceGenerator): 743 class HtmlDart2JSClassGenerator(Dart2JSInterfaceGenerator):
744 """Generates a Frog class for the dart:html library from a DOM IDL 744 """Generates a dart2js class for the dart:html library from a DOM IDL
745 interface. 745 interface.
746 """ 746 """
747 747
748 def __init__(self, system, interface): 748 def __init__(self, system, interface):
749 super(HtmlFrogClassGenerator, self).__init__( 749 super(HtmlDart2JSClassGenerator, self).__init__(
750 system, interface, None, None) 750 system, interface, None, None)
751 self._html_interface_name = system._renamer.RenameInterface(self._interface) 751 self._html_interface_name = system._renamer.RenameInterface(self._interface)
752 752
753 def HasImplementation(self): 753 def HasImplementation(self):
754 return not (IsPureInterface(self._interface.id) or 754 return not (IsPureInterface(self._interface.id) or
755 self._interface.id in _merged_html_interfaces) 755 self._interface.id in _merged_html_interfaces)
756 756
757 def ImplementationClassName(self): 757 def ImplementationClassName(self):
758 return self._ImplClassName(self._html_interface_name) 758 return self._ImplClassName(self._html_interface_name)
759 759
760 def FilePathForDartImplementation(self): 760 def FilePathForDartImplementation(self):
761 return os.path.join(self._system._output_dir, 'html', 'frog', 761 return os.path.join(self._system._output_dir, 'html', 'dart2js',
762 '%s.dart' % self._html_interface_name) 762 '%s.dart' % self._html_interface_name)
763 763
764 def FilePathForDartFactoryProviderImplementation(self): 764 def FilePathForDartFactoryProviderImplementation(self):
765 return os.path.join(self._system._output_dir, 'html', 'frog', 765 return os.path.join(self._system._output_dir, 'html', 'dart2js',
766 '_%sFactoryProvider.dart' % self._html_interface_name) 766 '_%sFactoryProvider.dart' % self._html_interface_name)
767 767
768 def FilePathForDartElementsFactoryProviderImplementation(self): 768 def FilePathForDartElementsFactoryProviderImplementation(self):
769 return os.path.join(self._system._output_dir, 'html', 'frog', 769 return os.path.join(self._system._output_dir, 'html', 'dart2js',
770 '_Elements.dart') 770 '_Elements.dart')
771 771
772 def SetImplementationEmitter(self, implementation_emitter): 772 def SetImplementationEmitter(self, implementation_emitter):
773 self._dart_code = implementation_emitter 773 self._dart_code = implementation_emitter
774 774
775 def ImplementsMergedMembers(self): 775 def ImplementsMergedMembers(self):
776 return True 776 return True
777 777
778 def _ImplClassName(self, type_name): 778 def _ImplClassName(self, type_name):
779 return '_%sImpl' % type_name 779 return '_%sImpl' % type_name
(...skipping 21 matching lines...) Expand all
801 801
802 # TODO: Include all implemented interfaces, including other Lists. 802 # TODO: Include all implemented interfaces, including other Lists.
803 implements = [self._html_interface_name] 803 implements = [self._html_interface_name]
804 element_type = MaybeTypedArrayElementType(self._interface) 804 element_type = MaybeTypedArrayElementType(self._interface)
805 if element_type: 805 if element_type:
806 implements.append('List<%s>' % self._DartType(element_type)) 806 implements.append('List<%s>' % self._DartType(element_type))
807 implements.append('JavaScriptIndexingBehavior') 807 implements.append('JavaScriptIndexingBehavior')
808 808
809 template_file = 'impl_%s.darttemplate' % self._html_interface_name 809 template_file = 'impl_%s.darttemplate' % self._html_interface_name
810 template = (self._system._templates.TryLoad(template_file) or 810 template = (self._system._templates.TryLoad(template_file) or
811 self._system._templates.Load('frog_impl.darttemplate')) 811 self._system._templates.Load('dart2js_impl.darttemplate'))
812 self._members_emitter = self._dart_code.Emit( 812 self._members_emitter = self._dart_code.Emit(
813 template, 813 template,
814 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 814 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
815 #$!MEMBERS 815 #$!MEMBERS
816 #} 816 #}
817 CLASSNAME=self._class_name, 817 CLASSNAME=self._class_name,
818 EXTENDS=extends, 818 EXTENDS=extends,
819 IMPLEMENTS=' implements ' + ', '.join(implements), 819 IMPLEMENTS=' implements ' + ', '.join(implements),
820 NATIVESPEC=' native "' + native_spec + '"') 820 NATIVESPEC=' native "' + native_spec + '"')
821 if self._members_emitter == None: 821 if self._members_emitter == None:
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 NAME=info.name, 992 NAME=info.name,
993 PARAMS=info.ParametersImplementationDeclaration( 993 PARAMS=info.ParametersImplementationDeclaration(
994 lambda type_name: self._NarrowInputType(type_name))) 994 lambda type_name: self._NarrowInputType(type_name)))
995 995
996 def _HasCustomImplementation(self, member_name): 996 def _HasCustomImplementation(self, member_name):
997 member_name = '%s.%s' % (self._html_interface_name, member_name) 997 member_name = '%s.%s' % (self._html_interface_name, member_name)
998 return member_name in _js_custom_members 998 return member_name in _js_custom_members
999 999
1000 # ------------------------------------------------------------------------------ 1000 # ------------------------------------------------------------------------------
1001 1001
1002 class HtmlFrogSystem(System): 1002 class HtmlDart2JSSystem(System):
1003 1003
1004 def __init__(self, options): 1004 def __init__(self, options):
1005 super(HtmlFrogSystem, self).__init__(options) 1005 super(HtmlDart2JSSystem, self).__init__(options)
1006 1006
1007 def ImplementationGenerator(self, interface): 1007 def ImplementationGenerator(self, interface):
1008 return HtmlFrogClassGenerator(self, interface) 1008 return HtmlDart2JSClassGenerator(self, interface)
1009 1009
1010 def GenerateLibraries(self, dart_files): 1010 def GenerateLibraries(self, dart_files):
1011 self._GenerateLibFile( 1011 self._GenerateLibFile(
1012 'html_frog.darttemplate', 1012 'html_dart2js.darttemplate',
1013 os.path.join(self._output_dir, 'html_frog.dart'), 1013 os.path.join(self._output_dir, 'html_dart2js.dart'),
1014 dart_files) 1014 dart_files)
1015 1015
1016 def Finish(self): 1016 def Finish(self):
1017 pass 1017 pass
OLDNEW
« no previous file with comments | « lib/dom/scripts/systemfrog.py ('k') | lib/dom/src/dart2js_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698