Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Import sequence inner types if it appears in dictionary members
  • Loading branch information
KiChjang committed Nov 8, 2017
1 parent 4decea1 commit ce8486a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/script/dom/bindings/codegen/Configuration.py
Expand Up @@ -4,7 +4,7 @@

import os

from WebIDL import IDLExternalInterface, IDLWrapperType, WebIDLError
from WebIDL import IDLExternalInterface, IDLSequenceType, IDLWrapperType, WebIDLError


class Configuration:
Expand Down Expand Up @@ -457,7 +457,7 @@ def getTypesFromDictionary(dictionary):
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

Expand All @@ -473,6 +473,12 @@ def getTypesFromCallback(callback):
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
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/testbinding.rs
Expand Up @@ -390,6 +390,7 @@ impl TestBindingMethods for TestBinding {
octetValue: None,
requiredValue: true,
seqDict: None,
elementSequence: None,
shortValue: None,
stringValue: None,
type_: Some(DOMString::from("success")),
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/webidls/TestBinding.webidl
Expand Up @@ -34,6 +34,8 @@ dictionary TestDictionary {
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
Expand Down

0 comments on commit ce8486a

Please sign in to comment.