Skip to content
Permalink
Browse files

Share a little less code between the branches for conversion to any.

  • Loading branch information
Ms2ger committed Feb 16, 2017
1 parent 7d24cd7 commit 5eaa19bdd4ae221b2db7b547d6dfae0003511735
Showing with 11 additions and 12 deletions.
  1. +11 −12 components/script/dom/bindings/codegen/CodegenRust.py
@@ -1032,8 +1032,6 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
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 wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
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)

0 comments on commit 5eaa19b

Please sign in to comment.
You can’t perform that action at this time.