From 4fa12841e77c7f227ede71cd9636c6e597ece1dd Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 7 Mar 2014 11:21:00 +0100 Subject: [PATCH] Don't initialize nullable interface arguments to None in codegen. This allows Rust to check that we've actually initialized all cases. --- .../dom/bindings/codegen/CodegenRust.py | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index bbdd6b9420e..5aa4d7a8354 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -918,21 +918,6 @@ for (uint32_t i = 0; i < length; ++i) { typePtr = descriptor.nativeType - # Compute a few things: - # - declType is the type we want to return as the first element of our - # tuple. - # - holderType is the type we want to return as the third element - # of our tuple. - - # Set up some sensible defaults for these things insofar as we can. - holderType = None - initialValue = None - if argIsPointer or isOptional: - declType = "Option<" + typePtr + ">" - initialValue = "None" - else: - declType = typePtr - templateBody = "" if descriptor.castable: if descriptor.interface.isConsequential(): @@ -969,10 +954,11 @@ for (uint32_t i = 0; i < length; ++i) { type, "${declName} = None", failureCode) - declType = CGGeneric(declType) - if holderType is not None: - holderType = CGGeneric(holderType) - return (templateBody, declType, holderType, isOptional, initialValue) + declType = CGGeneric(typePtr) + if argIsPointer or isOptional: + declType = CGWrapper(declType, pre="Option<", post=">") + + return (templateBody, declType, None, isOptional, "None" if isOptional else None) if type.isSpiderMonkeyInterface(): assert not isEnforceRange and not isClamp