aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-02-19 05:56:01 -0800
committerGitHub <noreply@github.com>2017-02-19 05:56:01 -0800
commit28698dc8ba0501d3c7783e46ad3201cab5730d0b (patch)
treee181761551444fb4af4e0b655376758c1ceb4524
parentd2ae3d8bedf99c97877ec944d94f2aa72e67478d (diff)
parentfb8eb1db650e0902ee6909b4142c0e942a12943d (diff)
downloadservo-28698dc8ba0501d3c7783e46ad3201cab5730d0b.tar.gz
servo-28698dc8ba0501d3c7783e46ad3201cab5730d0b.zip
Auto merge of #15589 - servo:RootedTraceable-union, r=nox
Use RootedTraceableBox for unions. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15589) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py6
-rw-r--r--components/script/dom/testbinding.rs4
-rw-r--r--components/script/dom/webidls/TestBinding.webidl1
3 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index b184cce76b2..73dfb4294f1 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -722,6 +722,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
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"
@@ -6196,6 +6199,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():
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index 1582647ca33..d9defc53770 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -435,7 +435,9 @@ 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>) {}
+ #[allow(unsafe_code)]
+ unsafe fn PassUnion10(&self, _: *mut JSContext, _: RootedTraceableBox<UnionTypes::StringOrObject>) {}
fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {}
fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
#[allow(unsafe_code)]
diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl
index fc6d4771366..74216947917 100644
--- a/components/script/dom/webidls/TestBinding.webidl
+++ b/components/script/dom/webidls/TestBinding.webidl
@@ -246,6 +246,7 @@ interface TestBinding {
void passUnion7((sequence<DOMString> or unsigned long) arg);
void passUnion8((sequence<ByteString> or long) arg);
void passUnion9((TestDictionary or long) arg);
+ void passUnion10((DOMString or object) arg);
void passUnionWithTypedef((Document or TestTypedef) arg);
void passUnionWithTypedef2((sequence<long> or TestTypedef) arg);
void passAny(any arg);