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

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

Issue 10388084: Better support for the case of typed arrays inheriting from other typed arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: better comment Created 8 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 | « lib/dom/scripts/systeminterface.py ('k') | lib/html/dartium/html_dartium.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 systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 # 594 #
595 # In the non-root case we have to choose between: 595 # In the non-root case we have to choose between:
596 # 596 #
597 # class YImpl extends XImpl { add List<T> methods; } 597 # class YImpl extends XImpl { add List<T> methods; }
598 # 598 #
599 # and 599 # and
600 # 600 #
601 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } 601 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
602 # 602 #
603 dart_element_type = DartType(element_type) 603 dart_element_type = DartType(element_type)
604 if ('CustomIndexedGetter' in self._interface.ext_attrs or 604 if self._HasNativeIndexGetter():
605 'NumericIndexedGetter' in self._interface.ext_attrs):
606 self._EmitNativeIndexGetter(dart_element_type) 605 self._EmitNativeIndexGetter(dart_element_type)
607 else: 606 else:
608 self._members_emitter.Emit( 607 self._members_emitter.Emit(
609 '\n' 608 '\n'
610 ' $TYPE operator[](int index) {\n' 609 ' $TYPE operator[](int index) {\n'
611 ' return item(index);\n' 610 ' return item(index);\n'
612 ' }\n', 611 ' }\n',
613 TYPE=dart_element_type) 612 TYPE=dart_element_type)
614 613
615 if 'CustomIndexedSetter' in self._interface.ext_attrs: 614 if self._HasNativeIndexSetter():
616 self._EmitNativeIndexSetter(dart_element_type) 615 self._EmitNativeIndexSetter(dart_element_type)
617 else: 616 else:
618 self._members_emitter.Emit( 617 self._members_emitter.Emit(
619 '\n' 618 '\n'
620 ' void operator[]=(int index, $TYPE value) {\n' 619 ' void operator[]=(int index, $TYPE value) {\n'
621 ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n' 620 ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n'
622 ' }\n', 621 ' }\n',
623 TYPE=dart_element_type) 622 TYPE=dart_element_type)
624 623
625 self._members_emitter.Emit( 624 self._members_emitter.Emit(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 '\n' 703 '\n'
705 ' bool isEmpty() {\n' 704 ' bool isEmpty() {\n'
706 ' return length == 0;\n' 705 ' return length == 0;\n'
707 ' }\n' 706 ' }\n'
708 '\n' 707 '\n'
709 ' Iterator<$TYPE> iterator() {\n' 708 ' Iterator<$TYPE> iterator() {\n'
710 ' return new _FixedSizeListIterator<$TYPE>(this);\n' 709 ' return new _FixedSizeListIterator<$TYPE>(this);\n'
711 ' }\n', 710 ' }\n',
712 TYPE=dart_element_type) 711 TYPE=dart_element_type)
713 712
713 def AmendIndexer(self, element_type):
714 # If interface is marked as having native indexed
715 # getter or setter, we must emit overrides as it's not
716 # guaranteed that the corresponding methods in C++ would be
717 # virtual. For example, as of time of writing, even though
718 # Uint8ClampedArray inherits from Uint8Array, ::set method
719 # is not virtual and accessing it through Uint8Array pointer
720 # would lead to wrong semantics (modulo vs. clamping.)
721 dart_element_type = DartType(element_type)
722
723 if self._HasNativeIndexGetter():
724 self._EmitNativeIndexGetter(dart_element_type)
725 if self._HasNativeIndexSetter():
726 self._EmitNativeIndexSetter(dart_element_type)
727
728 def _HasNativeIndexGetter(self):
729 ext_attrs = self._interface.ext_attrs
730 return ('CustomIndexedGetter' in ext_attrs or
731 'NumericIndexedGetter' in ext_attrs)
732
714 def _EmitNativeIndexGetter(self, element_type): 733 def _EmitNativeIndexGetter(self, element_type):
715 dart_declaration = '%s operator[](int index)' % element_type 734 dart_declaration = '%s operator[](int index)' % element_type
716 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration, 735 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration,
717 'Callback', True) 736 'Callback', True)
718 737
738 def _HasNativeIndexSetter(self):
739 return 'CustomIndexedSetter' in self._interface.ext_attrs
740
719 def _EmitNativeIndexSetter(self, element_type): 741 def _EmitNativeIndexSetter(self, element_type):
720 dart_declaration = 'void operator[]=(int index, %s value)' % element_type 742 dart_declaration = 'void operator[]=(int index, %s value)' % element_type
721 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, 743 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration,
722 'Callback', True) 744 'Callback', True)
723 745
724 def _AddOperation(self, info): 746 def _AddOperation(self, info):
725 """ 747 """
726 Arguments: 748 Arguments:
727 info: An OperationInfo object. 749 info: An OperationInfo object.
728 """ 750 """
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 def _InstanceOfNode(database, interface): 1143 def _InstanceOfNode(database, interface):
1122 if interface.id == 'Node': 1144 if interface.id == 'Node':
1123 return True 1145 return True
1124 for parent in interface.parents: 1146 for parent in interface.parents:
1125 if not database.HasInterface(parent.type.id): 1147 if not database.HasInterface(parent.type.id):
1126 continue 1148 continue
1127 parent_interface = database.GetInterface(parent.type.id) 1149 parent_interface = database.GetInterface(parent.type.id)
1128 if _InstanceOfNode(database, parent_interface): 1150 if _InstanceOfNode(database, parent_interface):
1129 return True 1151 return True
1130 return False 1152 return False
OLDNEW
« no previous file with comments | « lib/dom/scripts/systeminterface.py ('k') | lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698