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

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

Issue 23534050: Make direct calls to _nativeIndexedGetter in "get last" "get first" "get single" instead of calling… (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
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/templateloader.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 from generator import AnalyzeOperation, ConstantOutputOrder, \ 10 from generator import AnalyzeOperation, ConstantOutputOrder, \
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 NAME=method_name, 628 NAME=method_name,
629 PARAMS=operation.ParametersDeclaration(self._DartType)) 629 PARAMS=operation.ParametersDeclaration(self._DartType))
630 630
631 def EmitListMixin(self, element_name): 631 def EmitListMixin(self, element_name):
632 # TODO(sra): Use separate mixins for mutable implementations of List<T>. 632 # TODO(sra): Use separate mixins for mutable implementations of List<T>.
633 # TODO(sra): Use separate mixins for typed array implementations of List<T>. 633 # TODO(sra): Use separate mixins for typed array implementations of List<T>.
634 template_file = 'immutable_list_mixin.darttemplate' 634 template_file = 'immutable_list_mixin.darttemplate'
635 has_length = False 635 has_length = False
636 has_length_setter = False 636 has_length_setter = False
637 637
638 def _HasExplicitIndexedGetter(self):
639 return any(op.id == 'getItem' for op in self._interface.operations)
640
641 def _HasCustomIndexedGetter(self):
642 return 'CustomIndexedGetter' in self._interface.ext_attrs
643
644 def _HasNativeIndexedGetter(self):
645 return not (_HasCustomIndexedGetter(self) or _HasExplicitIndexedGetter(sel f))
646
647 if _HasExplicitIndexedGetter(self):
648 getter_name = 'getItem'
649 else:
650 getter_name = '_nativeIndexedGetter'
651
638 for attr in self._interface.attributes: 652 for attr in self._interface.attributes:
639 if attr.id == 'length': 653 if attr.id == 'length':
640 has_length = True 654 has_length = True
641 has_length_setter = not attr.is_read_only 655 has_length_setter = not attr.is_read_only
642 656
643 has_num_items = any(attr.id == 'numberOfItems' 657 has_num_items = any(attr.id == 'numberOfItems'
644 for attr in self._interface.attributes) 658 for attr in self._interface.attributes)
645 659
646 template = self._template_loader.Load( 660 template = self._template_loader.Load(
647 template_file, 661 template_file,
648 { 662 {
649 'DEFINE_LENGTH_AS_NUM_ITEMS': not has_length and has_num_items, 663 'DEFINE_LENGTH_AS_NUM_ITEMS': not has_length and has_num_items,
650 'DEFINE_LENGTH_SETTER': not has_length_setter, 664 'DEFINE_LENGTH_SETTER': not has_length_setter,
665 'USE_NATIVE_INDEXED_GETTER': _HasNativeIndexedGetter(self) or _HasExpl icitIndexedGetter(self),
651 }) 666 })
652 self._members_emitter.Emit(template, E=element_name) 667 self._members_emitter.Emit(template, E=element_name, GETTER=getter_name)
653 668
654 def SecureOutputType(self, type_name, is_dart_type=False, 669 def SecureOutputType(self, type_name, is_dart_type=False,
655 can_narrow_type=False): 670 can_narrow_type=False):
656 """ Converts the type name to the secure type name for return types. 671 """ Converts the type name to the secure type name for return types.
657 Arguments: 672 Arguments:
658 can_narrow_type - True if the output type can be narrowed further than 673 can_narrow_type - True if the output type can be narrowed further than
659 what would be accepted for input, used to narrow num APIs down to double 674 what would be accepted for input, used to narrow num APIs down to double
660 or int. 675 or int.
661 """ 676 """
662 if is_dart_type: 677 if is_dart_type:
(...skipping 13 matching lines...) Expand all
676 691
677 def SecureBaseName(self, type_name): 692 def SecureBaseName(self, type_name):
678 if type_name in _secure_base_types: 693 if type_name in _secure_base_types:
679 return _secure_base_types[type_name] 694 return _secure_base_types[type_name]
680 695
681 def _DartType(self, type_name): 696 def _DartType(self, type_name):
682 return self._type_registry.DartType(type_name) 697 return self._type_registry.DartType(type_name)
683 698
684 def _TypeInfo(self, type_name): 699 def _TypeInfo(self, type_name):
685 return self._type_registry.TypeInfo(type_name) 700 return self._type_registry.TypeInfo(type_name)
OLDNEW
« no previous file with comments | « sdk/lib/web_sql/dartium/web_sql_dartium.dart ('k') | tools/dom/scripts/templateloader.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698