mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-25 00:29:14 -05:00
Some clean-ups after making Locker a Scope (#231)
This commit is contained in:
parent
44d58f8f48
commit
b3d93dad78
5 changed files with 10 additions and 34 deletions
|
@ -631,14 +631,12 @@ void v8__Template__Set(v8::Template& self, v8::Local<v8::Name> key,
|
|||
}
|
||||
|
||||
v8::ObjectTemplate* v8__ObjectTemplate__New(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> templ) {
|
||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> templ) {
|
||||
return local_to_ptr(v8::ObjectTemplate::New(isolate, templ));
|
||||
}
|
||||
|
||||
v8::Object* v8__ObjectTemplate__NewInstance(
|
||||
v8::ObjectTemplate& self,
|
||||
v8::Local<v8::Context> context) {
|
||||
v8::Object* v8__ObjectTemplate__NewInstance(v8::ObjectTemplate& self,
|
||||
v8::Local<v8::Context> context) {
|
||||
return maybe_local_to_ptr(self.NewInstance(context));
|
||||
}
|
||||
|
||||
|
@ -903,8 +901,8 @@ v8::Function* v8__FunctionTemplate__GetFunction(
|
|||
return maybe_local_to_ptr(self->GetFunction(context));
|
||||
}
|
||||
|
||||
void v8__FunctionTemplate__SetClassName(
|
||||
v8::Local<v8::FunctionTemplate> self, v8::Local<v8::String> name) {
|
||||
void v8__FunctionTemplate__SetClassName(v8::Local<v8::FunctionTemplate> self,
|
||||
v8::Local<v8::String> name) {
|
||||
self->SetClassName(name);
|
||||
}
|
||||
|
||||
|
@ -942,11 +940,6 @@ v8::Value* v8__ReturnValue__Get(const v8::ReturnValue<v8::Value>& self) {
|
|||
return local_to_ptr(self.Get());
|
||||
}
|
||||
|
||||
v8::Isolate* v8__ReturnValue__GetIsolate(
|
||||
const v8::ReturnValue<v8::Value>& self) {
|
||||
return self.GetIsolate();
|
||||
}
|
||||
|
||||
int v8__StackTrace__GetFrameCount(v8::StackTrace* self) {
|
||||
return self->GetFrameCount();
|
||||
}
|
||||
|
|
|
@ -176,8 +176,7 @@ impl<'s, S, P> Entered<'s, S, P> {
|
|||
/// instead.
|
||||
///
|
||||
/// A CallbackScope can be created from the following inputs:
|
||||
/// - `&mut Isolate`
|
||||
/// ` - `Local<Context>`
|
||||
/// - `Local<Context>`
|
||||
/// - `Local<Message>`
|
||||
/// - `Local<Object>`
|
||||
/// - `Local<Promise>`
|
||||
|
|
|
@ -14,7 +14,6 @@ use crate::Locker;
|
|||
use crate::Message;
|
||||
use crate::Object;
|
||||
use crate::PropertyCallbackInfo;
|
||||
use crate::ReturnValue;
|
||||
|
||||
pub(crate) mod internal {
|
||||
use super::*;
|
||||
|
@ -33,7 +32,6 @@ pub(crate) mod internal {
|
|||
fn v8__PropertyCallbackInfo__GetIsolate(
|
||||
self_: &PropertyCallbackInfo,
|
||||
) -> *mut Isolate;
|
||||
fn v8__ReturnValue__GetIsolate(self_: &ReturnValue) -> *mut Isolate;
|
||||
}
|
||||
|
||||
/// Internal trait for retrieving a raw Isolate pointer from various V8
|
||||
|
@ -132,16 +130,8 @@ pub(crate) mod internal {
|
|||
unsafe { v8__PropertyCallbackInfo__GetIsolate(self) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> GetRawIsolate for ReturnValue<'a> {
|
||||
fn get_raw_isolate(&self) -> *mut Isolate {
|
||||
unsafe { v8__ReturnValue__GetIsolate(self) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use internal::GetRawIsolate;
|
||||
|
||||
/// Trait for retrieving the current isolate from a scope object.
|
||||
pub trait InIsolate {
|
||||
// Do not implement this trait on unscoped Isolate references
|
||||
|
@ -149,12 +139,6 @@ pub trait InIsolate {
|
|||
fn isolate(&mut self) -> &mut Isolate;
|
||||
}
|
||||
|
||||
impl InIsolate for Locker {
|
||||
fn isolate(&mut self) -> &mut Isolate {
|
||||
unsafe { &mut *self.get_raw_isolate() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'s, S, P> InIsolate for Entered<'s, S, P>
|
||||
where
|
||||
S: internal::GetRawIsolate,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
use rusty_v8 as v8;
|
||||
|
||||
pub fn main() {
|
||||
let mut locker: v8::Locker = mock();
|
||||
let mut hs0 = v8::HandleScope::new(&mut locker);
|
||||
let mut locker = v8::Locker::new(mock());
|
||||
let mut hs0 = v8::HandleScope::new(locker.enter());
|
||||
let hs0 = hs0.enter();
|
||||
|
||||
let _fail = {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
use rusty_v8 as v8;
|
||||
|
||||
pub fn main() {
|
||||
let mut locker: v8::Locker = mock();
|
||||
let mut root_hs = v8::HandleScope::new(&mut locker);
|
||||
let mut locker = v8::Locker::new(mock());
|
||||
let mut root_hs = v8::HandleScope::new(locker.enter());
|
||||
let root_hs = root_hs.enter();
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue