pub struct PropertyCallbackArguments<'s>(/* private fields */);Implementations§
Source§impl<'s> PropertyCallbackArguments<'s>
impl<'s> PropertyCallbackArguments<'s>
Sourcepub fn holder(&self) -> Local<'s, Object>
pub fn holder(&self) -> Local<'s, Object>
Returns the 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.
In case the property is installed on the global object the Holder()
would return the global proxy.
Sourcepub fn this(&self) -> Local<'s, Object>
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)");Sourcepub fn data(&self) -> Local<'s, Value>
pub fn data(&self) -> Local<'s, Value>
Returns the data set in the configuration, i.e., in
NamedPropertyHandlerConfiguration or
IndexedPropertyHandlerConfiguration.
Sourcepub fn should_throw_on_error(&self) -> bool
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.