aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-03-06 22:52:57 +0100
committerMs2ger <ms2ger@gmail.com>2014-03-06 22:52:57 +0100
commit922d191948702509eb026edf8e86f853f9d004c2 (patch)
treeb22c90612f0ebe426ba745f84ba8a13ee6273523 /src/components/script/dom/bindings/codegen
parent54a59b9d38b4cb9b58417039e4be145c15074a8d (diff)
downloadservo-922d191948702509eb026edf8e86f853f9d004c2.tar.gz
servo-922d191948702509eb026edf8e86f853f9d004c2.zip
Common up some code in the conversion to nullable and non-nullable primitive types.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index bbdd6b9420e..b08a209a879 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1238,17 +1238,17 @@ for (uint32_t i = 0; i < length; ++i) {
if failureCode is None:
failureCode = 'return 0'
- if type.nullable():
- successVal = "v"
- if preSuccess or postSuccess:
- successVal = preSuccess + successVal + postSuccess
- #XXXjdm support conversionBehavior here
- template = (
- "match JSValConvertible::from_jsval(cx, ${val}) {\n"
- " Ok(v) => ${declName} = %s,\n"
- " Err(_) => %s\n"
- "}" % (successVal, failureCode))
+ successVal = "v"
+ if preSuccess or postSuccess:
+ successVal = preSuccess + successVal + postSuccess
+ #XXXjdm support conversionBehavior here
+ template = (
+ "match JSValConvertible::from_jsval(cx, ${val}) {\n"
+ " Ok(v) => ${declName} = %s,\n"
+ " Err(_) => %s\n"
+ "}" % (successVal, failureCode))
+ if type.nullable():
if defaultValue is not None and isinstance(defaultValue, IDLNullValue):
template = CGWrapper(CGIndenter(CGGeneric(template)),
pre="if ${haveValue} {\n",
@@ -1261,16 +1261,8 @@ for (uint32_t i = 0; i < length; ++i) {
else:
assert(defaultValue is None or
not isinstance(defaultValue, IDLNullValue))
- #XXXjdm conversionBehavior should be used
- successVal = "v"
- if preSuccess or postSuccess:
- successVal = preSuccess + successVal + postSuccess
- template = (
- "match JSValConvertible::from_jsval(cx, ${val}) {\n"
- " Err(_) => %s,\n"
- " Ok(v) => ${declName} = %s\n"
- "}" % (failureCode, successVal))
declType = CGGeneric(typeName)
+
if (defaultValue is not None and
# We already handled IDLNullValue, so just deal with the other ones
not isinstance(defaultValue, IDLNullValue)):