mirror of
https://github.com/servo/servo.git
synced 2025-06-15 11:54: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
|
||||
|
||||
# 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue