diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-04-10 14:11:26 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-04-10 14:53:22 +0200 |
commit | 2a5119ff372d306d1385f8061d817f7a3b1cdc7d (patch) | |
tree | 09e0a45758f0ec023989acce84a79b866757d756 /components/script/script_task.rs | |
parent | 24ef5baf66d3a904cb400507c6baa975f9f23971 (diff) | |
download | servo-2a5119ff372d306d1385f8061d817f7a3b1cdc7d.tar.gz servo-2a5119ff372d306d1385f8061d817f7a3b1cdc7d.zip |
Add rt and cx methods to Runtime.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 18 |
1 files changed, 14 insertions, 4 deletions
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<Cx>) { 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. |