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 4323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4334 * Returns an array containing the names of the properties the named | 4334 * Returns an array containing the names of the properties the named |
4335 * property getter intercepts. | 4335 * property getter intercepts. |
4336 */ | 4336 */ |
4337 typedef void (*NamedPropertyEnumeratorCallback)( | 4337 typedef void (*NamedPropertyEnumeratorCallback)( |
4338 const PropertyCallbackInfo<Array>& info); | 4338 const PropertyCallbackInfo<Array>& info); |
4339 | 4339 |
4340 | 4340 |
4341 // TODO(dcarney): Deprecate and remove previous typedefs, and replace | 4341 // TODO(dcarney): Deprecate and remove previous typedefs, and replace |
4342 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. | 4342 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. |
4343 /** | 4343 /** |
4344 * GenericNamedProperty[Getter|Setter] are used as interceptors on object. | 4344 * Interceptor for get requests on an object. |
4345 * See ObjectTemplate::SetNamedPropertyHandler. | 4345 * |
| 4346 * Use `info.GetReturnValue().Set()` to set the return value of the |
| 4347 * intercepted get request. |
| 4348 * |
| 4349 * \param property The name of the property for which the request was |
| 4350 * intercepted. |
| 4351 * \param info Information about the intercepted request, such as |
| 4352 * isolate, receiver, return value, or whether running in `'use strict`' mode. |
| 4353 * See `PropertyCallbackInfo`. |
| 4354 * |
| 4355 * \code |
| 4356 * void GetterCallback( |
| 4357 * Local<Name> name, |
| 4358 * const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 4359 * info.GetReturnValue().Set(v8_num(42)); |
| 4360 * } |
| 4361 * |
| 4362 * v8::Local<v8::FunctionTemplate> templ = |
| 4363 * v8::FunctionTemplate::New(isolate); |
| 4364 * templ->InstanceTemplate()->SetHandler( |
| 4365 * v8::NamedPropertyHandlerConfiguration(GetterCallback)); |
| 4366 * LocalContext env; |
| 4367 * env->Global() |
| 4368 * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) |
| 4369 * .ToLocalChecked() |
| 4370 * ->NewInstance(env.local()) |
| 4371 * .ToLocalChecked()) |
| 4372 * .FromJust(); |
| 4373 * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a"); |
| 4374 * CHECK(v8_num(42)->Equals(env.local(), result).FromJust()); |
| 4375 * \endcode |
| 4376 * |
| 4377 * See also `ObjectTemplate::SetNamedPropertyHandler`. |
4346 */ | 4378 */ |
4347 typedef void (*GenericNamedPropertyGetterCallback)( | 4379 typedef void (*GenericNamedPropertyGetterCallback)( |
4348 Local<Name> property, const PropertyCallbackInfo<Value>& info); | 4380 Local<Name> property, const PropertyCallbackInfo<Value>& info); |
4349 | 4381 |
4350 /** | 4382 /** |
4351 * Interceptor for set requests on an object. | 4383 * Interceptor for set requests on an object. |
4352 * | 4384 * |
4353 * Use `info.GetReturnValue()` to indicate whether the request was intercepted | 4385 * Use `info.GetReturnValue()` to indicate whether the request was intercepted |
4354 * or not. If the setter successfully intercepts the request, i.e., if the | 4386 * or not. If the setter successfully intercepts the request, i.e., if the |
4355 * request should not be further executed, call | 4387 * request should not be further executed, call |
(...skipping 4684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9040 */ | 9072 */ |
9041 | 9073 |
9042 | 9074 |
9043 } // namespace v8 | 9075 } // namespace v8 |
9044 | 9076 |
9045 | 9077 |
9046 #undef TYPE_CHECK | 9078 #undef TYPE_CHECK |
9047 | 9079 |
9048 | 9080 |
9049 #endif // INCLUDE_V8_H_ | 9081 #endif // INCLUDE_V8_H_ |
OLD | NEW |