Move the assignment outside the if when dealing with optional arguments.

This commit is contained in:
Ms2ger 2014-05-03 15:04:25 +02:00
parent d14efebb5c
commit aed95dfd94

View file

@ -824,6 +824,12 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
string.Template(templateBody).substitute(replacements)
)
if argcAndIndex is not None:
condition = string.Template("${index} < ${argc}").substitute(argcAndIndex)
conversion = CGIfElseWrapper(condition,
conversion,
CGGeneric("None"))
if declType is not None:
newDecl = [CGGeneric("let mut "),
CGGeneric(replacements["declName"]),
@ -835,12 +841,6 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
pre="%s = " % replacements["declName"],
post=";")
if argcAndIndex is not None:
condition = string.Template("${index} < ${argc}").substitute(argcAndIndex)
conversion = CGIfElseWrapper(condition,
conversion,
CGGeneric("%s = None" % replacements["declName"]))
result.append(conversion)
# Add an empty CGGeneric to get an extra newline after the argument
# conversion.