mirror of
https://github.com/servo/servo
synced 2026-05-02 04:17:38 +02:00
Treat undefined arguments in JS as missing
This commit is contained in:
@@ -1142,7 +1142,6 @@ class CGArgumentConverter(CGThing):
|
||||
"argc": argc,
|
||||
"args": args
|
||||
}
|
||||
condition = string.Template("${index} < ${argc}").substitute(replacer)
|
||||
|
||||
replacementVariables = {
|
||||
"val": string.Template("${args}.get(${index})").substitute(replacer),
|
||||
@@ -1164,17 +1163,18 @@ class CGArgumentConverter(CGThing):
|
||||
|
||||
if not argument.variadic:
|
||||
if argument.optional:
|
||||
condition = "{args}.get({index}).is_undefined()".format(**replacer)
|
||||
if argument.defaultValue:
|
||||
assert default
|
||||
template = CGIfElseWrapper(condition,
|
||||
CGGeneric(template),
|
||||
CGGeneric(default)).define()
|
||||
CGGeneric(default),
|
||||
CGGeneric(template)).define()
|
||||
else:
|
||||
assert not default
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
template = CGIfElseWrapper(condition,
|
||||
CGGeneric("Some(%s)" % template),
|
||||
CGGeneric("None")).define()
|
||||
CGGeneric("None"),
|
||||
CGGeneric("Some(%s)" % template)).define()
|
||||
else:
|
||||
assert not default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user