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

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

Issue 14619013: Explicitly implementing some DOM iterable APIs for performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 monitored 10 import monitored
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 # and 704 # and
705 # 705 #
706 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 706 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
707 # 707 #
708 708
709 ext_attrs = self._interface.ext_attrs 709 ext_attrs = self._interface.ext_attrs
710 has_indexed_getter = ('IndexedGetter' in ext_attrs or 710 has_indexed_getter = ('IndexedGetter' in ext_attrs or
711 'CustomIndexedSetter' in ext_attrs) 711 'CustomIndexedSetter' in ext_attrs)
712 712
713 if has_indexed_getter: 713 if has_indexed_getter:
714 indexed_getter = 'JS("%s", "#[#]", this, index)' % self.SecureOutputType(e lement_type);
sra1 2013/05/09 19:55:50 line length
blois 2013/05/09 22:49:24 Done.
715 elif any(op.id == 'getItem' for op in self._interface.operations):
716 indexed_getter = 'this.getItem(index)'
717 elif any(op.id == 'item' for op in self._interface.operations):
718 indexed_getter = 'this.item(index)'
719
720 if indexed_getter:
714 self._members_emitter.Emit( 721 self._members_emitter.Emit(
715 '\n' 722 '\n'
716 ' $TYPE operator[](int index) => ' 723 ' $TYPE operator[](int index) {\n'
717 'JS("$TYPE", "#[#]", this, index);\n', 724 ' if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, le ngth)) throw new RangeError.range(index, 0, length);\n'
718 TYPE=self.SecureOutputType(element_type)) 725 ' return $INDEXED_GETTER;\n'
719 else: 726 ' }',
720 if any(op.id == 'getItem' for op in self._interface.operations):
721 indexed_getter = 'this.getItem(index)'
722 elif any(op.id == 'item' for op in self._interface.operations):
723 indexed_getter = 'this.item(index)'
724 self._members_emitter.Emit(
725 '\n'
726 ' $TYPE operator[](int index) => $INDEXED_GETTER;\n',
727 INDEXED_GETTER=indexed_getter, 727 INDEXED_GETTER=indexed_getter,
728 TYPE=self.SecureOutputType(element_type)) 728 TYPE=self.SecureOutputType(element_type))
729 729
730 if 'CustomIndexedSetter' in self._interface.ext_attrs: 730 if 'CustomIndexedSetter' in self._interface.ext_attrs:
731 self._members_emitter.Emit( 731 self._members_emitter.Emit(
732 '\n' 732 '\n'
733 ' void operator[]=(int index, $TYPE value) {' 733 ' void operator[]=(int index, $TYPE value) {'
734 ' JS("void", "#[#] = #", this, index, value); }', 734 ' JS("void", "#[#] = #", this, index, value); }',
735 TYPE=self._NarrowInputType(element_type)) 735 TYPE=self._NarrowInputType(element_type))
736 else: 736 else:
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 for library_name in libraries: 1167 for library_name in libraries:
1168 self._libraries[library_name] = DartLibrary( 1168 self._libraries[library_name] = DartLibrary(
1169 library_name, template_loader, library_type, output_dir) 1169 library_name, template_loader, library_type, output_dir)
1170 1170
1171 def AddFile(self, basename, library_name, path): 1171 def AddFile(self, basename, library_name, path):
1172 self._libraries[library_name].AddFile(path) 1172 self._libraries[library_name].AddFile(path)
1173 1173
1174 def Emit(self, emitter, auxiliary_dir): 1174 def Emit(self, emitter, auxiliary_dir):
1175 for lib in self._libraries.values(): 1175 for lib in self._libraries.values():
1176 lib.Emit(emitter, auxiliary_dir) 1176 lib.Emit(emitter, auxiliary_dir)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698