Chromium Code Reviews| 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 3527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3538 | 3538 |
| 3539 | 3539 |
| 3540 /** | 3540 /** |
| 3541 * Returns an array containing the names of the properties the named | 3541 * Returns an array containing the names of the properties the named |
| 3542 * property getter intercepts. | 3542 * property getter intercepts. |
| 3543 */ | 3543 */ |
| 3544 typedef void (*NamedPropertyEnumeratorCallback)( | 3544 typedef void (*NamedPropertyEnumeratorCallback)( |
| 3545 const PropertyCallbackInfo<Array>& info); | 3545 const PropertyCallbackInfo<Array>& info); |
| 3546 | 3546 |
| 3547 | 3547 |
| 3548 // TODO(dcarney): Deprecate and remove previous typedefs, and replace | |
| 3549 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. | |
| 3550 /** | |
| 3551 * GenericNamedProperty[Getter|Setter] are used as interceptors on object. | |
| 3552 * See ObjectTemplate::SetNamedPropertyHandler. | |
| 3553 */ | |
| 3554 typedef void (*GenericNamedPropertyGetterCallback)( | |
| 3555 Local<Name> property, const PropertyCallbackInfo<Value>& info); | |
| 3556 | |
| 3557 | |
| 3558 /** | |
| 3559 * Returns the value if the setter intercepts the request. | |
| 3560 * Otherwise, returns an empty handle. | |
| 3561 */ | |
| 3562 typedef void (*GenericNamedPropertySetterCallback)( | |
| 3563 Local<Name> property, Local<Value> value, | |
| 3564 const PropertyCallbackInfo<Value>& info); | |
| 3565 | |
| 3566 | |
| 3567 /** | |
| 3568 * Returns a non-empty handle if the interceptor intercepts the request. | |
| 3569 * The result is an integer encoding property attributes (like v8::None, | |
| 3570 * v8::DontEnum, etc.) | |
| 3571 */ | |
| 3572 typedef void (*GenericNamedPropertyQueryCallback)( | |
| 3573 Local<Name> property, const PropertyCallbackInfo<Integer>& info); | |
| 3574 | |
| 3575 | |
| 3576 /** | |
| 3577 * Returns a non-empty handle if the deleter intercepts the request. | |
| 3578 * The return value is true if the property could be deleted and false | |
| 3579 * otherwise. | |
| 3580 */ | |
| 3581 typedef void (*GenericNamedPropertyDeleterCallback)( | |
| 3582 Local<Name> property, const PropertyCallbackInfo<Boolean>& info); | |
| 3583 | |
| 3584 | |
| 3585 /** | |
| 3586 * Returns an array containing the names of the properties the named | |
| 3587 * property getter intercepts. | |
| 3588 */ | |
| 3589 typedef void (*GenericNamedPropertyEnumeratorCallback)( | |
| 3590 const PropertyCallbackInfo<Array>& info); | |
| 3591 | |
| 3592 | |
| 3548 /** | 3593 /** |
| 3549 * Returns the value of the property if the getter intercepts the | 3594 * Returns the value of the property if the getter intercepts the |
| 3550 * request. Otherwise, returns an empty handle. | 3595 * request. Otherwise, returns an empty handle. |
| 3551 */ | 3596 */ |
| 3552 typedef void (*IndexedPropertyGetterCallback)( | 3597 typedef void (*IndexedPropertyGetterCallback)( |
| 3553 uint32_t index, | 3598 uint32_t index, |
| 3554 const PropertyCallbackInfo<Value>& info); | 3599 const PropertyCallbackInfo<Value>& info); |
| 3555 | 3600 |
| 3556 | 3601 |
| 3557 /** | 3602 /** |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3790 */ | 3835 */ |
| 3791 bool HasInstance(Handle<Value> object); | 3836 bool HasInstance(Handle<Value> object); |
| 3792 | 3837 |
| 3793 private: | 3838 private: |
| 3794 FunctionTemplate(); | 3839 FunctionTemplate(); |
| 3795 friend class Context; | 3840 friend class Context; |
| 3796 friend class ObjectTemplate; | 3841 friend class ObjectTemplate; |
| 3797 }; | 3842 }; |
| 3798 | 3843 |
| 3799 | 3844 |
| 3845 struct NamedPropertyHandlerConfiguration { | |
| 3846 NamedPropertyHandlerConfiguration( | |
| 3847 /** Note: getter is required **/ | |
| 3848 GenericNamedPropertyGetterCallback getter = 0, | |
| 3849 GenericNamedPropertySetterCallback setter = 0, | |
| 3850 GenericNamedPropertyQueryCallback query = 0, | |
| 3851 GenericNamedPropertyDeleterCallback deleter = 0, | |
| 3852 GenericNamedPropertyEnumeratorCallback enumerator = 0, | |
| 3853 Handle<Value> data = Handle<Value>()) | |
| 3854 : getter_(getter), | |
| 3855 setter_(setter), | |
| 3856 query_(query), | |
| 3857 deleter_(deleter), | |
| 3858 enumerator_(enumerator), | |
| 3859 data_(data) {} | |
| 3860 | |
| 3861 GenericNamedPropertyGetterCallback getter_; | |
|
rossberg
2014/11/26 15:03:27
Nit: no trailing '_' for public struct members.
dcarney
2014/11/26 15:26:54
Done.
| |
| 3862 GenericNamedPropertySetterCallback setter_; | |
| 3863 GenericNamedPropertyQueryCallback query_; | |
| 3864 GenericNamedPropertyDeleterCallback deleter_; | |
| 3865 GenericNamedPropertyEnumeratorCallback enumerator_; | |
| 3866 Handle<Value> data_; | |
| 3867 }; | |
| 3868 | |
| 3869 | |
| 3800 /** | 3870 /** |
| 3801 * An ObjectTemplate is used to create objects at runtime. | 3871 * An ObjectTemplate is used to create objects at runtime. |
| 3802 * | 3872 * |
| 3803 * Properties added to an ObjectTemplate are added to each object | 3873 * Properties added to an ObjectTemplate are added to each object |
| 3804 * created from the ObjectTemplate. | 3874 * created from the ObjectTemplate. |
| 3805 */ | 3875 */ |
| 3806 class V8_EXPORT ObjectTemplate : public Template { | 3876 class V8_EXPORT ObjectTemplate : public Template { |
| 3807 public: | 3877 public: |
| 3808 /** Creates an ObjectTemplate. */ | 3878 /** Creates an ObjectTemplate. */ |
| 3809 static Local<ObjectTemplate> New(Isolate* isolate); | 3879 static Local<ObjectTemplate> New(Isolate* isolate); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3859 Handle<AccessorSignature> signature = | 3929 Handle<AccessorSignature> signature = |
| 3860 Handle<AccessorSignature>()); | 3930 Handle<AccessorSignature>()); |
| 3861 | 3931 |
| 3862 /** | 3932 /** |
| 3863 * Sets a named property handler on the object template. | 3933 * Sets a named property handler on the object template. |
| 3864 * | 3934 * |
| 3865 * Whenever a property whose name is a string is accessed on objects created | 3935 * Whenever a property whose name is a string is accessed on objects created |
| 3866 * from this object template, the provided callback is invoked instead of | 3936 * from this object template, the provided callback is invoked instead of |
| 3867 * accessing the property directly on the JavaScript object. | 3937 * accessing the property directly on the JavaScript object. |
| 3868 * | 3938 * |
| 3939 * Note that new code should use the second version that can intercept | |
| 3940 * symbol-named properties as well as string-named properties. | |
| 3941 * | |
| 3869 * \param getter The callback to invoke when getting a property. | 3942 * \param getter The callback to invoke when getting a property. |
| 3870 * \param setter The callback to invoke when setting a property. | 3943 * \param setter The callback to invoke when setting a property. |
| 3871 * \param query The callback to invoke to check if a property is present, | 3944 * \param query The callback to invoke to check if a property is present, |
| 3872 * and if present, get its attributes. | 3945 * and if present, get its attributes. |
| 3873 * \param deleter The callback to invoke when deleting a property. | 3946 * \param deleter The callback to invoke when deleting a property. |
| 3874 * \param enumerator The callback to invoke to enumerate all the named | 3947 * \param enumerator The callback to invoke to enumerate all the named |
| 3875 * properties of an object. | 3948 * properties of an object. |
| 3876 * \param data A piece of data that will be passed to the callbacks | 3949 * \param data A piece of data that will be passed to the callbacks |
| 3877 * whenever they are invoked. | 3950 * whenever they are invoked. |
| 3878 */ | 3951 */ |
| 3879 void SetNamedPropertyHandler( | 3952 void SetNamedPropertyHandler( |
| 3880 NamedPropertyGetterCallback getter, | 3953 NamedPropertyGetterCallback getter, |
| 3881 NamedPropertySetterCallback setter = 0, | 3954 NamedPropertySetterCallback setter = 0, |
| 3882 NamedPropertyQueryCallback query = 0, | 3955 NamedPropertyQueryCallback query = 0, |
| 3883 NamedPropertyDeleterCallback deleter = 0, | 3956 NamedPropertyDeleterCallback deleter = 0, |
| 3884 NamedPropertyEnumeratorCallback enumerator = 0, | 3957 NamedPropertyEnumeratorCallback enumerator = 0, |
| 3885 Handle<Value> data = Handle<Value>()); | 3958 Handle<Value> data = Handle<Value>()); |
| 3959 void SetHandler(const NamedPropertyHandlerConfiguration& configuration); | |
| 3886 | 3960 |
| 3887 /** | 3961 /** |
| 3888 * Sets an indexed property handler on the object template. | 3962 * Sets an indexed property handler on the object template. |
| 3889 * | 3963 * |
| 3890 * Whenever an indexed property is accessed on objects created from | 3964 * Whenever an indexed property is accessed on objects created from |
| 3891 * this object template, the provided callback is invoked instead of | 3965 * this object template, the provided callback is invoked instead of |
| 3892 * accessing the property directly on the JavaScript object. | 3966 * accessing the property directly on the JavaScript object. |
| 3893 * | 3967 * |
| 3894 * \param getter The callback to invoke when getting a property. | 3968 * \param getter The callback to invoke when getting a property. |
| 3895 * \param setter The callback to invoke when setting a property. | 3969 * \param setter The callback to invoke when setting a property. |
| (...skipping 3483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7379 */ | 7453 */ |
| 7380 | 7454 |
| 7381 | 7455 |
| 7382 } // namespace v8 | 7456 } // namespace v8 |
| 7383 | 7457 |
| 7384 | 7458 |
| 7385 #undef TYPE_CHECK | 7459 #undef TYPE_CHECK |
| 7386 | 7460 |
| 7387 | 7461 |
| 7388 #endif // V8_H_ | 7462 #endif // V8_H_ |
| OLD | NEW |