diff options
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py')
-rw-r--r-- | components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py index d7780c1ffa1..505b36468d6 100644 --- a/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py +++ b/components/script/dom/bindings/codegen/parser/tests/test_distinguishability.py @@ -3,13 +3,16 @@ def firstArgType(method): def WebIDLTest(parser, harness): parser.parse(""" + // Give our dictionary a required member so we don't need to + // mess with optional and default values. dictionary Dict { + required long member; }; callback interface Foo { }; interface Bar { // Bit of a pain to get things that have dictionary types - void passDict(optional Dict arg); + void passDict(Dict arg); void passFoo(Foo arg); void passNullableUnion((object? or DOMString) arg); void passNullable(Foo? arg); @@ -56,8 +59,6 @@ def WebIDLTest(parser, harness): void passKid(Kid arg); void passParent(Parent arg); void passGrandparent(Grandparent arg); - void passImplemented(Implemented arg); - void passImplementedParent(ImplementedParent arg); void passUnrelated1(Unrelated1 arg); void passUnrelated2(Unrelated2 arg); void passArrayBuffer(ArrayBuffer arg); @@ -67,9 +68,6 @@ def WebIDLTest(parser, harness): interface Kid : Parent {}; interface Parent : Grandparent {}; interface Grandparent {}; - interface Implemented : ImplementedParent {}; - Parent implements Implemented; - interface ImplementedParent {}; interface Unrelated1 {}; interface Unrelated2 {}; """) @@ -151,47 +149,50 @@ def WebIDLTest(parser, harness): # Now let's test our whole distinguishability table argTypes = [ "long", "short", "long?", "short?", "boolean", - "boolean?", "DOMString", "ByteString", "Enum", "Enum2", + "boolean?", "DOMString", "ByteString", "UTF8String", "Enum", "Enum2", "Interface", "Interface?", - "AncestorInterface", "UnrelatedInterface", - "ImplementedInterface", "CallbackInterface", + "AncestorInterface", "UnrelatedInterface", "CallbackInterface", "CallbackInterface?", "CallbackInterface2", - "object", "Callback", "Callback2", "optional Dict", - "optional Dict2", "sequence<long>", "sequence<short>", - "MozMap<object>", "MozMap<Dict>", "MozMap<long>", - "Date", "Date?", "any", - "Promise<any>", "Promise<any>?", - "USVString", "ArrayBuffer", "ArrayBufferView", "SharedArrayBuffer", - "Uint8Array", "Uint16Array" ] - # When we can parse Date and RegExp, we need to add them here. + "object", "Callback", "Callback2", "Dict", + "Dict2", "sequence<long>", "sequence<short>", + "record<DOMString, object>", + "record<USVString, Dict>", + "record<ByteString, long>", + "record<UTF8String, long>", + "any", "Promise<any>", "Promise<any>?", + "USVString", "JSString", "ArrayBuffer", "ArrayBufferView", + "Uint8Array", "Uint16Array", + "(long or Callback)", "(long or Dict)", + ] # Try to categorize things a bit to keep list lengths down def allBut(list1, list2): return [a for a in list1 if a not in list2 and (a != "any" and a != "Promise<any>" and a != "Promise<any>?")] + unions = [ "(long or Callback)", "(long or Dict)" ] numerics = [ "long", "short", "long?", "short?" ] booleans = [ "boolean", "boolean?" ] primitives = numerics + booleans - nonNumerics = allBut(argTypes, numerics) + nonNumerics = allBut(argTypes, numerics + unions) nonBooleans = allBut(argTypes, booleans) - strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString" ] + strings = [ "DOMString", "ByteString", "Enum", "Enum2", "USVString", "JSString", "UTF8String" ] nonStrings = allBut(argTypes, strings) nonObjects = primitives + strings objects = allBut(argTypes, nonObjects ) bufferSourceTypes = ["ArrayBuffer", "ArrayBufferView", "Uint8Array", "Uint16Array"] - sharedBufferSourceTypes = ["SharedArrayBuffer"] interfaces = [ "Interface", "Interface?", "AncestorInterface", - "UnrelatedInterface", "ImplementedInterface" ] + bufferSourceTypes + sharedBufferSourceTypes - nullables = ["long?", "short?", "boolean?", "Interface?", - "CallbackInterface?", "optional Dict", "optional Dict2", - "Date?", "any", "Promise<any>?"] - dates = [ "Date", "Date?" ] + "UnrelatedInterface" ] + bufferSourceTypes + nullables = (["long?", "short?", "boolean?", "Interface?", + "CallbackInterface?", "Dict", "Dict2", + "Date?", "any", "Promise<any>?"] + + allBut(unions, [ "(long or Callback)" ])) sequences = [ "sequence<long>", "sequence<short>" ] - nonUserObjects = nonObjects + interfaces + dates + sequences + nonUserObjects = nonObjects + interfaces + sequences otherObjects = allBut(argTypes, nonUserObjects + ["object"]) notRelatedInterfaces = (nonObjects + ["UnrelatedInterface"] + - otherObjects + dates + sequences + bufferSourceTypes + sharedBufferSourceTypes) - mozMaps = [ "MozMap<object>", "MozMap<Dict>", "MozMap<long>" ] + otherObjects + sequences + bufferSourceTypes) + records = [ "record<DOMString, object>", "record<USVString, Dict>", + "record<ByteString, long>", "record<UTF8String, long>" ] # JSString not supported in records # Build a representation of the distinguishability table as a dict # of dicts, holding True values where needed, holes elsewhere. @@ -210,7 +211,9 @@ def WebIDLTest(parser, harness): setDistinguishable("boolean?", allBut(nonBooleans, nullables)) setDistinguishable("DOMString", nonStrings) setDistinguishable("ByteString", nonStrings) + setDistinguishable("UTF8String", nonStrings) setDistinguishable("USVString", nonStrings) + setDistinguishable("JSString", nonStrings) setDistinguishable("Enum", nonStrings) setDistinguishable("Enum2", nonStrings) setDistinguishable("Interface", notRelatedInterfaces) @@ -218,24 +221,23 @@ def WebIDLTest(parser, harness): setDistinguishable("AncestorInterface", notRelatedInterfaces) setDistinguishable("UnrelatedInterface", allBut(argTypes, ["object", "UnrelatedInterface"])) - setDistinguishable("ImplementedInterface", notRelatedInterfaces) setDistinguishable("CallbackInterface", nonUserObjects) setDistinguishable("CallbackInterface?", allBut(nonUserObjects, nullables)) setDistinguishable("CallbackInterface2", nonUserObjects) setDistinguishable("object", nonObjects) setDistinguishable("Callback", nonUserObjects) setDistinguishable("Callback2", nonUserObjects) - setDistinguishable("optional Dict", allBut(nonUserObjects, nullables)) - setDistinguishable("optional Dict2", allBut(nonUserObjects, nullables)) + setDistinguishable("Dict", allBut(nonUserObjects, nullables)) + setDistinguishable("Dict2", allBut(nonUserObjects, nullables)) setDistinguishable("sequence<long>", allBut(argTypes, sequences + ["object"])) setDistinguishable("sequence<short>", allBut(argTypes, sequences + ["object"])) - setDistinguishable("MozMap<object>", nonUserObjects) - setDistinguishable("MozMap<Dict>", nonUserObjects) - setDistinguishable("MozMap<long>", nonUserObjects) - setDistinguishable("Date", allBut(argTypes, dates + ["object"])) - setDistinguishable("Date?", allBut(argTypes, dates + nullables + ["object"])) + setDistinguishable("record<DOMString, object>", nonUserObjects) + setDistinguishable("record<USVString, Dict>", nonUserObjects) + # JSString not supported in records + setDistinguishable("record<ByteString, long>", nonUserObjects) + setDistinguishable("record<UTF8String, long>", nonUserObjects) setDistinguishable("any", []) setDistinguishable("Promise<any>", []) setDistinguishable("Promise<any>?", []) @@ -243,7 +245,10 @@ def WebIDLTest(parser, harness): setDistinguishable("ArrayBufferView", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "Uint16Array", "object"])) setDistinguishable("Uint8Array", allBut(argTypes, ["ArrayBufferView", "Uint8Array", "object"])) setDistinguishable("Uint16Array", allBut(argTypes, ["ArrayBufferView", "Uint16Array", "object"])) - setDistinguishable("SharedArrayBuffer", allBut(argTypes, ["SharedArrayBuffer", "object"])) + setDistinguishable("(long or Callback)", + allBut(nonUserObjects, numerics)) + setDistinguishable("(long or Dict)", + allBut(nonUserObjects, numerics + nullables)) def areDistinguishable(type1, type2): return data[type1].get(type2, False) @@ -255,15 +260,14 @@ def WebIDLTest(parser, harness): interface Interface : AncestorInterface {}; interface AncestorInterface {}; interface UnrelatedInterface {}; - interface ImplementedInterface {}; - Interface implements ImplementedInterface; callback interface CallbackInterface {}; callback interface CallbackInterface2 {}; callback Callback = any(); callback Callback2 = long(short arg); - dictionary Dict {}; - dictionary Dict2 {}; - interface _Promise {}; + // Give our dictionaries required members so we don't need to + // mess with optional and default values. + dictionary Dict { required long member; }; + dictionary Dict2 { required long member; }; interface TestInterface {%s }; """ |