diff --git a/README.md b/README.md index 7e9cd1c9..512cc1cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rusty V8 Binding -V8 Version: 9.8.177.9 +V8 Version: 9.9.115.5 [![ci](https://github.com/denoland/rusty_v8/workflows/ci/badge.svg?branch=main)](https://github.com/denoland/rusty_v8/actions) [![crates](https://img.shields.io/crates/v/v8.svg)](https://crates.io/crates/v8) diff --git a/src/binding.cc b/src/binding.cc index 25d85573..696f28ad 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -1126,8 +1126,8 @@ int v8__Object__GetIdentityHash(const v8::Object& self) { return ptr_to_local(&self)->GetIdentityHash(); } -const v8::Context* v8__Object__CreationContext(const v8::Object& self) { - return local_to_ptr(ptr_to_local(&self)->CreationContext()); +const v8::Context* v8__Object__GetCreationContext(const v8::Object& self) { + return maybe_local_to_ptr(ptr_to_local(&self)->GetCreationContext()); } const v8::Array* v8__Object__GetOwnPropertyNames(const v8::Object* self, diff --git a/src/object.rs b/src/object.rs index 0c55cd18..8d512f70 100644 --- a/src/object.rs +++ b/src/object.rs @@ -80,7 +80,7 @@ extern "C" { attr: PropertyAttribute, ) -> MaybeBool; fn v8__Object__GetIdentityHash(this: *const Object) -> int; - fn v8__Object__CreationContext(this: *const Object) -> *const Context; + fn v8__Object__GetCreationContext(this: *const Object) -> *const Context; fn v8__Object__GetOwnPropertyNames( this: *const Object, context: *const Context, @@ -382,11 +382,11 @@ impl Object { } /// Returns the context in which the object was created. - pub fn creation_context<'s>( + pub fn get_creation_context<'s>( &self, scope: &mut HandleScope<'s>, - ) -> Local<'s, Context> { - unsafe { scope.cast_local(|_| v8__Object__CreationContext(self)) }.unwrap() + ) -> Option> { + unsafe { scope.cast_local(|_| v8__Object__GetCreationContext(self)) } } /// This function has the same functionality as GetPropertyNames but the diff --git a/tests/test_api.rs b/tests/test_api.rs index 76c0d0a8..a4eb61bd 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -1540,7 +1540,7 @@ fn object() { &[v1, v2], ); assert!(!object.is_null_or_undefined()); - let lhs = object.creation_context(scope).global(scope); + let lhs = object.get_creation_context(scope).unwrap().global(scope); let rhs = context.global(scope); assert!(lhs.strict_equals(rhs.into())); @@ -1653,7 +1653,7 @@ fn array() { let s2 = v8::String::new(scope, "b").unwrap(); let array = v8::Array::new(scope, 2); assert_eq!(array.length(), 2); - let lhs = array.creation_context(scope).global(scope); + let lhs = array.get_creation_context(scope).unwrap().global(scope); let rhs = context.global(scope); assert!(lhs.strict_equals(rhs.into())); array.set_index(scope, 0, s1.into()); @@ -2024,7 +2024,7 @@ fn function() { let function = fn_template .get_function(scope) .expect("Unable to create function"); - let lhs = function.creation_context(scope).global(scope); + let lhs = function.get_creation_context(scope).unwrap().global(scope); let rhs = context.global(scope); assert!(lhs.strict_equals(rhs.into())); let value = function @@ -2219,7 +2219,7 @@ fn promise_hook() { #[allow(clippy::clone_on_copy)] if type_.clone() == v8::PromiseHookType::Init {} let scope = &mut unsafe { v8::CallbackScope::new(promise) }; - let context = promise.creation_context(scope); + let context = promise.get_creation_context(scope).unwrap(); let scope = &mut v8::ContextScope::new(scope, context); let global = context.global(scope); let name = v8::String::new(scope, "hook").unwrap(); diff --git a/v8 b/v8 index d89d2947..3f7acaf7 160000 --- a/v8 +++ b/v8 @@ -1 +1 @@ -Subproject commit d89d294754e47fc32385e8930c1dcfb82cd2345a +Subproject commit 3f7acaf72adeb21dfac5a92601dd510e3f43ec42