mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
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:
parent
134d1f6fe3
commit
4fa12841e7
1 changed files with 5 additions and 19 deletions
|
@ -918,21 +918,6 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
|
|
||||||
typePtr = descriptor.nativeType
|
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 = ""
|
templateBody = ""
|
||||||
if descriptor.castable:
|
if descriptor.castable:
|
||||||
if descriptor.interface.isConsequential():
|
if descriptor.interface.isConsequential():
|
||||||
|
@ -969,10 +954,11 @@ for (uint32_t i = 0; i < length; ++i) {
|
||||||
type, "${declName} = None",
|
type, "${declName} = None",
|
||||||
failureCode)
|
failureCode)
|
||||||
|
|
||||||
declType = CGGeneric(declType)
|
declType = CGGeneric(typePtr)
|
||||||
if holderType is not None:
|
if argIsPointer or isOptional:
|
||||||
holderType = CGGeneric(holderType)
|
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||||
return (templateBody, declType, holderType, isOptional, initialValue)
|
|
||||||
|
return (templateBody, declType, None, isOptional, "None" if isOptional else None)
|
||||||
|
|
||||||
if type.isSpiderMonkeyInterface():
|
if type.isSpiderMonkeyInterface():
|
||||||
assert not isEnforceRange and not isClamp
|
assert not isEnforceRange and not isClamp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue