From 3fa148f89a4ee78fbc27fe4a5ef2901257c5107c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 19 Dec 2013 23:30:38 -0500 Subject: [PATCH] Bug 952073. Fix codegen to actually work correctly for the case of a nullable union dictionary member with no default value. r=dzbarsky This fix just makes us take the normal Optional codepath for this case, since there is no weirdness here. --- dom/bindings/Codegen.py | 11 ++++++----- dom/bindings/test/TestCodeGen.webidl | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4814b3596c9f..f054cf05e27f 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -3299,13 +3299,14 @@ for (uint32_t i = 0; i < length; ++i) { holderType = CGTemplatedType("Maybe", holderType) # If we're isOptional and not nullable the normal optional handling will - # handle lazy construction of our holder. If we're nullable we do it - # all by hand because we do not want our holder constructed if we're - # null. + # handle lazy construction of our holder. If we're nullable and not + # isMember we do it all by hand because we do not want our holder + # constructed if we're null. But if we're isMember we don't have a + # holder anyway, so we can do the normal Optional codepath. declLoc = "${declName}" constructDecl = None if nullable: - if isOptional: + if isOptional and not isMember: holderArgs = "${declName}.Value().SetValue()" declType = CGTemplatedType("Optional", declType) constructDecl = CGGeneric("${declName}.Construct();") @@ -3374,7 +3375,7 @@ for (uint32_t i = 0; i < length; ++i) { declType=declType, holderType=holderType, holderArgs=holderArgs, - dealWithOptional=isOptional and not nullable) + dealWithOptional=isOptional and (not nullable or isMember)) if type.isGeckoInterface(): assert not isEnforceRange and not isClamp diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index b5e531fa84f4..4fafd038a31b 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -791,6 +791,7 @@ dictionary Dict : ParentDict { #ifdef DEBUG (EventInit or long) eventInitOrLong; (EventInit or long)? nullableEventInitOrLong; + (Node or long)? nullableNodeOrLong; // CustomEventInit is useful to test because it needs rooting. (CustomEventInit or long) eventInitOrLong2; (CustomEventInit or long)? nullableEventInitOrLong2;