diff options
author | Ms2ger <ms2ger@gmail.com> | 2014-03-06 22:52:57 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2014-03-06 22:52:57 +0100 |
commit | 922d191948702509eb026edf8e86f853f9d004c2 (patch) | |
tree | b22c90612f0ebe426ba745f84ba8a13ee6273523 /src/components/script/dom/bindings/codegen | |
parent | 54a59b9d38b4cb9b58417039e4be145c15074a8d (diff) | |
download | servo-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.py | 30 |
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)): |