mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-02-01 20:24:56 -05:00
feat: Add "v8::Object::get_real_named_property_*" methods (#1428)
This commit is contained in:
parent
69bac645e0
commit
10d12a450e
2 changed files with 62 additions and 0 deletions
|
@ -1519,6 +1519,20 @@ const v8::Value* v8__Object__GetOwnPropertyDescriptor(
|
||||||
ptr_to_local(&context), ptr_to_local(&key)));
|
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<v8::PropertyAttribute>* 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,
|
const v8::Array* v8__Object__PreviewEntries(const v8::Object& self,
|
||||||
bool* is_key_value) {
|
bool* is_key_value) {
|
||||||
return maybe_local_to_ptr(ptr_to_local(&self)->PreviewEntries(is_key_value));
|
return maybe_local_to_ptr(ptr_to_local(&self)->PreviewEntries(is_key_value));
|
||||||
|
|
|
@ -198,6 +198,17 @@ extern "C" {
|
||||||
this: *const Object,
|
this: *const Object,
|
||||||
is_key_value: *mut bool,
|
is_key_value: *mut bool,
|
||||||
) -> *const Array;
|
) -> *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<PropertyAttribute>,
|
||||||
|
);
|
||||||
|
|
||||||
fn v8__Array__New(isolate: *mut Isolate, length: int) -> *const Array;
|
fn v8__Array__New(isolate: *mut Isolate, length: int) -> *const Array;
|
||||||
fn v8__Array__New_with_elements(
|
fn v8__Array__New_with_elements(
|
||||||
|
@ -831,6 +842,43 @@ impl Object {
|
||||||
(val, is_key_value)
|
(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<Name>,
|
||||||
|
) -> Option<Local<'s, Value>> {
|
||||||
|
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<Name>,
|
||||||
|
) -> Option<PropertyAttribute> {
|
||||||
|
let mut out = Maybe::<PropertyAttribute>::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
|
/// Object integrity levels can be used to restrict what can be done to an
|
||||||
|
|
Loading…
Add table
Reference in a new issue