mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-25 15:29:43 -05:00
Fix methods that should require '&mut Isolate' but didn't (#222)
This commit is contained in:
parent
52067dc4da
commit
00d8eb8e16
3 changed files with 38 additions and 35 deletions
|
@ -130,14 +130,14 @@ void v8__Isolate__RunMicrotasks(v8::Isolate& isolate) {
|
|||
isolate.RunMicrotasks();
|
||||
}
|
||||
|
||||
void v8__Isolate__EnqueueMicrotask(v8::Isolate& isolate,
|
||||
v8::Function* function) {
|
||||
isolate.EnqueueMicrotask(ptr_to_local(function));
|
||||
void v8__Isolate__EnqueueMicrotask(v8::Isolate* isolate,
|
||||
v8::Local<v8::Function> function) {
|
||||
isolate->EnqueueMicrotask(function);
|
||||
}
|
||||
|
||||
void v8__Isolate__RequestInterrupt(v8::Isolate& isolate,
|
||||
void v8__Isolate__RequestInterrupt(v8::Isolate* isolate,
|
||||
v8::InterruptCallback callback, void* data) {
|
||||
isolate.RequestInterrupt(callback, data);
|
||||
isolate->RequestInterrupt(callback, data);
|
||||
}
|
||||
|
||||
void v8__Isolate__SetPromiseRejectCallback(v8::Isolate* isolate,
|
||||
|
@ -168,21 +168,21 @@ bool v8__Isolate__AddMessageListener(v8::Isolate& isolate,
|
|||
return isolate.AddMessageListener(callback);
|
||||
}
|
||||
|
||||
v8::Value* v8__Isolate__ThrowException(v8::Isolate& isolate,
|
||||
v8::Value* exception) {
|
||||
return local_to_ptr(isolate.ThrowException(ptr_to_local(exception)));
|
||||
v8::Value* v8__Isolate__ThrowException(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> exception) {
|
||||
return local_to_ptr(isolate->ThrowException(exception));
|
||||
}
|
||||
|
||||
void v8__Isolate__TerminateExecution(v8::Isolate& isolate) {
|
||||
isolate.TerminateExecution();
|
||||
void v8__Isolate__TerminateExecution(v8::Isolate* isolate) {
|
||||
isolate->TerminateExecution();
|
||||
}
|
||||
|
||||
bool v8__Isolate__IsExecutionTerminating(v8::Isolate& isolate) {
|
||||
return isolate.IsExecutionTerminating();
|
||||
bool v8__Isolate__IsExecutionTerminating(v8::Isolate* isolate) {
|
||||
return isolate->IsExecutionTerminating();
|
||||
}
|
||||
|
||||
void v8__Isolate__CancelTerminateExecution(v8::Isolate& isolate) {
|
||||
isolate.CancelTerminateExecution();
|
||||
void v8__Isolate__CancelTerminateExecution(v8::Isolate* isolate) {
|
||||
isolate->CancelTerminateExecution();
|
||||
}
|
||||
|
||||
v8::Isolate::CreateParams* v8__Isolate__CreateParams__NEW() {
|
||||
|
|
|
@ -100,14 +100,17 @@ extern "C" {
|
|||
data: *mut c_void,
|
||||
);
|
||||
fn v8__Isolate__ThrowException(
|
||||
isolate: &Isolate,
|
||||
exception: &Value,
|
||||
isolate: *mut Isolate,
|
||||
exception: Local<Value>,
|
||||
) -> *mut Value;
|
||||
fn v8__Isolate__TerminateExecution(isolate: &Isolate);
|
||||
fn v8__Isolate__IsExecutionTerminating(isolate: &Isolate) -> bool;
|
||||
fn v8__Isolate__CancelTerminateExecution(isolate: &Isolate);
|
||||
fn v8__Isolate__RunMicrotasks(isolate: &Isolate);
|
||||
fn v8__Isolate__EnqueueMicrotask(isolate: &Isolate, microtask: *mut Function);
|
||||
fn v8__Isolate__TerminateExecution(isolate: *const Isolate);
|
||||
fn v8__Isolate__IsExecutionTerminating(isolate: *const Isolate) -> bool;
|
||||
fn v8__Isolate__CancelTerminateExecution(isolate: *const Isolate);
|
||||
fn v8__Isolate__RunMicrotasks(isolate: *mut Isolate);
|
||||
fn v8__Isolate__EnqueueMicrotask(
|
||||
isolate: *mut Isolate,
|
||||
microtask: Local<Function>,
|
||||
);
|
||||
|
||||
fn v8__Isolate__CreateParams__NEW() -> *mut CreateParams;
|
||||
fn v8__Isolate__CreateParams__DELETE(this: &mut CreateParams);
|
||||
|
@ -255,11 +258,11 @@ impl Isolate {
|
|||
/// operation; the caller must return immediately and only after the exception
|
||||
/// has been handled does it become legal to invoke JavaScript operations.
|
||||
pub fn throw_exception<'sc>(
|
||||
&self,
|
||||
exception: Local<'_, Value>,
|
||||
&mut self,
|
||||
exception: Local<Value>,
|
||||
) -> Local<'sc, Value> {
|
||||
unsafe {
|
||||
let ptr = v8__Isolate__ThrowException(self, &exception);
|
||||
let ptr = v8__Isolate__ThrowException(self, exception);
|
||||
Local::from_raw(ptr).unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -301,13 +304,13 @@ impl Isolate {
|
|||
|
||||
/// Runs the default MicrotaskQueue until it gets empty.
|
||||
/// Any exceptions thrown by microtask callbacks are swallowed.
|
||||
pub fn run_microtasks(&self) {
|
||||
pub fn run_microtasks(&mut self) {
|
||||
unsafe { v8__Isolate__RunMicrotasks(self) }
|
||||
}
|
||||
|
||||
/// Enqueues the callback to the default MicrotaskQueue
|
||||
pub fn enqueue_microtask(&self, mut microtask: Local<Function>) {
|
||||
unsafe { v8__Isolate__EnqueueMicrotask(self, &mut *microtask) }
|
||||
pub fn enqueue_microtask(&mut self, microtask: Local<Function>) {
|
||||
unsafe { v8__Isolate__EnqueueMicrotask(self, microtask) }
|
||||
}
|
||||
|
||||
/// Request V8 to interrupt long running JavaScript code and invoke
|
||||
|
|
|
@ -200,10 +200,10 @@ fn microtasks() {
|
|||
let mut params = v8::Isolate::create_params();
|
||||
params.set_array_buffer_allocator(v8::new_default_allocator());
|
||||
let isolate = v8::Isolate::new(params);
|
||||
|
||||
isolate.run_microtasks();
|
||||
|
||||
let mut locker = v8::Locker::new(&isolate);
|
||||
|
||||
locker.isolate().run_microtasks();
|
||||
|
||||
{
|
||||
let mut hs = v8::HandleScope::new(&mut locker);
|
||||
let scope = hs.enter();
|
||||
|
@ -221,13 +221,12 @@ fn microtasks() {
|
|||
},
|
||||
)
|
||||
.unwrap();
|
||||
scope.isolate().enqueue_microtask(function);
|
||||
|
||||
assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 0);
|
||||
|
||||
isolate.enqueue_microtask(function);
|
||||
isolate.run_microtasks();
|
||||
|
||||
scope.isolate().run_microtasks();
|
||||
assert_eq!(CALL_COUNT.load(Ordering::SeqCst), 1);
|
||||
|
||||
context.exit();
|
||||
}
|
||||
}
|
||||
|
@ -416,7 +415,8 @@ fn throw_exception() {
|
|||
{
|
||||
let mut try_catch = v8::TryCatch::new(scope);
|
||||
let tc = try_catch.enter();
|
||||
isolate.throw_exception(v8_str(scope, "boom").into());
|
||||
let exception = v8_str(scope, "boom");
|
||||
scope.isolate().throw_exception(exception.into());
|
||||
assert!(tc.has_caught());
|
||||
assert!(tc
|
||||
.exception()
|
||||
|
|
Loading…
Reference in a new issue