mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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 -->
This commit is contained in:
commit
28698dc8ba
3 changed files with 10 additions and 1 deletions
|
@ -722,6 +722,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
declType = CGWrapper(declType, pre="Option<", post=" >")
|
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"
|
templateBody = ("match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n"
|
||||||
" Ok(ConversionResult::Success(value)) => value,\n"
|
" Ok(ConversionResult::Success(value)) => value,\n"
|
||||||
" Ok(ConversionResult::Failure(error)) => {\n"
|
" Ok(ConversionResult::Failure(error)) => {\n"
|
||||||
|
@ -6196,6 +6199,9 @@ def type_needs_tracing(t):
|
||||||
if t.isSequence():
|
if t.isSequence():
|
||||||
return type_needs_tracing(t.inner)
|
return type_needs_tracing(t.inner)
|
||||||
|
|
||||||
|
if t.isUnion():
|
||||||
|
return any(type_needs_tracing(member) for member in t.flatMemberTypes)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if t.isDictionary():
|
if t.isDictionary():
|
||||||
|
|
|
@ -435,7 +435,9 @@ impl TestBindingMethods for TestBinding {
|
||||||
fn PassUnion6(&self, _: UnsignedLongOrBoolean) {}
|
fn PassUnion6(&self, _: UnsignedLongOrBoolean) {}
|
||||||
fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {}
|
fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {}
|
||||||
fn PassUnion8(&self, _: ByteStringSequenceOrLong) {}
|
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 PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {}
|
||||||
fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
|
fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
|
@ -246,6 +246,7 @@ interface TestBinding {
|
||||||
void passUnion7((sequence<DOMString> or unsigned long) arg);
|
void passUnion7((sequence<DOMString> or unsigned long) arg);
|
||||||
void passUnion8((sequence<ByteString> or long) arg);
|
void passUnion8((sequence<ByteString> or long) arg);
|
||||||
void passUnion9((TestDictionary or long) arg);
|
void passUnion9((TestDictionary or long) arg);
|
||||||
|
void passUnion10((DOMString or object) arg);
|
||||||
void passUnionWithTypedef((Document or TestTypedef) arg);
|
void passUnionWithTypedef((Document or TestTypedef) arg);
|
||||||
void passUnionWithTypedef2((sequence<long> or TestTypedef) arg);
|
void passUnionWithTypedef2((sequence<long> or TestTypedef) arg);
|
||||||
void passAny(any arg);
|
void passAny(any arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue