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

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

Issue 10823140: Make more native DOM array-like objects known to compiler. (Closed) Base URL: https://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 | « no previous file | lib/html/dart2js/html_dart2js.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
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 799
800 native_spec = MakeNativeSpec(interface.javascript_binding_name) 800 native_spec = MakeNativeSpec(interface.javascript_binding_name)
801 801
802 extends = ' extends ' + base if base else '' 802 extends = ' extends ' + base if base else ''
803 803
804 # TODO: Include all implemented interfaces, including other Lists. 804 # TODO: Include all implemented interfaces, including other Lists.
805 implements = [self._html_interface_name] 805 implements = [self._html_interface_name]
806 element_type = MaybeTypedArrayElementType(self._interface) 806 element_type = MaybeTypedArrayElementType(self._interface)
807 if element_type: 807 if element_type:
808 implements.append('List<%s>' % self._DartType(element_type)) 808 implements.append('List<%s>' % self._DartType(element_type))
809
810 if self._HasJavaScriptIndexingBehaviour():
809 implements.append('JavaScriptIndexingBehavior') 811 implements.append('JavaScriptIndexingBehavior')
810 812
811 template_file = 'impl_%s.darttemplate' % self._html_interface_name 813 template_file = 'impl_%s.darttemplate' % self._html_interface_name
812 template = (self._system._templates.TryLoad(template_file) or 814 template = (self._system._templates.TryLoad(template_file) or
813 self._system._templates.Load('dart2js_impl.darttemplate')) 815 self._system._templates.Load('dart2js_impl.darttemplate'))
814 self._members_emitter = self._dart_code.Emit( 816 self._members_emitter = self._dart_code.Emit(
815 template, 817 template,
816 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 818 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
817 #$!MEMBERS 819 #$!MEMBERS
818 #} 820 #}
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 ' $TYPE $NAME($PARAMS) native;\n', 994 ' $TYPE $NAME($PARAMS) native;\n',
993 TYPE=self._NarrowOutputType(info.type_name), 995 TYPE=self._NarrowOutputType(info.type_name),
994 NAME=info.name, 996 NAME=info.name,
995 PARAMS=info.ParametersImplementationDeclaration( 997 PARAMS=info.ParametersImplementationDeclaration(
996 lambda type_name: self._NarrowInputType(type_name))) 998 lambda type_name: self._NarrowInputType(type_name)))
997 999
998 def _HasCustomImplementation(self, member_name): 1000 def _HasCustomImplementation(self, member_name):
999 member_name = '%s.%s' % (self._html_interface_name, member_name) 1001 member_name = '%s.%s' % (self._html_interface_name, member_name)
1000 return member_name in _js_custom_members 1002 return member_name in _js_custom_members
1001 1003
1004 def _HasJavaScriptIndexingBehaviour(self):
1005 """Returns True if the native object has an indexer and length property."""
1006 (element_type, requires_indexer) = ListImplementationInfo(
1007 self._interface, self._database)
kasperl 2012/08/02 10:03:06 4 space indent here?
sra1 2012/08/02 10:26:51 Done.
1008 if element_type and requires_indexer: return True
1009 return False
1010
1002 # ------------------------------------------------------------------------------ 1011 # ------------------------------------------------------------------------------
1003 1012
1004 class HtmlDart2JSSystem(System): 1013 class HtmlDart2JSSystem(System):
1005 1014
1006 def __init__(self, options): 1015 def __init__(self, options):
1007 super(HtmlDart2JSSystem, self).__init__(options) 1016 super(HtmlDart2JSSystem, self).__init__(options)
1008 1017
1009 def ImplementationGenerator(self, interface): 1018 def ImplementationGenerator(self, interface):
1010 return HtmlDart2JSClassGenerator(self, interface) 1019 return HtmlDart2JSClassGenerator(self, interface)
1011 1020
1012 def GenerateLibraries(self, dart_files): 1021 def GenerateLibraries(self, dart_files):
1013 self._GenerateLibFile( 1022 self._GenerateLibFile(
1014 'html_dart2js.darttemplate', 1023 'html_dart2js.darttemplate',
1015 os.path.join(self._output_dir, 'html_dart2js.dart'), 1024 os.path.join(self._output_dir, 'html_dart2js.dart'),
1016 dart_files) 1025 dart_files)
1017 1026
1018 def Finish(self): 1027 def Finish(self):
1019 pass 1028 pass
OLDNEW
« no previous file with comments | « no previous file | lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698