Treat undefined arguments in JS as missing

This commit is contained in:
Keith Yeung 2015-12-05 23:05:46 -08:00
parent d6708a2fea
commit db92a8b030
15 changed files with 8 additions and 62 deletions

View file

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

View file

@ -878,7 +878,7 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.1"
source = "git+https://github.com/servo/rust-mozjs#6bfe259e0adc51ceabeb95d3af87d9041d16a767"
source = "git+https://github.com/servo/rust-mozjs#07523d8b3dd12276eb94a266e83c0b1d77aa4160"
dependencies = [
"heapsize 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",