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

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

Issue 23499007: HTML types that don't have [] do not implement JavaScriptIndexingBehavior, that is, the items canno… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 import emitter 9 import emitter
10 import logging 10 import logging
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 return True 644 return True
645 645
646 def GenerateCallback(self, info): 646 def GenerateCallback(self, info):
647 pass 647 pass
648 648
649 def RootClassName(self): 649 def RootClassName(self):
650 return None 650 return None
651 651
652 def AdditionalImplementedInterfaces(self): 652 def AdditionalImplementedInterfaces(self):
653 implements = super(Dart2JSBackend, self).AdditionalImplementedInterfaces() 653 implements = super(Dart2JSBackend, self).AdditionalImplementedInterfaces()
654 if self._interface_type_info.list_item_type(): 654 if self._interface_type_info.list_item_type() and self.HasIndexedGetter():
655 implements.append('JavaScriptIndexingBehavior') 655 implements.append('JavaScriptIndexingBehavior')
656 return implements 656 return implements
657 657
658 def NativeSpec(self): 658 def NativeSpec(self):
659 native_spec = MakeNativeSpec(self._interface.javascript_binding_name) 659 native_spec = MakeNativeSpec(self._interface.javascript_binding_name)
660 return ' native "%s"' % native_spec 660 return ' native "%s"' % native_spec
661 661
662 def ImplementationTemplate(self): 662 def ImplementationTemplate(self):
663 template_file = ('impl_%s.darttemplate' % 663 template_file = ('impl_%s.darttemplate' %
664 self._interface.doc_js_name) 664 self._interface.doc_js_name)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 PARAMETERS=constructor_info.ParametersAsArgumentList(index), 711 PARAMETERS=constructor_info.ParametersAsArgumentList(index),
712 CTOR_NAME=constructor_info.name or self._interface.doc_js_name, 712 CTOR_NAME=constructor_info.name or self._interface.doc_js_name,
713 PLACEHOLDERS=','.join(['#'] * index), 713 PLACEHOLDERS=','.join(['#'] * index),
714 ARGUMENTS=arguments) 714 ARGUMENTS=arguments)
715 715
716 def SecondaryContext(self, interface): 716 def SecondaryContext(self, interface):
717 if interface is not self._current_secondary_parent: 717 if interface is not self._current_secondary_parent:
718 self._current_secondary_parent = interface 718 self._current_secondary_parent = interface
719 self._members_emitter.Emit('\n // From $WHERE\n', WHERE=interface.id) 719 self._members_emitter.Emit('\n // From $WHERE\n', WHERE=interface.id)
720 720
721 def HasIndexedGetter(self):
722 ext_attrs = self._interface.ext_attrs
723 has_indexed_getter = 'CustomIndexedGetter' in ext_attrs
724 for operation in self._interface.operations:
725 if operation.id == 'item' and 'getter' in operation.specials:
726 has_indexed_getter = True
727 break
728 return has_indexed_getter
729
721 def AddIndexer(self, element_type): 730 def AddIndexer(self, element_type):
722 """Adds all the methods required to complete implementation of List.""" 731 """Adds all the methods required to complete implementation of List."""
723 # We would like to simply inherit the implementation of everything except 732 # We would like to simply inherit the implementation of everything except
724 # length, [], and maybe []=. It is possible to extend from a base 733 # length, [], and maybe []=. It is possible to extend from a base
725 # array implementation class only when there is no other implementation 734 # array implementation class only when there is no other implementation
726 # inheritance. There might be no implementation inheritance other than 735 # inheritance. There might be no implementation inheritance other than
727 # DOMBaseWrapper for many classes, but there might be some where the 736 # DOMBaseWrapper for many classes, but there might be some where the
728 # array-ness is introduced by a non-root interface: 737 # array-ness is introduced by a non-root interface:
729 # 738 #
730 # interface Y extends X, List<T> ... 739 # interface Y extends X, List<T> ...
731 # 740 #
732 # In the non-root case we have to choose between: 741 # In the non-root case we have to choose between:
733 # 742 #
734 # class YImpl extends XImpl { add List<T> methods; } 743 # class YImpl extends XImpl { add List<T> methods; }
735 # 744 #
736 # and 745 # and
737 # 746 #
738 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 747 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
739 # 748 #
740 749
741 ext_attrs = self._interface.ext_attrs 750 has_indexed_getter = self.HasIndexedGetter()
742 has_indexed_getter = 'CustomIndexedGetter' in ext_attrs
743 for operation in self._interface.operations:
744 if operation.id == 'item' and 'getter' in operation.specials:
745 has_indexed_getter = True
746 break
747 751
748 if has_indexed_getter: 752 if has_indexed_getter:
749 indexed_getter = ('JS("%s", "#[#]", this, index)' % 753 indexed_getter = ('JS("%s", "#[#]", this, index)' %
750 self.SecureOutputType(element_type)); 754 self.SecureOutputType(element_type));
751 elif any(op.id == 'getItem' for op in self._interface.operations): 755 elif any(op.id == 'getItem' for op in self._interface.operations):
752 indexed_getter = 'this.getItem(index)' 756 indexed_getter = 'this.getItem(index)'
753 elif any(op.id == 'item' for op in self._interface.operations): 757 elif any(op.id == 'item' for op in self._interface.operations):
754 indexed_getter = 'this.item(index)' 758 indexed_getter = 'this.item(index)'
755 759
756 if indexed_getter: 760 if indexed_getter:
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 for library_name in libraries: 1221 for library_name in libraries:
1218 self._libraries[library_name] = DartLibrary( 1222 self._libraries[library_name] = DartLibrary(
1219 library_name, template_loader, library_type, output_dir) 1223 library_name, template_loader, library_type, output_dir)
1220 1224
1221 def AddFile(self, basename, library_name, path): 1225 def AddFile(self, basename, library_name, path):
1222 self._libraries[library_name].AddFile(path) 1226 self._libraries[library_name].AddFile(path)
1223 1227
1224 def Emit(self, emitter, auxiliary_dir): 1228 def Emit(self, emitter, auxiliary_dir):
1225 for lib in self._libraries.values(): 1229 for lib in self._libraries.values():
1226 lib.Emit(emitter, auxiliary_dir) 1230 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/templates/html/dart2js/svg_dart2js.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698