mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-27 01:29:19 -05:00
feat: access with receiver (#1542)
This commit is contained in:
parent
c9383c2184
commit
d5da421046
2 changed files with 72 additions and 0 deletions
|
@ -1380,6 +1380,14 @@ const v8::Value* v8__Object__Get(const v8::Object& self,
|
|||
ptr_to_local(&self)->Get(ptr_to_local(&context), ptr_to_local(&key)));
|
||||
}
|
||||
|
||||
const v8::Value* v8__Object__GetWithReceiver(const v8::Object& self,
|
||||
const v8::Context& context,
|
||||
const v8::Value& key,
|
||||
const v8::Object& receiver) {
|
||||
return maybe_local_to_ptr(ptr_to_local(&self)->Get(
|
||||
ptr_to_local(&context), ptr_to_local(&key), ptr_to_local(&receiver)));
|
||||
}
|
||||
|
||||
const v8::Value* v8__Object__GetIndex(const v8::Object& self,
|
||||
const v8::Context& context,
|
||||
uint32_t index) {
|
||||
|
@ -1411,6 +1419,16 @@ MaybeBool v8__Object__Set(const v8::Object& self, const v8::Context& context,
|
|||
ptr_to_local(&context), ptr_to_local(&key), ptr_to_local(&value)));
|
||||
}
|
||||
|
||||
MaybeBool v8__Object__SetWithReceiver(const v8::Object& self,
|
||||
const v8::Context& context,
|
||||
const v8::Value& key,
|
||||
const v8::Value& value,
|
||||
const v8::Object& receiver) {
|
||||
return maybe_to_maybe_bool(
|
||||
ptr_to_local(&self)->Set(ptr_to_local(&context), ptr_to_local(&key),
|
||||
ptr_to_local(&value), ptr_to_local(&receiver)));
|
||||
}
|
||||
|
||||
MaybeBool v8__Object__SetIndex(const v8::Object& self,
|
||||
const v8::Context& context, uint32_t index,
|
||||
const v8::Value& value) {
|
||||
|
|
|
@ -58,6 +58,12 @@ extern "C" {
|
|||
context: *const Context,
|
||||
key: *const Value,
|
||||
) -> *const Value;
|
||||
fn v8__Object__GetWithReceiver(
|
||||
this: *const Object,
|
||||
context: *const Context,
|
||||
key: *const Value,
|
||||
receiver: *const Object,
|
||||
) -> *const Value;
|
||||
fn v8__Object__GetIndex(
|
||||
this: *const Object,
|
||||
context: *const Context,
|
||||
|
@ -70,6 +76,13 @@ extern "C" {
|
|||
key: *const Value,
|
||||
value: *const Value,
|
||||
) -> MaybeBool;
|
||||
fn v8__Object__SetWithReceiver(
|
||||
this: *const Object,
|
||||
context: *const Context,
|
||||
key: *const Value,
|
||||
value: *const Value,
|
||||
receiver: *const Object,
|
||||
) -> MaybeBool;
|
||||
fn v8__Object__SetIndex(
|
||||
this: *const Object,
|
||||
context: *const Context,
|
||||
|
@ -333,6 +346,28 @@ impl Object {
|
|||
.into()
|
||||
}
|
||||
|
||||
/// SetWithReceiver only return Just(true) or Empty(), so if it should never fail, use
|
||||
/// result.Check().
|
||||
#[inline(always)]
|
||||
pub fn set_with_receiver(
|
||||
&self,
|
||||
scope: &mut HandleScope,
|
||||
key: Local<Value>,
|
||||
value: Local<Value>,
|
||||
receiver: Local<Object>,
|
||||
) -> Option<bool> {
|
||||
unsafe {
|
||||
v8__Object__SetWithReceiver(
|
||||
self,
|
||||
&*scope.get_current_context(),
|
||||
&*key,
|
||||
&*value,
|
||||
&*receiver,
|
||||
)
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Set only return Just(true) or Empty(), so if it should never fail, use
|
||||
/// result.Check().
|
||||
#[inline(always)]
|
||||
|
@ -449,6 +484,25 @@ impl Object {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_with_receiver<'s>(
|
||||
&self,
|
||||
scope: &mut HandleScope<'s>,
|
||||
key: Local<Value>,
|
||||
receiver: Local<Object>,
|
||||
) -> Option<Local<'s, Value>> {
|
||||
unsafe {
|
||||
scope.cast_local(|sd| {
|
||||
v8__Object__GetWithReceiver(
|
||||
self,
|
||||
sd.get_current_context(),
|
||||
&*key,
|
||||
&*receiver,
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_index<'s>(
|
||||
&self,
|
||||
|
|
Loading…
Reference in a new issue