aboutsummaryrefslogtreecommitdiffstats
path: root/components/jstraceable_derive/lib.rs
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2023-08-10 23:46:06 +0200
committerGitHub <noreply@github.com>2023-08-10 21:46:06 +0000
commit450f8193a567ac6e5acd84e89fe73ed7ce137a78 (patch)
tree1c8418988d54fc4122d14218275927a523058413 /components/jstraceable_derive/lib.rs
parent1f7f4cf2bedd1819ae129c2ac327425a756b5299 (diff)
downloadservo-450f8193a567ac6e5acd84e89fe73ed7ce137a78.tar.gz
servo-450f8193a567ac6e5acd84e89fe73ed7ce137a78.zip
Use mozjs tracing infrastructure (#29918)
* Update mozjs https://github.com/servo/mozjs/commit/64711ec2e6dc4595df691bffc7f1e5052ab86c8d also fixes https://github.com/servo/servo/issues/30043 * Move to mozjs Traceable and introduce CustomTraceable
Diffstat (limited to 'components/jstraceable_derive/lib.rs')
-rw-r--r--components/jstraceable_derive/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/components/jstraceable_derive/lib.rs b/components/jstraceable_derive/lib.rs
index 669a71842d3..2e90f967970 100644
--- a/components/jstraceable_derive/lib.rs
+++ b/components/jstraceable_derive/lib.rs
@@ -7,7 +7,7 @@ extern crate syn;
#[macro_use]
extern crate synstructure;
-decl_derive!([JSTraceable, attributes(no_trace)] =>
+decl_derive!([JSTraceable, attributes(no_trace, custom_trace)] =>
/// Implements `JSTraceable` on structs and enums
///
/// Example:
@@ -17,6 +17,8 @@ decl_derive!([JSTraceable, attributes(no_trace)] =>
/// js_managed: JSManagedType,
/// #[no_trace]
/// non_js: NonJSManagedType,
+/// #[custom_trace] // Extern type implements CustomTraceable that is in servo => no problem with orphan rules
+/// extern_managed_type: Extern<JSManagedType>,
/// }
/// ```
///
@@ -30,6 +32,7 @@ decl_derive!([JSTraceable, attributes(no_trace)] =>
/// S {
/// js_managed: ref __binding_0,
/// non_js: ref __binding_1,
+/// extern_managed_type: ref __binding_2,
/// } => {
/// {
/// __binding_0.trace(tracer);
@@ -37,6 +40,9 @@ decl_derive!([JSTraceable, attributes(no_trace)] =>
/// {
/// // __binding_1 is not traceable so we do not need to trace it
/// }
+/// {
+/// <crate::dom::bindings::trace::CustomTraceable>::trace(__binding_2, tracer);
+/// }
/// },
/// }
/// }
@@ -150,9 +156,12 @@ fn js_traceable_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
if path.is_ident("no_trace") {
asserts.extend(assert_not_impl_traceable(&binding.ast().ty));
return None;
+ } else if path.is_ident("custom_trace") {
+ return Some(quote!(<crate::dom::bindings::trace::CustomTraceable>::trace(#binding, tracer);));
}
},
syn::Meta::NameValue(syn::MetaNameValue { ref path, .. }) => {
+ // if reason provided we can skip JSTraceable check
if path.is_ident("no_trace") {
return None;
}