diff --git a/src/binding.cc b/src/binding.cc index a7365473..837128ff 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -1519,6 +1519,20 @@ const v8::Value* v8__Object__GetOwnPropertyDescriptor( ptr_to_local(&context), ptr_to_local(&key))); } + +const v8::Value* v8__Object__GetRealNamedProperty( + const v8::Object& self, const v8::Context& context, const v8::Name& key) { + return maybe_local_to_ptr(ptr_to_local(&self)->GetRealNamedProperty( + ptr_to_local(&context), ptr_to_local(&key))); +} + +void v8__Object__GetRealNamedPropertyAttributes( + const v8::Object& self, const v8::Context& context, const v8::Name& key, + v8::Maybe* out) { + *out = ptr_to_local(&self)->GetRealNamedPropertyAttributes( + ptr_to_local(&context), ptr_to_local(&key)); +} + const v8::Array* v8__Object__PreviewEntries(const v8::Object& self, bool* is_key_value) { return maybe_local_to_ptr(ptr_to_local(&self)->PreviewEntries(is_key_value)); diff --git a/src/object.rs b/src/object.rs index 16f1e0be..17f6a485 100644 --- a/src/object.rs +++ b/src/object.rs @@ -198,6 +198,17 @@ extern "C" { this: *const Object, is_key_value: *mut bool, ) -> *const Array; + fn v8__Object__GetRealNamedProperty( + this: *const Object, + context: *const Context, + key: *const Name, + ) -> *const Value; + fn v8__Object__GetRealNamedPropertyAttribute( + this: *const Object, + context: *const Context, + key: *const Name, + out: *mut Maybe, + ); fn v8__Array__New(isolate: *mut Isolate, length: int) -> *const Array; fn v8__Array__New_with_elements( @@ -831,6 +842,43 @@ impl Object { (val, is_key_value) } } + + /// If result.IsEmpty() no real property was located on the object or + /// in the prototype chain. + /// This means interceptors in the prototype chain are not called. + #[inline(always)] + pub fn get_real_named_property<'s>( + &self, + scope: &mut HandleScope<'s>, + key: Local, + ) -> Option> { + unsafe { + scope.cast_local(|sd| { + v8__Object__GetRealNamedProperty(self, sd.get_current_context(), &*key) + }) + } + } + + /// Gets the property attributes of a real property which can be + /// None or any combination of ReadOnly, DontEnum and DontDelete. + /// Interceptors in the prototype chain are not called. + #[inline(always)] + pub fn get_real_named_property_attributes( + &self, + scope: &mut HandleScope, + key: Local, + ) -> Option { + let mut out = Maybe::::default(); + unsafe { + v8__Object__GetRealNamedPropertyAttribute( + self, + &*scope.get_current_context(), + &*key, + &mut out, + ) + } + out.into() + } } /// Object integrity levels can be used to restrict what can be done to an