Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Unified Diff: include/v8.h

Issue 2278523002: [api] Add documentation for PropertyCallbackInfo.This(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DocPropertyCallbackInfo
Patch Set: Do not use cctest isolate in documentation. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index fcd1baf5840376519a7816a180b6b211b6578828..77affcff2c7a8c25974d8db76f198215cbf46680 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3248,6 +3248,47 @@ class PropertyCallbackInfo {
*/
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;
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698