aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-04-16 14:33:13 +0200
committerMs2ger <ms2ger@gmail.com>2014-04-24 22:21:23 +0200
commitab1b429aefce97474b6bb40567b653ec6ec70b54 (patch)
tree31c9df42283e87b846890c2bac4196c28608d348 /src/components/script/dom/bindings
parentb19376735014562144a20dfab8ccf6c75aafeda1 (diff)
downloadservo-ab1b429aefce97474b6bb40567b653ec6ec70b54.tar.gz
servo-ab1b429aefce97474b6bb40567b653ec6ec70b54.zip
Move assignments outside match expressions in getJSToNativeConversionTemplate.
This is a first step towards making getJSToNativeConversionTemplate return an expression, which will improve dictionary codegen in particular.
Diffstat (limited to 'src/components/script/dom/bindings')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index cba5bd0b333..320224c3fab 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -104,12 +104,12 @@ class CastableObjectUnwrapper():
def __str__(self):
return string.Template(
-"""match unwrap_jsmanaged(${source}, ${prototype}, ${depth}) {
- Ok(val) => ${target} = ${unwrapped_val},
+"""${target} = match unwrap_jsmanaged(${source}, ${prototype}, ${depth}) {
+ Ok(val) => ${unwrapped_val},
Err(()) => {
${codeOnFailure}
}
-}
+};
""").substitute(self.substitution)
#"""{
@@ -586,10 +586,10 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
declType = CGWrapper(declType, pre="Option<", post=" >")
value = CGWrapper(value, pre="Some(", post=")")
- templateBody = CGGeneric("match %s::from_value(cx, ${val}) {\n"
+ templateBody = CGGeneric("${declName} = match %s::from_value(cx, ${val}) {\n"
" Err(()) => { %s },\n"
- " Ok(value) => ${declName} = %s,\n"
- "}" % (type.name, exceptionCode, value.define()))
+ " Ok(value) => %s,\n"
+ "};" % (type.name, exceptionCode, value.define()))
if type.nullable():
templateBody = CGIfElseWrapper(
@@ -668,10 +668,10 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
strval = "Some(%s)" % strval
conversionCode = (
- "match FromJSValConvertible::from_jsval(cx, ${val}, %s) {\n"
- " Ok(strval) => ${declName} = %s,\n"
+ "${declName} = match FromJSValConvertible::from_jsval(cx, ${val}, %s) {\n"
+ " Ok(strval) => %s,\n"
" Err(_) => { %s },\n"
- "}" % (nullBehavior, strval, exceptionCode))
+ "};" % (nullBehavior, strval, exceptionCode))
if defaultValue is None:
return conversionCode
@@ -837,10 +837,10 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
#XXXjdm support conversionBehavior here
template = (
- "match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
- " Ok(v) => ${declName} = %s,\n"
+ "${declName} = match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
+ " Ok(v) => %s,\n"
" Err(_) => { %s }\n"
- "}" % (value, exceptionCode))
+ "};" % (value, exceptionCode))
if defaultValue is not None:
if isinstance(defaultValue, IDLNullValue):