mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-25 15:29:43 -05:00
Make Private work with context-less HandleScope (#549)
v8::Private is like v8::String and other primitives, it doesn't need an active v8::Context.
This commit is contained in:
parent
4e8eaf94c3
commit
530c876aff
2 changed files with 6 additions and 5 deletions
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
impl Private {
|
||||
/// Create a private symbol. If name is not empty, it will be the description.
|
||||
pub fn new<'s>(
|
||||
scope: &mut HandleScope<'s>,
|
||||
scope: &mut HandleScope<'s, ()>,
|
||||
name: Option<Local<String>>,
|
||||
) -> Local<'s, Private> {
|
||||
unsafe {
|
||||
|
@ -42,7 +42,7 @@ impl Private {
|
|||
/// To minimize the potential for clashes, use qualified names as keys,
|
||||
/// e.g., "Class#property".
|
||||
pub fn for_api<'s>(
|
||||
scope: &mut HandleScope<'s>,
|
||||
scope: &mut HandleScope<'s, ()>,
|
||||
name: Option<Local<String>>,
|
||||
) -> Local<'s, Private> {
|
||||
unsafe {
|
||||
|
@ -57,7 +57,7 @@ impl Private {
|
|||
}
|
||||
|
||||
/// Returns the print name string of the private symbol, or undefined if none.
|
||||
pub fn name<'s>(&self, scope: &mut HandleScope<'s>) -> Local<'s, Value> {
|
||||
pub fn name<'s>(&self, scope: &mut HandleScope<'s, ()>) -> Local<'s, Value> {
|
||||
unsafe { scope.cast_local(|_| v8__Private__Name(&*self)) }.unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3873,8 +3873,6 @@ fn private() {
|
|||
let _setup_guard = setup();
|
||||
let isolate = &mut v8::Isolate::new(Default::default());
|
||||
let scope = &mut v8::HandleScope::new(isolate);
|
||||
let context = v8::Context::new(scope);
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
|
||||
let p = v8::Private::new(scope, None);
|
||||
assert!(p.name(scope) == v8::undefined(scope));
|
||||
|
@ -3891,6 +3889,9 @@ fn private() {
|
|||
assert!(p_api2 != p);
|
||||
assert!(p_api == p_api2);
|
||||
|
||||
let context = v8::Context::new(scope);
|
||||
let scope = &mut v8::ContextScope::new(scope, context);
|
||||
|
||||
let object = v8::Object::new(scope);
|
||||
let sentinel = v8::Object::new(scope).into();
|
||||
assert!(!object.has_private(scope, p).unwrap());
|
||||
|
|
Loading…
Reference in a new issue