servo: Merge #19133 - Import sequence inner types if it appears in dictionary members (from KiChjang:import-sequence-inner-types); r=jdm
☠☠ backed out by b72eaedcdfaa ☠ ☠
authorKeith Yeung <kungfukeith11@gmail.com>
Tue, 07 Nov 2017 17:07:03 -0600
changeset 443907 dd834d38eaabe22f056d3eb37304f43f37edeb35
parent 443906 f47cb574c96e39ecda7bdcdac10ed97afb651f02
child 443908 076a93ecab1087287245d658d3d227c2ff6fcabf
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #19133 - Import sequence inner types if it appears in dictionary members (from KiChjang:import-sequence-inner-types); r=jdm Fixes #19107. r? nox Source-Repo: https://github.com/servo/servo Source-Revision: 7ae852b6731f7405a101e01881c7fa70cfb83826
servo/components/script/dom/bindings/codegen/Configuration.py
servo/components/script/dom/testbinding.rs
servo/components/script/dom/webidls/TestBinding.webidl
--- a/servo/components/script/dom/bindings/codegen/Configuration.py
+++ b/servo/components/script/dom/bindings/codegen/Configuration.py
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 
-from WebIDL import IDLExternalInterface, IDLWrapperType, WebIDLError
+from WebIDL import IDLExternalInterface, IDLSequenceType, IDLWrapperType, WebIDLError
 
 
 class Configuration:
     """
     Represents global configuration state based on IDL parse data and
     the configuration file.
     """
     def __init__(self, filename, parseData):
@@ -452,29 +452,35 @@ def getTypesFromDictionary(dictionary):
     """
     Get all member types for this dictionary
     """
     if isinstance(dictionary, IDLWrapperType):
         dictionary = dictionary.inner
     types = []
     curDict = dictionary
     while curDict:
-        types.extend([m.type for m in curDict.members])
+        types.extend([getUnwrappedType(m.type) for m in curDict.members])
         curDict = curDict.parent
     return types
 
 
 def getTypesFromCallback(callback):
     """
     Get the types this callback depends on: its return type and the
     types of its arguments.
     """
     sig = callback.signatures()[0]
     types = [sig[0]]  # Return type
     types.extend(arg.type for arg in sig[1])  # Arguments
     return types
 
 
+def getUnwrappedType(type):
+    if isinstance(type, IDLSequenceType):
+        return type.inner
+    return type
+
+
 def iteratorNativeType(descriptor, infer=False):
     assert descriptor.interface.isIterable()
     iterableDecl = descriptor.interface.maplikeOrSetlikeOrIterable
     assert iterableDecl.isPairIterator()
     return "IterableIterator%s" % ("" if infer else '<%s>' % descriptor.interface.identifier.name)
--- a/servo/components/script/dom/testbinding.rs
+++ b/servo/components/script/dom/testbinding.rs
@@ -385,16 +385,17 @@ impl TestBindingMethods for TestBinding 
             floatValue: None,
             interfaceValue: None,
             longLongValue: None,
             longValue: None,
             objectValue: None,
             octetValue: None,
             requiredValue: true,
             seqDict: None,
+            elementSequence: None,
             shortValue: None,
             stringValue: None,
             type_: Some(DOMString::from("success")),
             unrestrictedDoubleValue: None,
             unrestrictedFloatValue: None,
             unsignedLongLongValue: None,
             unsignedLongValue: None,
             unsignedShortValue: None,
--- a/servo/components/script/dom/webidls/TestBinding.webidl
+++ b/servo/components/script/dom/webidls/TestBinding.webidl
@@ -29,16 +29,18 @@ dictionary TestDictionary {
   DOMString stringValue;
   USVString usvstringValue;
   TestEnum enumValue;
   Blob interfaceValue;
   any anyValue;
   object objectValue;
   TestDictionaryDefaults dict;
   sequence<TestDictionaryDefaults> seqDict;
+  // Testing codegen to import Element correctly, ensure no other code references Element directly
+  sequence<Element> elementSequence;
   // Reserved rust keyword
   DOMString type;
   // These are used to test bidirectional conversion
   // and differentiation of non-required and nullable types
   // in dictionaries.
   DOMString? nonRequiredNullable;
   DOMString? nonRequiredNullable2;
 };