OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 3230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 */ | 3241 */ |
3242 V8_INLINE Isolate* GetIsolate() const; | 3242 V8_INLINE Isolate* GetIsolate() const; |
3243 | 3243 |
3244 /** | 3244 /** |
3245 * \return The data set in the configuration, i.e., in | 3245 * \return The data set in the configuration, i.e., in |
3246 * `NamedPropertyHandlerConfiguration` or | 3246 * `NamedPropertyHandlerConfiguration` or |
3247 * `IndexedPropertyHandlerConfiguration.` | 3247 * `IndexedPropertyHandlerConfiguration.` |
3248 */ | 3248 */ |
3249 V8_INLINE Local<Value> Data() const; | 3249 V8_INLINE Local<Value> Data() const; |
3250 | 3250 |
| 3251 /** |
| 3252 * \return The receiver. In many cases, this is the object on which the |
| 3253 * property access was intercepted. When using |
| 3254 * `Reflect.Get`, `Function.prototype.call`, or similar functions, it is the |
| 3255 * object passed in as receiver or thisArg. |
| 3256 * |
| 3257 * \code |
| 3258 * void GetterCallback(Local<Name> name, |
| 3259 * const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 3260 * auto context = info.GetIsolate()->GetCurrentContext(); |
| 3261 * |
| 3262 * v8::Local<v8::Value> a_this = |
| 3263 * info.This() |
| 3264 * ->GetRealNamedProperty(context, v8_str("a")) |
| 3265 * .ToLocalChecked(); |
| 3266 * v8::Local<v8::Value> a_holder = |
| 3267 * info.Holder() |
| 3268 * ->GetRealNamedProperty(context, v8_str("a")) |
| 3269 * .ToLocalChecked(); |
| 3270 * |
| 3271 * CHECK(v8_str("r")->Equals(context, a_this).FromJust()); |
| 3272 * CHECK(v8_str("obj")->Equals(context, a_holder).FromJust()); |
| 3273 * |
| 3274 * info.GetReturnValue().Set(name); |
| 3275 * } |
| 3276 * |
| 3277 * v8::Local<v8::FunctionTemplate> templ = |
| 3278 * v8::FunctionTemplate::New(isolate); |
| 3279 * templ->InstanceTemplate()->SetHandler( |
| 3280 * v8::NamedPropertyHandlerConfiguration(GetterCallback)); |
| 3281 * LocalContext env; |
| 3282 * env->Global() |
| 3283 * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) |
| 3284 * .ToLocalChecked() |
| 3285 * ->NewInstance(env.local()) |
| 3286 * .ToLocalChecked()) |
| 3287 * .FromJust(); |
| 3288 * |
| 3289 * CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)"); |
| 3290 * \endcode |
| 3291 */ |
3251 V8_INLINE Local<Object> This() const; | 3292 V8_INLINE Local<Object> This() const; |
3252 | 3293 |
3253 /** | 3294 /** |
3254 * \return The object in the prototype chain of the receiver that has the | 3295 * \return The object in the prototype chain of the receiver that has the |
3255 * interceptor. Suppose you have `x` and its prototype is `y`, and `y` | 3296 * interceptor. Suppose you have `x` and its prototype is `y`, and `y` |
3256 * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`. | 3297 * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`. |
3257 * The Holder() could be a hidden object (the global object, rather | 3298 * The Holder() could be a hidden object (the global object, rather |
3258 * than the global proxy). | 3299 * than the global proxy). |
3259 * | 3300 * |
3260 * \note For security reasons, do not pass the object back into the runtime. | 3301 * \note For security reasons, do not pass the object back into the runtime. |
(...skipping 5763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9024 */ | 9065 */ |
9025 | 9066 |
9026 | 9067 |
9027 } // namespace v8 | 9068 } // namespace v8 |
9028 | 9069 |
9029 | 9070 |
9030 #undef TYPE_CHECK | 9071 #undef TYPE_CHECK |
9031 | 9072 |
9032 | 9073 |
9033 #endif // INCLUDE_V8_H_ | 9074 #endif // INCLUDE_V8_H_ |
OLD | NEW |