aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-05-03 15:04:25 +0200
committerMs2ger <ms2ger@gmail.com>2014-05-05 11:36:52 +0200
commitaed95dfd941d418faa1f816895e097fe867c2ac3 (patch)
tree5c307a5e69eec135eb3c3fd8a5054764f31874d7
parentd14efebb5c2ad4dcfa178cfc140bc54f81d93b2d (diff)
downloadservo-aed95dfd941d418faa1f816895e097fe867c2ac3.tar.gz
servo-aed95dfd941d418faa1f816895e097fe867c2ac3.zip
Move the assignment outside the if when dealing with optional arguments.
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 327fa119c9f..7bb5663b026 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -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.