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

Unified Diff: include/v8.h

Issue 2277513003: [api] Improve documentation for NamedPropertyGetterCallback. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DocCallbacksSetter
Patch Set: Word comment to set instead of change. 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 d5298442801dd7e46be07d5671abb85272bcf18e..c8c168c0b6b6a44bb19855455946e9b0bc570e0b 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4341,8 +4341,40 @@ typedef void (*NamedPropertyEnumeratorCallback)(
// TODO(dcarney): Deprecate and remove previous typedefs, and replace
// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback.
/**
- * GenericNamedProperty[Getter|Setter] are used as interceptors on object.
- * See ObjectTemplate::SetNamedPropertyHandler.
+ * Interceptor for get requests on an object.
+ *
+ * Use `info.GetReturnValue().Set()` to set the return value of the
+ * intercepted get request.
+ *
+ * \param property The name of the property for which the request was
+ * intercepted.
+ * \param info Information about the intercepted request, such as
+ * isolate, receiver, return value, or whether running in `'use strict`' mode.
+ * See `PropertyCallbackInfo`.
+ *
+ * \code
+ * void GetterCallback(
+ * Local<Name> name,
+ * const v8::PropertyCallbackInfo<v8::Value>& info) {
+ * info.GetReturnValue().Set(v8_num(42));
+ * }
+ *
+ * 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();
+ * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
+ * CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
+ * \endcode
+ *
+ * See also `ObjectTemplate::SetNamedPropertyHandler`.
*/
typedef void (*GenericNamedPropertyGetterCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
« 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