Skip to content

Commit

Permalink
dom: Improve precision of sequence types for WebIDL codegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed May 29, 2020
1 parent 70c43b7 commit c4f8167
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -677,7 +677,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
if type.isSequence() or type.isRecord():
innerInfo = getJSToNativeConversionInfo(innerContainerType(type),
descriptorProvider,
isMember=isMember,
isMember="Sequence",
isAutoRooted=isAutoRooted)
declType = wrapInNativeContainerType(type, innerInfo.declType)
config = getConversionConfigForType(type, isEnforceRange, isClamp, treatNullAs)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
assert not isEnforceRange and not isClamp
assert isMember != "Union"

if isMember == "Dictionary" or isAutoRooted:
if isMember in ("Dictionary", "Sequence") or isAutoRooted:
templateBody = "${val}.get()"

if defaultValue is None:
Expand All @@ -1087,7 +1087,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
else:
raise TypeError("Can't handle non-null, non-undefined default value here")

if isMember == "Dictionary":
if not isAutoRooted:
templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody
if default is not None:
default = "RootedTraceableBox::from_box(Heap::boxed(%s))" % default
Expand Down Expand Up @@ -1117,7 +1117,7 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
templateBody = "${val}.get().to_object()"
default = "ptr::null_mut()"

if isMember in ("Dictionary", "Union"):
if isMember in ("Dictionary", "Union", "Sequence") and not isAutoRooted:
templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody
default = "RootedTraceableBox::new(Heap::default())"
declType = CGGeneric("RootedTraceableBox<Heap<*mut JSObject>>")
Expand Down

0 comments on commit c4f8167

Please sign in to comment.