Skip to content

Commit

Permalink
Share a little less code between the branches for conversion to any.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Feb 16, 2017
1 parent 7d24cd7 commit 5eaa19b
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 5eaa19b

Please sign in to comment.