aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2017-02-14 13:59:07 +0100
committerMs2ger <Ms2ger@gmail.com>2017-02-16 11:03:20 +0100
commit5eaa19bdd4ae221b2db7b547d6dfae0003511735 (patch)
tree28e579b7a58efad70e4073b8c583682c37c5ec39
parent7d24cd7752f8b4c030525612fb0fc3496d5fa169 (diff)
downloadservo-5eaa19bdd4ae221b2db7b547d6dfae0003511735.tar.gz
servo-5eaa19bdd4ae221b2db7b547d6dfae0003511735.zip
Share a little less code between the branches for conversion to any.
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index bd8232b2a75..37cab821d92 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1032,8 +1032,6 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
if type.isAny():
assert not isEnforceRange and not isClamp
- declType = ""
- default = ""
if isMember == "Dictionary":
# TODO: Need to properly root dictionaries
# https://github.com/servo/servo/issues/6381
@@ -1047,17 +1045,18 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
default = "UndefinedValue()"
else:
raise TypeError("Can't handle non-null, non-undefined default value here")
- else:
- declType = CGGeneric("HandleValue")
+ return handleOptional("${val}", declType, default)
- if defaultValue is None:
- default = None
- elif isinstance(defaultValue, IDLNullValue):
- default = "HandleValue::null()"
- elif isinstance(defaultValue, IDLUndefinedValue):
- default = "HandleValue::undefined()"
- else:
- raise TypeError("Can't handle non-null, non-undefined default value here")
+ declType = CGGeneric("HandleValue")
+
+ if defaultValue is None:
+ default = None
+ elif isinstance(defaultValue, IDLNullValue):
+ default = "HandleValue::null()"
+ elif isinstance(defaultValue, IDLUndefinedValue):
+ default = "HandleValue::undefined()"
+ else:
+ raise TypeError("Can't handle non-null, non-undefined default value here")
return handleOptional("${val}", declType, default)