From 35bc171a05ea430b3c6bb6887e5135a6dd9908d1 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 8 Feb 2017 12:18:24 +0100 Subject: [PATCH] Support using typedefs with nullable unions. --- components/script/dom/bindings/codegen/CodegenRust.py | 3 ++- components/script/dom/webidls/TestBinding.webidl | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 79479363acd..e5c3761edfe 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -6122,7 +6122,8 @@ class CGBindingRoot(CGThing): # Do codegen for all the typdefs for t in typedefs: - if t.innerType.isUnion(): + if t.innerType.isUnion() and not t.innerType.nullable(): + # Allow using the typedef's name for accessing variants. cgthings.extend([CGGeneric("\npub use dom::bindings::codegen::UnionTypes::%s as %s;\n\n" % (t.innerType, t.identifier.name))]) else: diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 6920ded6301..59d4fb35466 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -7,6 +7,7 @@ enum TestEnum { "", "foo", "bar" }; typedef (DOMString or URL or Blob) TestTypedef; +typedef (DOMString or URL or Blob)? TestTypedefNullableUnion; dictionary TestDictionary { required boolean requiredValue;