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

Unified Diff: client/dom/scripts/dartgenerator.py

Issue 8784013: Fix CanvasPixelArray's operator[] for the wrapping js dom (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rerun Created 9 years 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 | « client/dom/idl/dart/dart.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index 828ea069c886b919d8144ba40bb68f205f34fbf8..e36610f84e09f984f699068f8fb6f113c44e5035 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -461,7 +461,6 @@ class DartGenerator(object):
ARGS=info.arg_implementation_declaration)
-
def _ProcessInterface(self, interface, super_interface_name,
source_filter,
common_prefix):
@@ -1462,16 +1461,62 @@ class WrappingInterfaceGenerator(object):
#
# class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
#
+ if ('HasIndexGetter' in self._interface.ext_attrs or
+ 'HasNumericIndexGetter' in self._interface.ext_attrs):
+ method_name = '_index'
+ self._members_emitter.Emit(
+ '\n'
+ ' $TYPE operator[](int index) { return $METHOD(this, index); }\n'
+ ' static $TYPE $METHOD(var _this, int index) native;\n',
+ TYPE=element_type, METHOD=method_name)
+ self._js_code.Emit(
+ '\n'
+ 'function native_$(CLASS)_$(METHOD)(_this, index) {\n'
+ ' try {\n'
+ ' return __dom_wrap(_this.$dom[index]);\n'
+ ' } catch (e) {\n'
+ ' throw __dom_wrap_exception(e);\n'
+ ' }\n'
+ '}\n',
+ CLASS=self._class_name, METHOD=method_name)
+ else:
+ self._members_emitter.Emit(
+ '\n'
+ ' $TYPE operator[](int index) {\n'
+ ' return item(index);\n'
+ ' }\n',
+ TYPE=element_type)
+
+
+ if 'HasCustomIndexSetter' in self._interface.ext_attrs:
+ method_name = '_set_index'
+ self._members_emitter.Emit(
+ '\n'
+ ' void operator[]=(int index, $TYPE value) {\n'
+ ' return $METHOD(this, index, value);\n'
+ ' }\n'
+ ' static $METHOD(_this, index, value) native;\n',
+ TYPE=element_type, METHOD=method_name)
+ self._js_code.Emit(
+ '\n'
+ 'function native_$(CLASS)_$(METHOD)(_this, index, value) {\n'
+ ' try {\n'
+ ' return _this.$dom[index] = __dom_unwrap(value);\n'
+ ' } catch (e) {\n'
+ ' throw __dom_wrap_exception(e);\n'
+ ' }\n'
+ '}\n',
+ CLASS=self._class_name, METHOD=method_name)
+ else:
+ self._members_emitter.Emit(
+ '\n'
+ ' void operator[]=(int index, $TYPE value) {\n'
+ ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n'
+ ' }\n',
+ TYPE=element_type)
+
self._members_emitter.Emit(
'\n'
- ' $TYPE operator[](int index) {\n'
- ' return item(index);\n'
- ' }\n'
- '\n'
- ' void operator[]=(int index, $TYPE value) {\n'
- ' throw new UnsupportedOperationException("Cannot assign element of immutable List.");\n'
- ' }\n'
- '\n'
' void add($TYPE value) {\n'
' throw new UnsupportedOperationException("Cannot add to immutable List.");\n'
' }\n'
« no previous file with comments | « client/dom/idl/dart/dart.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698