Skip to content

Commit

Permalink
Root JS object members in dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Mar 16, 2018
1 parent b49acf4 commit 760e0a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -1121,13 +1121,10 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
templateBody = "${val}.get().to_object()"
default = "ptr::null_mut()"

# TODO: Do we need to do the same for dictionaries?
if isMember == "Union":
if isMember in ("Dictionary", "Union"):
templateBody = "RootedTraceableBox::from_box(Heap::boxed(%s))" % templateBody
default = "RootedTraceableBox::new(Heap::default())"
declType = CGGeneric("RootedTraceableBox<Heap<*mut JSObject>>")
elif isMember == "Dictionary":
declType = CGGeneric("Heap<*mut JSObject>")
else:
# TODO: Need to root somehow
# https://github.com/servo/servo/issues/6382
Expand Down Expand Up @@ -6168,7 +6165,8 @@ def memberInit(memberInfo, isInitial):
conversion = self.getMemberConversion(memberInfo, member.type)
if isInitial:
return CGGeneric("%s: %s,\n" % (name, conversion.define()))
if member.type.isAny() or member.type.isObject():
# TODO: Root Heap<JSVal> using RootedTraceableBox
if member.type.isAny():
return CGGeneric("dictionary.%s.set(%s);\n" % (name, conversion.define()))
return CGGeneric("dictionary.%s = %s;\n" % (name, conversion.define()))

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/testbinding.rs
Expand Up @@ -369,7 +369,7 @@ impl TestBindingMethods for TestBinding {
nullableFloatValue: None,
nullableLongLongValue: None,
nullableLongValue: None,
nullableObjectValue: Heap::default(),
nullableObjectValue: RootedTraceableBox::new(Heap::default()),
nullableOctetValue: None,
nullableShortValue: None,
nullableStringValue: None,
Expand Down

0 comments on commit 760e0a5

Please sign in to comment.