pub struct PropertyCallbackArguments<'s>(_);

Implementations§

source§

impl<'s> PropertyCallbackArguments<'s>

source

pub fn holder(&self) -> Local<'s, Object>

Returns he object in the prototype chain of the receiver that has the interceptor. Suppose you have x and its prototype is y, and y has an interceptor. Then info.this() is x and info.holder() is y. The holder() could be a hidden object (the global object, rather than the global proxy).

For security reasons, do not pass the object back into the runtime.

source

pub fn this(&self) -> Local<'s, Object>

Returns the receiver. In many cases, this is the object on which the property access was intercepted. When using Reflect.get, Function.prototype.call, or similar functions, it is the object passed in as receiver or thisArg.

  void GetterCallback(Local<Name> name,
                      const v8::PropertyCallbackInfo<v8::Value>& info) {
     auto context = info.GetIsolate()->GetCurrentContext();

     v8::Local<v8::Value> a_this =
         info.This()
             ->GetRealNamedProperty(context, v8_str("a"))
             .ToLocalChecked();
     v8::Local<v8::Value> a_holder =
         info.Holder()
             ->GetRealNamedProperty(context, v8_str("a"))
             .ToLocalChecked();

    CHECK(v8_str("r")->Equals(context, a_this).FromJust());
    CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());

    info.GetReturnValue().Set(name);
  }

  v8::Local<v8::FunctionTemplate> templ =
  v8::FunctionTemplate::New(isolate);
  templ->InstanceTemplate()->SetHandler(
      v8::NamedPropertyHandlerConfiguration(GetterCallback));
  LocalContext env;
  env->Global()
      ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
                                           .ToLocalChecked()
                                           ->NewInstance(env.local())
                                           .ToLocalChecked())
      .FromJust();

  CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
source

pub fn data(&self) -> Local<'s, Value>

Returns the data set in the configuration, i.e., in NamedPropertyHandlerConfiguration or IndexedPropertyHandlerConfiguration.

source

pub fn should_throw_on_error(&self) -> bool

Returns true if the intercepted function should throw if an error occurs. Usually, true corresponds to 'use strict'.

Always false when intercepting Reflect.set() independent of the language mode.

Trait Implementations§

source§

impl<'s> Debug for PropertyCallbackArguments<'s>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.