Roll IDL Dartium37 (r181477)
Reviewers: vsm

R=vsm@google.com

Review URL: https://codereview.chromium.org//551053003

git-svn-id: http://dart.googlecode.com/svn/third_party/WebCore@39980 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/bindings/IDLExtendedAttributes.txt b/bindings/IDLExtendedAttributes.txt
index dafd683..044d188 100644
--- a/bindings/IDLExtendedAttributes.txt
+++ b/bindings/IDLExtendedAttributes.txt
@@ -56,6 +56,14 @@
 DartSuppress=|Getter|Setter
 # No need to setup Dart API scope when a native function is invoked. 
 DartNoAutoScope
+# TODO(terry): Used in dart.idl - look at removing or using 
+DartSupplemental
+# TODO(terry): Used in dart.idl (look at eliminating).
+DartForceOptional
+# TODO(terry): Used in dart.idl (look at eliminating).
+DartCallback
+# TODO(terry): Used in dart.idl (look at eliminating).
+DartStrictTypeChecking
 # End of Dartium attributes.
 Default=Undefined
 DependentLifetime
diff --git a/bindings/README b/bindings/README
index bf749b3..e77b8dc 100644
--- a/bindings/README
+++ b/bindings/README
@@ -6,4 +6,4 @@
 
 The current version corresponds to:
 URL: http://src.chromium.org/blink/branches/dart/dartium
-Current revision: 181268
+Current revision: 181477
diff --git a/bindings/dart/scripts/dart_attributes.py b/bindings/dart/scripts/dart_attributes.py
index 6e295ca..24c9fa3 100644
--- a/bindings/dart/scripts/dart_attributes.py
+++ b/bindings/dart/scripts/dart_attributes.py
@@ -160,6 +160,19 @@
     if (not attribute.is_read_only):
         generate_setter(interface, attribute, contents)
 
+    native_entry_getter = \
+        DartUtilities.generate_native_entry(interface.name, contents,
+                                            attribute.name, 'Getter',
+                                            None, [], None)
+    native_entry_setter = \
+        DartUtilities.generate_native_entry(interface.name, contents,
+                                            attribute.name, 'Setter',
+                                            None, ["value"], None)
+    contents.update({
+        'native_entry_getter': native_entry_getter,
+        'native_entry_setter': native_entry_setter,
+    })
+
     return contents
 
 
diff --git a/bindings/dart/scripts/dart_interface.py b/bindings/dart/scripts/dart_interface.py
index 540c3ac..efd70f0 100644
--- a/bindings/dart/scripts/dart_interface.py
+++ b/bindings/dart/scripts/dart_interface.py
@@ -395,6 +395,20 @@
     return False
 
 
+def add_native_entries(interface, constructors, is_custom):
+    for constructor in constructors:
+        types = None
+        if not is_custom:
+            types = [arg['preprocessed_type']
+                     for arg in constructor['arguments']]
+        argument_names = [arg['name'] for arg in constructor['arguments']]
+        native_entry = \
+            DartUtilities.generate_native_entry(interface.name, constructor,
+                                                None, 'Constructor', None,
+                                                argument_names, types)
+        constructor.update({'native_entry': native_entry})
+
+
 def generate_interface(interface):
     includes.clear()
     includes.update(INTERFACE_CPP_INCLUDES)
@@ -540,6 +554,11 @@
     # [NamedConstructor]
     named_constructor = generate_named_constructor(interface)
 
+    add_native_entries(interface, constructors, bool(custom_constructors))
+    add_native_entries(interface, custom_constructors, bool(custom_constructors))
+    if named_constructor:
+        add_native_entries(interface, [named_constructor], bool(custom_constructors))
+
     if (constructors or custom_constructors or has_event_constructor or
         named_constructor):
         includes.add('core/frame/LocalDOMWindow.h')
@@ -609,6 +628,8 @@
             # For overloaded methods, only generate one accessor
             ('overload_index' not in method or method['overload_index'] == 1))
 
+    generate_method_native_entries(interface, methods)
+
     template_contents.update({
         'has_origin_safe_method_setter': any(
             method['is_check_security_for_frame'] and not method['is_read_only']
@@ -618,6 +639,10 @@
         'methods': methods,
     })
 
+    native_entries = generate_native_entries(interface, constructors,
+                                             custom_constructors, attributes,
+                                             methods, named_constructor)
+
     template_contents.update({
         'indexed_property_getter': indexed_property_getter(interface),
         'indexed_property_setter': indexed_property_setter(interface),
@@ -626,11 +651,29 @@
         'named_property_getter': named_property_getter(interface),
         'named_property_setter': named_property_setter(interface),
         'named_property_deleter': named_property_deleter(interface),
+        'native_entries': native_entries,
     })
 
     return template_contents
 
 
+def generate_native_entries(interface, constructors, custom_constructors,
+                            attributes, methods, named_constructor):
+    entries = []
+    for constructor in constructors:
+        entries.append(constructor['native_entry'])
+    for constructor in custom_constructors:
+        entries.append(constructor['native_entry'])
+    if named_constructor:
+        entries.append(named_constructor['native_entry'])
+    for method in methods:
+        entries.extend(method['native_entries'])
+    for attribute in attributes:
+        entries.append(attribute['native_entry_getter'])
+        entries.append(attribute['native_entry_setter'])
+    return entries
+
+
 # [DeprecateAs], [Reflect], [RuntimeEnabled]
 def generate_constant(constant):
     # (Blink-only) string literals are unquoted in tokenizer, must be re-quoted
@@ -655,6 +698,46 @@
 # Overloads
 ################################################################################
 
+def generate_method_native_entry(interface, method, count, optional_index):
+    types = None
+    if not method['is_custom']:
+        types = [arg['preprocessed_type'] for arg in method['arguments'][0:count]]
+    if method['is_call_with_script_arguments']:
+        types.append("object")
+    argument_names = [arg['name'] for arg in method['arguments'][0:count]]
+    name = method['name']
+    native_entry = \
+        DartUtilities.generate_native_entry(interface.name, method,
+                                            name, 'Method',
+                                            optional_index,
+                                            argument_names, types)
+    return native_entry
+
+
+def generate_method_native_entries(interface, methods):
+    for method in methods:
+        native_entries = []
+        required_arg_count = method['number_of_required_arguments']
+        arg_count = method['number_of_arguments']
+        if required_arg_count != arg_count:
+            for x in range(required_arg_count, arg_count + 1):
+                # This is really silly, but is here for now just to match up
+                # the existing name generation in the old dart:html scripts
+                index = arg_count - x + 1
+                native_entry = \
+                    generate_method_native_entry(interface, method, x, index)
+                native_entries.append(native_entry)
+        else:
+            # Eventually, we should probably always generate an unindexed
+            # native entry, to handle cases like
+            # addEventListener in which we suppress the optionality,
+            # and in general to make us more robust against optional changes
+            native_entry = \
+                generate_method_native_entry(interface, method, arg_count, None)
+            native_entries.append(native_entry)
+
+        method.update({'native_entries': native_entries})
+
 def generate_overloads(methods):
     generate_overloads_by_type(methods, is_static=False)  # Regular methods
     generate_overloads_by_type(methods, is_static=True)
@@ -830,7 +913,8 @@
 def custom_constructor_argument(argument, index):
     return {
         'idl_type_object': argument.idl_type,
-        'preprocessed_type': argument.idl_type.preprocessed_type,
+        'name': argument.name,
+        'preprocessed_type': str(argument.idl_type.preprocessed_type),
     }
 
 
@@ -899,7 +983,7 @@
         # FIXME: remove once [Default] removed and just use argument.default_value
         'has_default': 'Default' in argument.extended_attributes or default_value,
         'idl_type_object': idl_type,
-        'preprocessed_type': idl_type.preprocessed_type,
+        'preprocessed_type': str(idl_type.preprocessed_type),
         # Dictionary is special-cased, but arrays and sequences shouldn't be
         'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
         'index': index,
diff --git a/bindings/dart/scripts/dart_methods.py b/bindings/dart/scripts/dart_methods.py
index 0a59338..aac8f5e 100644
--- a/bindings/dart/scripts/dart_methods.py
+++ b/bindings/dart/scripts/dart_methods.py
@@ -86,10 +86,23 @@
         this_cpp_type = idl_type.cpp_type
 
     is_auto_scope = not 'DartNoAutoScope' in extended_attributes
+
+    number_of_arguments = len(arguments)
+
+    number_of_required_arguments = \
+        len([
+            argument for argument in arguments
+            if not ((argument.is_optional and not ('Default' in argument.extended_attributes or argument.default_value)) or
+                    argument.is_variadic)])
+
+    arguments_data = [generate_argument(interface, method, argument, index)
+                      for index, argument in enumerate(arguments)]
+
+    is_custom = 'Custom' in extended_attributes or 'DartCustom' in extended_attributes
+
     method_data = {
         'activity_logging_world_list': DartUtilities.activity_logging_world_list(method),  # [ActivityLogging]
-        'arguments': [generate_argument(interface, method, argument, index)
-                      for index, argument in enumerate(arguments)],
+        'arguments': arguments_data,
         'conditional_string': DartUtilities.conditional_string(method),
         'cpp_type': this_cpp_type,
         'cpp_value': this_cpp_value,
@@ -116,7 +129,7 @@
         'is_call_with_script_state': is_call_with_script_state,
         'is_check_security_for_frame': is_check_security_for_frame,
         'is_check_security_for_node': is_check_security_for_node,
-        'is_custom': 'Custom' in extended_attributes or 'DartCustom' in extended_attributes,
+        'is_custom': is_custom,
         'is_custom_dart': 'DartCustom' in extended_attributes,
         'is_custom_dart_new': DartUtilities.has_extended_attribute_value(method, 'DartCustom', 'New'),
         'is_custom_element_callbacks': is_custom_element_callbacks,
@@ -135,11 +148,8 @@
         'is_variadic': arguments and arguments[-1].is_variadic,
         'measure_as': DartUtilities.measure_as(method),  # [MeasureAs]
         'name': name,
-        'number_of_arguments': len(arguments),
-        'number_of_required_arguments': len([
-            argument for argument in arguments
-            if not ((argument.is_optional and not ('Default' in argument.extended_attributes or argument.default_value)) or
-                    argument.is_variadic)]),
+        'number_of_arguments': number_of_arguments,
+        'number_of_required_arguments': number_of_required_arguments,
         'number_of_required_or_variadic_arguments': len([
             argument for argument in arguments
             if not argument.is_optional]),
diff --git a/bindings/dart/scripts/dart_utilities.py b/bindings/dart/scripts/dart_utilities.py
index f67437b..38e3899 100644
--- a/bindings/dart/scripts/dart_utilities.py
+++ b/bindings/dart/scripts/dart_utilities.py
@@ -132,6 +132,39 @@
     return extended_attributes['MeasureAs']
 
 
+def _generate_native_entry(interface_name, thing, name, kind,
+                           optional_index, args, types):
+    index = thing.get('overload_index') or optional_index
+    is_static = bool(thing.get('is_static'))
+    tag = ""
+    if kind == 'Getter':
+        tag = "%s_Getter" % name
+        blink_entry = tag
+    elif kind == 'Setter':
+        tag = "%s_Setter" % name
+        blink_entry = tag
+    elif kind == 'Constructor':
+        tag = "constructorCallback"
+        blink_entry = tag
+        if index is not None:
+            blink_entry = "_create_%s%s" % (index, blink_entry)
+    elif kind == 'Method':
+        tag = "%s_Callback" % name
+        if index is None:
+            blink_entry = tag
+        else:
+            blink_entry = "_%s_%d_Callback" % (name, index)
+    native_entry = "%s_%s" % (interface_name, tag)
+    if types is not None:
+        count = len(types)
+        types = "_".join(types)
+        native_entry = "%s_RESOLVER_STRING_%d_%s" % (native_entry, count, types)
+    if not is_static and kind != 'Constructor':
+        args.insert(0, "mthis")
+    return {'blink_entry': "$" + blink_entry,
+            'argument_names': args,
+            'resolver_string': native_entry}
+
 ################################################################################
 # This is the monkey patched methods most delegate to v8_utilities but some are
 # overridden in dart_utilities.
@@ -153,6 +186,7 @@
 DartUtilities.deprecate_as = _deprecate_as
 DartUtilities.extended_attribute_value_contains = v8_utilities.extended_attribute_value_contains
 DartUtilities.gc_type = v8_utilities.gc_type
+DartUtilities.generate_native_entry = _generate_native_entry
 DartUtilities.has_extended_attribute = v8_utilities.has_extended_attribute
 DartUtilities.has_extended_attribute_value = v8_utilities.has_extended_attribute_value
 DartUtilities.measure_as = _measure_as
diff --git a/bindings/scripts/idl_reader.py b/bindings/scripts/idl_reader.py
index 450c73d..3828668 100644
--- a/bindings/scripts/idl_reader.py
+++ b/bindings/scripts/idl_reader.py
@@ -42,7 +42,8 @@
 
 
 class IdlReader(object):
-    def __init__(self, interfaces_info=None, outputdir=''):
+    def __init__(self, interfaces_info=None, outputdir='', multi_interface=False):
+        self.multi_interface = multi_interface
         self.extended_attribute_validator = IDLExtendedAttributeValidator()
 
         if interfaces_info:
@@ -71,23 +72,27 @@
             raise Exception('Failed to parse %s' % idl_filename)
         definitions = IdlDefinitions(ast)
 
-        # Validate file contents with filename convention
-        # The Blink IDL filenaming convention is that the file
-        # <interface_name>.idl MUST contain exactly 1 interface (or exception),
-        # and the interface name must agree with the file's basename,
-        # unless it is a partial interface.
-        # (e.g., 'partial interface Foo' can be in FooBar.idl).
-        number_of_interfaces = len(definitions.interfaces)
-        if number_of_interfaces != 1:
-            raise Exception(
-                'Expected exactly 1 interface in file {0}, but found {1}'
-                .format(idl_filename, number_of_interfaces))
-        interface = next(definitions.interfaces.itervalues())
-        idl_file_basename, _ = os.path.splitext(os.path.basename(idl_filename))
-        if not interface.is_partial and interface.name != idl_file_basename:
-            raise Exception(
-                'Interface name "{0}" disagrees with IDL file basename "{1}".'
-                .format(interface.name, idl_file_basename))
+        if not self.multi_interface:
+            # Validate file contents with filename convention
+            # The Blink IDL filenaming convention is that the file
+            # <interface_name>.idl MUST contain exactly 1 interface (or exception),
+            # and the interface name must agree with the file's basename,
+            # unless it is a partial interface.
+            # (e.g., 'partial interface Foo' can be in FooBar.idl).
+            number_of_interfaces = len(definitions.interfaces)
+            if number_of_interfaces != 1:
+                raise Exception(
+                    'Expected exactly 1 interface in file {0}, but found {1}'
+                    .format(idl_filename, number_of_interfaces))
+            interface = next(definitions.interfaces.itervalues())
+            idl_file_basename, _ = os.path.splitext(os.path.basename(idl_filename))
+            if not interface.is_partial and interface.name != idl_file_basename:
+                raise Exception(
+                    'Interface name "{0}" disagrees with IDL file basename "{1}".'
+                    .format(interface.name, idl_file_basename))
+        else:
+            if len(definitions.interfaces) > 1:
+                print '----- Supplemental interfaces %s' % len(definitions.interfaces)
 
         # Validate extended attributes
         if not self.extended_attribute_validator:
diff --git a/core/README b/core/README
index bf749b3..e77b8dc 100644
--- a/core/README
+++ b/core/README
@@ -6,4 +6,4 @@
 
 The current version corresponds to:
 URL: http://src.chromium.org/blink/branches/dart/dartium
-Current revision: 181268
+Current revision: 181477
diff --git a/modules/README b/modules/README
index bf749b3..e77b8dc 100644
--- a/modules/README
+++ b/modules/README
@@ -6,4 +6,4 @@
 
 The current version corresponds to:
 URL: http://src.chromium.org/blink/branches/dart/dartium
-Current revision: 181268
+Current revision: 181477