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

Unified Diff: lib/dom/scripts/generator.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: Rebaseline 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
Index: lib/dom/scripts/generator.py
diff --git a/lib/dom/scripts/generator.py b/lib/dom/scripts/generator.py
index cb7adfdab98cca1ab7dfe672cec221e32620121f..2e055466209fa3eab1a8b0e0c45139da342a6c9e 100644
--- a/lib/dom/scripts/generator.py
+++ b/lib/dom/scripts/generator.py
@@ -85,6 +85,27 @@ dom_frog_native_bodies = {
def IsPrimitiveType(type_name):
return isinstance(GetIDLTypeInfo(type_name), PrimitiveIDLTypeInfo)
+def ListImplementationInfo(interface, database):
+ """Returns a tuple (elment_type, requires_indexer).
+ If interface do not have to implement List, element_type is None.
+ Otherwise element_type is list element type and requires_indexer
+ is true iff this interface implementation must have indexer and
+ false otherwise. False means that interface implementation
+ inherits indexer and may just reuse it."""
podivilov 2012/05/12 08:35:10 Maybe mention that it is needed to override indexe
Anton Muhin 2012/05/12 08:37:03 Not sure, let's keep it generic: I don't think tha
podivilov 2012/05/12 08:39:06 I just think that a note about why it is __really_
+ element_type = MaybeListElementType(interface)
+ if element_type:
+ return (element_type, True)
+
+ for parent in interface.parents:
+ if database.HasInterface(parent.type.id):
+ parent_interface = database.GetInterface(parent.type.id)
+ (element_type, _) = ListImplementationInfo(parent_interface, database)
+ if element_type:
+ return (element_type, False)
+
+ return (None, None)
+
+
def MaybeListElementTypeName(type_name):
"""Returns the List element type T from string of form "List<T>", or None."""
match = re.match(r'sequence<(\w*)>$', type_name)
@@ -108,10 +129,26 @@ def MaybeTypedArrayElementType(interface):
"""
# Typed arrays implement ArrayBufferView and List<T>.
for parent in interface.parents:
- if parent.type.id == 'ArrayBufferView':
+ if parent.type.id == 'ArrayBufferView':
return MaybeListElementType(interface)
return None
+def MaybeTypedArrayElementTypeInHierarchy(interface, database):
+ """Returns the typed array element type, or None in interface is not a
+ TypedArray. Checks the whole parent hierarchy.
+ """
+ element_type = MaybeTypedArrayElementType(interface)
+ if element_type:
+ return element_type
+ for parent in interface.parents:
+ if database.HasInterface(parent.type.id):
+ parent_interface = database.GetInterface(parent.type.id)
+ element_type = MaybeTypedArrayElementType(parent_interface)
+ if element_type:
+ return element_type
+
+ return None
+
def MakeNativeSpec(javascript_binding_name):
if javascript_binding_name in _frog_dom_custom_native_specs:
return _frog_dom_custom_native_specs[javascript_binding_name]

Powered by Google App Engine
This is Rietveld 408576698