Don't initialize nullable interface arguments to None in codegen.

This allows Rust to check that we've actually initialized all cases.
This commit is contained in:
Ms2ger 2014-03-07 11:21:00 +01:00
parent 134d1f6fe3
commit 4fa12841e7

View file

@ -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