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

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

Issue 9271036: Implement List<T> operations on dom types via manual mixins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: remove debug comment Created 8 years, 11 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 | « client/dom/generated/src/frog/Uint8Array.dart ('k') | client/dom/src/_Lists.dart » ('j') | 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 98021ad1b6e0bc89b8a92b37e483a52a15212552..0a8184d4cacfab2ba85606a4f436a565665394fd 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -725,14 +725,21 @@ class OperationInfo(object):
return ', '.join(argtexts)
+def MaybeListElementTypeName(type_name):
+ """Returns the List element type T from string of form "List<T>", or None."""
+ match = re.match(r'List<(\w*)>$', type_name)
+ if match:
+ return match.group(1)
+ return None
+
def MaybeListElementType(interface):
"""Returns the List element type T, or None in interface does not implement
List<T>.
"""
for parent in interface.parents:
- match = re.match(r'List<(\w*)>$', parent.type.id)
- if match:
- return match.group(1)
+ element_type = MaybeListElementTypeName(parent.type.id)
+ if element_type:
+ return element_type
return None
def MaybeTypedArrayElementType(interface):
@@ -1857,6 +1864,7 @@ class FrogInterfaceGenerator(object):
if base:
extends = ' extends ' + base
elif native_spec[0] == '=':
+ # The implementation is a singleton with no prototype.
extends = ''
else:
extends = ' extends DOMTypeJs'
@@ -1976,13 +1984,13 @@ class FrogInterfaceGenerator(object):
#
self._members_emitter.Emit(
'\n'
- ' $TYPE operator[](int index) native;\n',
+ ' $TYPE operator[](int index) native "return this[index];";\n',
TYPE=self._NarrowOutputType(element_type))
if 'HasCustomIndexSetter' in self._interface.ext_attrs:
self._members_emitter.Emit(
'\n'
- ' void operator[]=(int index, $TYPE value) native;\n',
+ ' void operator[]=(int index, $TYPE value) native "this[index] = value";\n',
TYPE=self._NarrowInputType(element_type))
else:
self._members_emitter.Emit(
@@ -1992,6 +2000,12 @@ class FrogInterfaceGenerator(object):
' }\n',
TYPE=self._NarrowInputType(element_type))
+ # TODO(sra): Use separate mixins for mutable implementations of List<T>.
+ # TODO(sra): Use separate mixins for typed array implementations of List<T>.
+ template_file = 'immutable_list_mixin.darttemplate'
+ template = self._system._templates.Load(template_file)
+ self._members_emitter.Emit(template, E=element_type)
+
def AddTypedArrayConstructors(self, element_type):
self._members_emitter.Emit(
« no previous file with comments | « client/dom/generated/src/frog/Uint8Array.dart ('k') | client/dom/src/_Lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698