From 2a5119ff372d306d1385f8061d817f7a3b1cdc7d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 10 Apr 2015 14:11:26 +0200 Subject: Add rt and cx methods to Runtime. --- components/script/script_task.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 7398f375a31..e1996bbdedf 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -280,6 +280,16 @@ impl Runtime { cx: js_context, } } + + /// Returns the `JSRuntime` object. + pub fn rt(&self) -> *mut JSRuntime { + self.rt.ptr + } + + /// Returns the `JSContext` object. + pub fn cx(&self) -> *mut JSContext { + self.cx.ptr + } } /// Information for an entire page. Pages are top-level browsing contexts and can contain multiple @@ -500,21 +510,21 @@ impl ScriptTask { pub fn new_rt_and_cx() -> (js::rust::rt, Rc) { LiveDOMReferences::initialize(); - let Runtime { rt: js_runtime, cx: js_context } = Runtime::new(); + let runtime = Runtime::new(); unsafe { - JS_SetExtraGCRootsTracer((*js_runtime).ptr, Some(trace_rust_roots), ptr::null_mut()); + JS_SetExtraGCRootsTracer(runtime.rt(), Some(trace_rust_roots), ptr::null_mut()); } // Needed for debug assertions about whether GC is running. if !cfg!(ndebug) { unsafe { - JS_SetGCCallback(js_runtime.ptr, + JS_SetGCCallback(runtime.rt(), Some(debug_gc_callback as unsafe extern "C" fn(*mut JSRuntime, JSGCStatus))); } } - (js_runtime, js_context) + (runtime.rt, runtime.cx) } // Return the root page in the frame tree. Panics if it doesn't exist. -- cgit v1.2.3