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

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
« no previous file with comments | « tests/html/node_test.dart ('k') | tools/dom/scripts/systemnative.py » ('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 import monitored 10 import monitored
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 # and 705 # and
706 # 706 #
707 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 707 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
708 # 708 #
709 709
710 ext_attrs = self._interface.ext_attrs 710 ext_attrs = self._interface.ext_attrs
711 has_indexed_getter = ('IndexedGetter' in ext_attrs or 711 has_indexed_getter = ('IndexedGetter' in ext_attrs or
712 'CustomIndexedSetter' in ext_attrs) 712 'CustomIndexedSetter' in ext_attrs)
713 713
714 if has_indexed_getter: 714 if has_indexed_getter:
715 indexed_getter = ('JS("%s", "#[#]", this, index)' %
716 self.SecureOutputType(element_type));
717 elif any(op.id == 'getItem' for op in self._interface.operations):
718 indexed_getter = 'this.getItem(index)'
719 elif any(op.id == 'item' for op in self._interface.operations):
720 indexed_getter = 'this.item(index)'
721
722 if indexed_getter:
715 self._members_emitter.Emit( 723 self._members_emitter.Emit(
716 '\n' 724 '\n'
717 ' $TYPE operator[](int index) => ' 725 ' $TYPE operator[](int index) {\n'
718 'JS("$TYPE", "#[#]", this, index);\n', 726 ' if (JS("bool", "# >>> 0 !== # || # >= #", index,\n'
719 TYPE=self.SecureOutputType(element_type)) 727 ' index, index, length))\n'
720 else: 728 ' throw new RangeError.range(index, 0, length);\n'
721 if any(op.id == 'getItem' for op in self._interface.operations): 729 ' return $INDEXED_GETTER;\n'
722 indexed_getter = 'this.getItem(index)' 730 ' }',
723 elif any(op.id == 'item' for op in self._interface.operations):
724 indexed_getter = 'this.item(index)'
725 self._members_emitter.Emit(
726 '\n'
727 ' $TYPE operator[](int index) => $INDEXED_GETTER;\n',
728 INDEXED_GETTER=indexed_getter, 731 INDEXED_GETTER=indexed_getter,
729 TYPE=self.SecureOutputType(element_type)) 732 TYPE=self.SecureOutputType(element_type))
730 733
731 if 'CustomIndexedSetter' in self._interface.ext_attrs: 734 if 'CustomIndexedSetter' in self._interface.ext_attrs:
732 self._members_emitter.Emit( 735 self._members_emitter.Emit(
733 '\n' 736 '\n'
734 ' void operator[]=(int index, $TYPE value) {' 737 ' void operator[]=(int index, $TYPE value) {'
735 ' JS("void", "#[#] = #", this, index, value); }', 738 ' JS("void", "#[#] = #", this, index, value); }',
736 TYPE=self._NarrowInputType(element_type)) 739 TYPE=self._NarrowInputType(element_type))
737 else: 740 else:
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 for library_name in libraries: 1171 for library_name in libraries:
1169 self._libraries[library_name] = DartLibrary( 1172 self._libraries[library_name] = DartLibrary(
1170 library_name, template_loader, library_type, output_dir) 1173 library_name, template_loader, library_type, output_dir)
1171 1174
1172 def AddFile(self, basename, library_name, path): 1175 def AddFile(self, basename, library_name, path):
1173 self._libraries[library_name].AddFile(path) 1176 self._libraries[library_name].AddFile(path)
1174 1177
1175 def Emit(self, emitter, auxiliary_dir): 1178 def Emit(self, emitter, auxiliary_dir):
1176 for lib in self._libraries.values(): 1179 for lib in self._libraries.values():
1177 lib.Emit(emitter, auxiliary_dir) 1180 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « tests/html/node_test.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698