servo: Merge #19148 - Import sequence inner types if it appears in dictionary members (from KiChjang:import-sequence-inner-types); r=jdm
authorKeith Yeung <kungfukeith11@gmail.com>
Wed, 08 Nov 2017 06:22:16 -0600
changeset 444044 6169e97b09d2a501640290f9d4b5b6c7e7d41641
parent 444043 4cd32018fcd24a0f04519683ded252eb6fc221ce
child 444045 2623a4e8fa60ae45f9ca25855d3e2a04c14f7944
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
bugs19148, 19133, 19143
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 #19148 - Import sequence inner types if it appears in dictionary members (from KiChjang:import-sequence-inner-types); r=jdm Relands #19133, as it was backed out wrongly in #19143. Source-Repo: https://github.com/servo/servo Source-Revision: a1f733722167124eb1a63e235101a1dc40ac2aa0
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):
+    while isinstance(type, IDLSequenceType):
+        type = 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;
 };