From e742af10aa67dc90a68fcb60b8e70733fd753e68 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sun, 7 Oct 2018 23:48:06 +0200 Subject: Abide by the rules when passing Isolate between c and rust Ensure that at most one mutable Isolate reference exists at a time. `deno_execute()` and `deno_respond()` now borrow a reference to the rust-side isolate from the caller. When we need a reference to the isolate while one of these functions is on the stack, `deno_get_data()` can be used to borrow back that reference. --- src/libdeno.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/libdeno.rs') diff --git a/src/libdeno.rs b/src/libdeno.rs index b48ddd166..77f7f5c3e 100644 --- a/src/libdeno.rs +++ b/src/libdeno.rs @@ -30,13 +30,19 @@ extern "C" { pub fn deno_init(); pub fn deno_v8_version() -> *const c_char; pub fn deno_set_v8_flags(argc: *mut c_int, argv: *mut *mut c_char); - pub fn deno_new(user_data: *mut c_void, cb: DenoRecvCb) -> *const isolate; + pub fn deno_new(cb: DenoRecvCb) -> *const isolate; pub fn deno_delete(i: *const isolate); pub fn deno_last_exception(i: *const isolate) -> *const c_char; pub fn deno_get_data(i: *const isolate) -> *mut c_void; - pub fn deno_respond(i: *const isolate, req_id: i32, buf: deno_buf); + pub fn deno_respond( + i: *const isolate, + user_data: *mut c_void, + req_id: i32, + buf: deno_buf, + ); pub fn deno_execute( i: *const isolate, + user_data: *mut c_void, js_filename: *const c_char, js_source: *const c_char, ) -> c_int; -- cgit v1.2.3