Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanup. #145

Merged
merged 3 commits into from May 9, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Inline JSRuntime creation into Runtime::new().

There is no reason for any consumer to call these functions manually.
  • Loading branch information
Ms2ger committed May 9, 2015
commit f15755479ecb1e83fc1491ad808147d001ad5350
@@ -34,10 +34,11 @@ pub struct Runtime {
impl Runtime {
/// Creates a new `JSRuntime` and `JSContext`.
pub fn new() -> Runtime {
let js_runtime = rt();
assert!({
let ptr: *mut JSRuntime = (*js_runtime).ptr;
!ptr.is_null()
let js_runtime = unsafe { JS_Init(default_heapsize) };
assert!(!js_runtime.is_null());

let js_runtime = rc::Rc::new(rt_rsrc {
ptr: js_runtime
});

// Unconstrain the runtime's threshold on nominal heap size, to avoid
@@ -95,19 +96,6 @@ impl Drop for rt_rsrc {
}
}

pub fn new_runtime(p: *mut JSRuntime) -> rt {
return rc::Rc::new(rt_rsrc {
ptr: p
})
}

pub fn rt() -> rt {
unsafe {
let runtime = JS_Init(default_heapsize);
return new_runtime(runtime);
}
}

// ___________________________________________________________________________
// contexts

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.