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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/dom/scripts/systeminterface.py ('k') | lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/systemnative.py
diff --git a/lib/dom/scripts/systemnative.py b/lib/dom/scripts/systemnative.py
index 64ee82ce29bb98450e0eee8c7ef098751bf1db56..bec4e5ea32943d8bddafab9b001c04d067b059e9 100644
--- a/lib/dom/scripts/systemnative.py
+++ b/lib/dom/scripts/systemnative.py
@@ -601,8 +601,7 @@ class NativeImplementationGenerator(object):
# class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
#
dart_element_type = DartType(element_type)
- if ('CustomIndexedGetter' in self._interface.ext_attrs or
- 'NumericIndexedGetter' in self._interface.ext_attrs):
+ if self._HasNativeIndexGetter():
self._EmitNativeIndexGetter(dart_element_type)
else:
self._members_emitter.Emit(
@@ -612,7 +611,7 @@ class NativeImplementationGenerator(object):
' }\n',
TYPE=dart_element_type)
- if 'CustomIndexedSetter' in self._interface.ext_attrs:
+ if self._HasNativeIndexSetter():
self._EmitNativeIndexSetter(dart_element_type)
else:
self._members_emitter.Emit(
@@ -711,11 +710,34 @@ class NativeImplementationGenerator(object):
' }\n',
TYPE=dart_element_type)
+ def AmendIndexer(self, element_type):
+ # If interface is marked as having native indexed
+ # getter or setter, we must emit overrides as it's not
+ # guaranteed that the corresponding methods in C++ would be
+ # virtual. For example, as of time of writing, even though
+ # Uint8ClampedArray inherits from Uint8Array, ::set method
+ # is not virtual and accessing it through Uint8Array pointer
+ # would lead to wrong semantics (modulo vs. clamping.)
+ dart_element_type = DartType(element_type)
+
+ if self._HasNativeIndexGetter():
+ self._EmitNativeIndexGetter(dart_element_type)
+ if self._HasNativeIndexSetter():
+ self._EmitNativeIndexSetter(dart_element_type)
+
+ def _HasNativeIndexGetter(self):
+ ext_attrs = self._interface.ext_attrs
+ return ('CustomIndexedGetter' in ext_attrs or
+ 'NumericIndexedGetter' in ext_attrs)
+
def _EmitNativeIndexGetter(self, element_type):
dart_declaration = '%s operator[](int index)' % element_type
self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration,
'Callback', True)
+ def _HasNativeIndexSetter(self):
+ return 'CustomIndexedSetter' in self._interface.ext_attrs
+
def _EmitNativeIndexSetter(self, element_type):
dart_declaration = 'void operator[]=(int index, %s value)' % element_type
self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration,
« 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