[api] Add documentation for PropertyCallbackInfo.This().
BUG=v8:5260 Review-Url: https://codereview.chromium.org/2278523002 Cr-Commit-Position: refs/heads/master@{#38949}
This commit is contained in:
parent
864728085d
commit
5aa7230516
41
include/v8.h
41
include/v8.h
@ -3346,6 +3346,47 @@ class PropertyCallbackInfo {
|
|||||||
*/
|
*/
|
||||||
V8_INLINE Local<Value> Data() const;
|
V8_INLINE Local<Value> Data() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \return 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.
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* 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)");
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
V8_INLINE Local<Object> This() const;
|
V8_INLINE Local<Object> This() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user