Navigation Menu

Skip to content

Commit

Permalink
Add safe handle function for rooted heap values
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Mar 23, 2018
1 parent 8aa2ebe commit ed0091f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/script/dom/bindings/trace.rs
Expand Up @@ -59,9 +59,9 @@ use hyper::mime::Mime;
use hyper::status::StatusCode;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use js::glue::{CallObjectTracer, CallValueTracer};
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
use js::jsapi::{GCTraceKindToAscii, Heap, Handle, JSObject, JSTracer, TraceKind};
use js::jsval::JSVal;
use js::rust::Runtime;
use js::rust::{GCMethods, Runtime};
use js::typedarray::TypedArray;
use js::typedarray::TypedArrayElement;
use metrics::{InteractiveMetrics, InteractiveWindow};
Expand Down Expand Up @@ -788,6 +788,16 @@ impl<T: JSTraceable + 'static> RootedTraceableBox<T> {
}
}

impl<T> RootedTraceableBox<Heap<T>>
where
Heap<T>: JSTraceable + 'static,
T: GCMethods + Copy,
{
pub fn handle(&self) -> Handle<T> {
unsafe { (*self.ptr).handle() }
}
}

impl<T: JSTraceable + Default> Default for RootedTraceableBox<T> {
fn default() -> RootedTraceableBox<T> {
RootedTraceableBox::new(T::default())
Expand Down

0 comments on commit ed0091f

Please sign in to comment.