Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use RootedTraceableBox for unions.
  • Loading branch information
Ms2ger committed Feb 16, 2017
1 parent 0cc6d3e commit d5f8b35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -722,6 +722,9 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,
if type.nullable():
declType = CGWrapper(declType, pre="Option<", post=" >")

if isMember != "Dictionary" and type_needs_tracing(type):
declType = CGTemplatedType("RootedTraceableBox", declType)

templateBody = ("match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
" Ok(ConversionResult::Success(value)) => value,\n"
" Ok(ConversionResult::Failure(error)) => {\n"
Expand Down Expand Up @@ -6190,6 +6193,9 @@ def type_needs_tracing(t):
if t.isSequence():
return type_needs_tracing(t.inner)

if t.isUnion():
return any(type_needs_tracing(member) for member in t.flatMemberTypes)

return False

if t.isDictionary():
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/testbinding.rs
Expand Up @@ -435,7 +435,7 @@ impl TestBindingMethods for TestBinding {
fn PassUnion6(&self, _: UnsignedLongOrBoolean) {}
fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {}
fn PassUnion8(&self, _: ByteStringSequenceOrLong) {}
fn PassUnion9(&self, _: UnionTypes::TestDictionaryOrLong) {}
fn PassUnion9(&self, _: RootedTraceableBox<UnionTypes::TestDictionaryOrLong>) {}
fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {}
fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
#[allow(unsafe_code)]
Expand Down

0 comments on commit d5f8b35

Please sign in to comment.