| 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."""
|
| + 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]
|
|
|