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

Side by Side Diff: include/v8.h

Issue 2322673004: [api] Add documentation for IndexedPropertyCallbacks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4612 matching lines...) Expand 10 before | Expand all | Expand 10 after
4623 * env->Global() 4623 * env->Global()
4624 * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) 4624 * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
4625 * .ToLocalChecked() 4625 * .ToLocalChecked()
4626 * ->NewInstance(env.local()) 4626 * ->NewInstance(env.local())
4627 * .ToLocalChecked()) 4627 * .ToLocalChecked())
4628 * .FromJust(); 4628 * .FromJust();
4629 * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a"); 4629 * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
4630 * CHECK(v8_num(42)->Equals(env.local(), result).FromJust()); 4630 * CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
4631 * \endcode 4631 * \endcode
4632 * 4632 *
4633 * See also `ObjectTemplate::SetNamedPropertyHandler`. 4633 * See also `ObjectTemplate::SetHandler`.
4634 */ 4634 */
4635 typedef void (*GenericNamedPropertyGetterCallback)( 4635 typedef void (*GenericNamedPropertyGetterCallback)(
4636 Local<Name> property, const PropertyCallbackInfo<Value>& info); 4636 Local<Name> property, const PropertyCallbackInfo<Value>& info);
4637 4637
4638 /** 4638 /**
4639 * Interceptor for set requests on an object. 4639 * Interceptor for set requests on an object.
4640 * 4640 *
4641 * Use `info.GetReturnValue()` to indicate whether the request was intercepted 4641 * Use `info.GetReturnValue()` to indicate whether the request was intercepted
4642 * or not. If the setter successfully intercepts the request, i.e., if the 4642 * or not. If the setter successfully intercepts the request, i.e., if the
4643 * request should not be further executed, call 4643 * request should not be further executed, call
4644 * `info.GetReturnValue().Set(value)`. If the setter 4644 * `info.GetReturnValue().Set(value)`. If the setter
4645 * did not intercept the request, i.e., if the request should be handled as 4645 * did not intercept the request, i.e., if the request should be handled as
4646 * if no interceptor is present, do not not call `Set()`. 4646 * if no interceptor is present, do not not call `Set()`.
4647 * 4647 *
4648 * \param property The name of the property for which the request was 4648 * \param property The name of the property for which the request was
4649 * intercepted. 4649 * intercepted.
4650 * \param value The value which the property will have if the request 4650 * \param value The value which the property will have if the request
4651 * is not intercepted. 4651 * is not intercepted.
4652 * \param info Information about the intercepted request, such as 4652 * \param info Information about the intercepted request, such as
4653 * isolate, receiver, return value, or whether running in `'use strict'` mode. 4653 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4654 * See `PropertyCallbackInfo`. 4654 * See `PropertyCallbackInfo`.
4655 * 4655 *
4656 * See also 4656 * See also
4657 * `ObjectTemplate::SetNamedPropertyHandler.` 4657 * `ObjectTemplate::SetHandler.`
4658 */ 4658 */
4659 typedef void (*GenericNamedPropertySetterCallback)( 4659 typedef void (*GenericNamedPropertySetterCallback)(
4660 Local<Name> property, Local<Value> value, 4660 Local<Name> property, Local<Value> value,
4661 const PropertyCallbackInfo<Value>& info); 4661 const PropertyCallbackInfo<Value>& info);
4662 4662
4663 /** 4663 /**
4664 * Intercepts all requests that query the attributes of the 4664 * Intercepts all requests that query the attributes of the
4665 * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and 4665 * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and
4666 * defineProperty(). 4666 * defineProperty().
4667 * 4667 *
4668 * Use `info.GetReturnValue().Set(value)` to set the property attributes. The 4668 * Use `info.GetReturnValue().Set(value)` to set the property attributes. The
4669 * value is an interger encoding a `v8::PropertyAttribute`. 4669 * value is an interger encoding a `v8::PropertyAttribute`.
4670 * 4670 *
4671 * \param property The name of the property for which the request was 4671 * \param property The name of the property for which the request was
4672 * intercepted. 4672 * intercepted.
4673 * \param info Information about the intercepted request, such as 4673 * \param info Information about the intercepted request, such as
4674 * isolate, receiver, return value, or whether running in `'use strict'` mode. 4674 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4675 * See `PropertyCallbackInfo`. 4675 * See `PropertyCallbackInfo`.
4676 * 4676 *
4677 * \note Some functions query the property attributes internally, even though 4677 * \note Some functions query the property attributes internally, even though
4678 * they do not return the attributes. For example, `hasOwnProperty()` can 4678 * they do not return the attributes. For example, `hasOwnProperty()` can
4679 * trigger this interceptor depending on the state of the object. 4679 * trigger this interceptor depending on the state of the object.
4680 * 4680 *
4681 * See also 4681 * See also
4682 * `ObjectTemplate::SetNamedPropertyHandler.` 4682 * `ObjectTemplate::SetHandler.`
4683 */ 4683 */
4684 typedef void (*GenericNamedPropertyQueryCallback)( 4684 typedef void (*GenericNamedPropertyQueryCallback)(
4685 Local<Name> property, const PropertyCallbackInfo<Integer>& info); 4685 Local<Name> property, const PropertyCallbackInfo<Integer>& info);
4686 4686
4687 /** 4687 /**
4688 * Interceptor for delete requests on an object. 4688 * Interceptor for delete requests on an object.
4689 * 4689 *
4690 * Use `info.GetReturnValue()` to indicate whether the request was intercepted 4690 * Use `info.GetReturnValue()` to indicate whether the request was intercepted
4691 * or not. If the deleter successfully intercepts the request, i.e., if the 4691 * or not. If the deleter successfully intercepts the request, i.e., if the
4692 * request should not be further executed, call 4692 * request should not be further executed, call
4693 * `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is 4693 * `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
4694 * used as the return value of `delete`. 4694 * used as the return value of `delete`.
4695 * 4695 *
4696 * \param property The name of the property for which the request was 4696 * \param property The name of the property for which the request was
4697 * intercepted. 4697 * intercepted.
4698 * \param info Information about the intercepted request, such as 4698 * \param info Information about the intercepted request, such as
4699 * isolate, receiver, return value, or whether running in `'use strict'` mode. 4699 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4700 * See `PropertyCallbackInfo`. 4700 * See `PropertyCallbackInfo`.
4701 * 4701 *
4702 * \note If you need to mimic the behavior of `delete`, i.e., throw in strict 4702 * \note If you need to mimic the behavior of `delete`, i.e., throw in strict
4703 * mode instead of returning false, use `info.ShouldThrowOnError()` to determine 4703 * mode instead of returning false, use `info.ShouldThrowOnError()` to determine
4704 * if you are in strict mode. 4704 * if you are in strict mode.
4705 * 4705 *
4706 * See also `ObjectTemplate::SetNamedPropertyHandler.` 4706 * See also `ObjectTemplate::SetHandler.`
4707 */ 4707 */
4708 typedef void (*GenericNamedPropertyDeleterCallback)( 4708 typedef void (*GenericNamedPropertyDeleterCallback)(
4709 Local<Name> property, const PropertyCallbackInfo<Boolean>& info); 4709 Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
4710 4710
4711 4711
4712 /** 4712 /**
4713 * Returns an array containing the names of the properties the named 4713 * Returns an array containing the names of the properties the named
4714 * property getter intercepts. 4714 * property getter intercepts.
4715 */ 4715 */
4716 typedef void (*GenericNamedPropertyEnumeratorCallback)( 4716 typedef void (*GenericNamedPropertyEnumeratorCallback)(
(...skipping 10 matching lines...) Expand all
4727 * if no interceptor is present, do not not call `Set()`. 4727 * if no interceptor is present, do not not call `Set()`.
4728 * 4728 *
4729 * \param property The name of the property for which the request was 4729 * \param property The name of the property for which the request was
4730 * intercepted. 4730 * intercepted.
4731 * \param desc The property descriptor which is used to define the 4731 * \param desc The property descriptor which is used to define the
4732 * property if the request is not intercepted. 4732 * property if the request is not intercepted.
4733 * \param info Information about the intercepted request, such as 4733 * \param info Information about the intercepted request, such as
4734 * isolate, receiver, return value, or whether running in `'use strict'` mode. 4734 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4735 * See `PropertyCallbackInfo`. 4735 * See `PropertyCallbackInfo`.
4736 * 4736 *
4737 * See also `ObjectTemplate::SetNamedPropertyHandler`. 4737 * See also `ObjectTemplate::SetHandler`.
4738 */ 4738 */
4739 typedef void (*GenericNamedPropertyDefinerCallback)( 4739 typedef void (*GenericNamedPropertyDefinerCallback)(
4740 Local<Name> property, const PropertyDescriptor& desc, 4740 Local<Name> property, const PropertyDescriptor& desc,
4741 const PropertyCallbackInfo<Value>& info); 4741 const PropertyCallbackInfo<Value>& info);
4742 4742
4743 /** 4743 /**
4744 * Interceptor for getOwnPropertyDescriptor requests on an object. 4744 * Interceptor for getOwnPropertyDescriptor requests on an object.
4745 * 4745 *
4746 * Use `info.GetReturnValue().Set()` to set the return value of the 4746 * Use `info.GetReturnValue().Set()` to set the return value of the
4747 * intercepted request. The return value must be an object that 4747 * intercepted request. The return value must be an object that
4748 * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from 4748 * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from
4749 * `v8::Object::getOwnPropertyDescriptor`. 4749 * `v8::Object::getOwnPropertyDescriptor`.
4750 * 4750 *
4751 * \param property The name of the property for which the request was 4751 * \param property The name of the property for which the request was
4752 * intercepted. 4752 * intercepted.
4753 * \info Information about the intercepted request, such as 4753 * \info Information about the intercepted request, such as
4754 * isolate, receiver, return value, or whether running in `'use strict'` mode. 4754 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4755 * See `PropertyCallbackInfo`. 4755 * See `PropertyCallbackInfo`.
4756 * 4756 *
4757 * \note If GetOwnPropertyDescriptor is intercepted, it will 4757 * \note If GetOwnPropertyDescriptor is intercepted, it will
4758 * always return true, i.e., indicate that the property was found. 4758 * always return true, i.e., indicate that the property was found.
4759 * 4759 *
4760 * See also `ObjectTemplate::SetNamedPropertyHandler`. 4760 * See also `ObjectTemplate::SetHandler`.
4761 */ 4761 */
4762 typedef void (*GenericNamedPropertyDescriptorCallback)( 4762 typedef void (*GenericNamedPropertyDescriptorCallback)(
4763 Local<Name> property, const PropertyCallbackInfo<Value>& info); 4763 Local<Name> property, const PropertyCallbackInfo<Value>& info);
4764 4764
4765 /** 4765 /**
4766 * Returns the value of the property if the getter intercepts the 4766 * See `v8::GenericNamedPropertyGetterCallback`.
4767 * request. Otherwise, returns an empty handle.
4768 */ 4767 */
4769 typedef void (*IndexedPropertyGetterCallback)( 4768 typedef void (*IndexedPropertyGetterCallback)(
4770 uint32_t index, 4769 uint32_t index,
4771 const PropertyCallbackInfo<Value>& info); 4770 const PropertyCallbackInfo<Value>& info);
4772 4771
4773
4774 /** 4772 /**
4775 * Returns the value if the setter intercepts the request. 4773 * See `v8::GenericNamedPropertySetterCallback`.
4776 * Otherwise, returns an empty handle.
4777 */ 4774 */
4778 typedef void (*IndexedPropertySetterCallback)( 4775 typedef void (*IndexedPropertySetterCallback)(
4779 uint32_t index, 4776 uint32_t index,
4780 Local<Value> value, 4777 Local<Value> value,
4781 const PropertyCallbackInfo<Value>& info); 4778 const PropertyCallbackInfo<Value>& info);
4782 4779
4783
4784 /** 4780 /**
4785 * Returns a non-empty handle if the interceptor intercepts the request. 4781 * See `v8::GenericNamedPropertyQueryCallback`.
4786 * The result is an integer encoding property attributes.
4787 */ 4782 */
4788 typedef void (*IndexedPropertyQueryCallback)( 4783 typedef void (*IndexedPropertyQueryCallback)(
4789 uint32_t index, 4784 uint32_t index,
4790 const PropertyCallbackInfo<Integer>& info); 4785 const PropertyCallbackInfo<Integer>& info);
4791 4786
4792
4793 /** 4787 /**
4794 * Returns a non-empty handle if the deleter intercepts the request. 4788 * See `v8::GenericNamedPropertyDeleterCallback`.
4795 * The return value is true if the property could be deleted and false
4796 * otherwise.
4797 */ 4789 */
4798 typedef void (*IndexedPropertyDeleterCallback)( 4790 typedef void (*IndexedPropertyDeleterCallback)(
4799 uint32_t index, 4791 uint32_t index,
4800 const PropertyCallbackInfo<Boolean>& info); 4792 const PropertyCallbackInfo<Boolean>& info);
4801 4793
4802
4803 /** 4794 /**
4804 * Returns an array containing the indices of the properties the 4795 * See `v8::GenericNamedPropertyEnumeratorCallback`.
4805 * indexed property getter intercepts.
4806 */ 4796 */
4807 typedef void (*IndexedPropertyEnumeratorCallback)( 4797 typedef void (*IndexedPropertyEnumeratorCallback)(
4808 const PropertyCallbackInfo<Array>& info); 4798 const PropertyCallbackInfo<Array>& info);
4809 4799
4800 /**
4801 * See `v8::GenericNamedPropertyDefinerCallback`.
4802 */
4810 typedef void (*IndexedPropertyDefinerCallback)( 4803 typedef void (*IndexedPropertyDefinerCallback)(
4811 uint32_t index, const PropertyDescriptor& desc, 4804 uint32_t index, const PropertyDescriptor& desc,
4812 const PropertyCallbackInfo<Value>& info); 4805 const PropertyCallbackInfo<Value>& info);
4813 4806
4807 /**
4808 * See `v8::GenericNamedPropertyDescriptorCallback`.
4809 */
4814 typedef void (*IndexedPropertyDescriptorCallback)( 4810 typedef void (*IndexedPropertyDescriptorCallback)(
4815 uint32_t index, const PropertyCallbackInfo<Value>& info); 4811 uint32_t index, const PropertyCallbackInfo<Value>& info);
4816 4812
4817 /** 4813 /**
4818 * Access type specification. 4814 * Access type specification.
4819 */ 4815 */
4820 enum AccessType { 4816 enum AccessType {
4821 ACCESS_GET, 4817 ACCESS_GET,
4822 ACCESS_SET, 4818 ACCESS_SET,
4823 ACCESS_HAS, 4819 ACCESS_HAS,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
5054 // chain, i.e., only call into interceptor for properties that do not exist. 5050 // chain, i.e., only call into interceptor for properties that do not exist.
5055 // Currently only valid for named interceptors. 5051 // Currently only valid for named interceptors.
5056 kNonMasking = 1 << 1, 5052 kNonMasking = 1 << 1,
5057 // Will not call into interceptor for symbol lookup. Only meaningful for 5053 // Will not call into interceptor for symbol lookup. Only meaningful for
5058 // named interceptors. 5054 // named interceptors.
5059 kOnlyInterceptStrings = 1 << 2, 5055 kOnlyInterceptStrings = 1 << 2,
5060 }; 5056 };
5061 5057
5062 struct NamedPropertyHandlerConfiguration { 5058 struct NamedPropertyHandlerConfiguration {
5063 NamedPropertyHandlerConfiguration( 5059 NamedPropertyHandlerConfiguration(
5064 /** Note: getter is required **/ 5060 /** Note: getter is required */
5065 GenericNamedPropertyGetterCallback getter = 0, 5061 GenericNamedPropertyGetterCallback getter = 0,
5066 GenericNamedPropertySetterCallback setter = 0, 5062 GenericNamedPropertySetterCallback setter = 0,
5067 GenericNamedPropertyQueryCallback query = 0, 5063 GenericNamedPropertyQueryCallback query = 0,
5068 GenericNamedPropertyDeleterCallback deleter = 0, 5064 GenericNamedPropertyDeleterCallback deleter = 0,
5069 GenericNamedPropertyEnumeratorCallback enumerator = 0, 5065 GenericNamedPropertyEnumeratorCallback enumerator = 0,
5070 Local<Value> data = Local<Value>(), 5066 Local<Value> data = Local<Value>(),
5071 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) 5067 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
5072 : getter(getter), 5068 : getter(getter),
5073 setter(setter), 5069 setter(setter),
5074 query(query), 5070 query(query),
(...skipping 30 matching lines...) Expand all
5105 GenericNamedPropertyEnumeratorCallback enumerator; 5101 GenericNamedPropertyEnumeratorCallback enumerator;
5106 GenericNamedPropertyDefinerCallback definer; 5102 GenericNamedPropertyDefinerCallback definer;
5107 GenericNamedPropertyDescriptorCallback descriptor; 5103 GenericNamedPropertyDescriptorCallback descriptor;
5108 Local<Value> data; 5104 Local<Value> data;
5109 PropertyHandlerFlags flags; 5105 PropertyHandlerFlags flags;
5110 }; 5106 };
5111 5107
5112 5108
5113 struct IndexedPropertyHandlerConfiguration { 5109 struct IndexedPropertyHandlerConfiguration {
5114 IndexedPropertyHandlerConfiguration( 5110 IndexedPropertyHandlerConfiguration(
5115 /** Note: getter is required **/ 5111 /** Note: getter is required */
5116 IndexedPropertyGetterCallback getter = 0, 5112 IndexedPropertyGetterCallback getter = 0,
5117 IndexedPropertySetterCallback setter = 0, 5113 IndexedPropertySetterCallback setter = 0,
5118 IndexedPropertyQueryCallback query = 0, 5114 IndexedPropertyQueryCallback query = 0,
5119 IndexedPropertyDeleterCallback deleter = 0, 5115 IndexedPropertyDeleterCallback deleter = 0,
5120 IndexedPropertyEnumeratorCallback enumerator = 0, 5116 IndexedPropertyEnumeratorCallback enumerator = 0,
5121 Local<Value> data = Local<Value>(), 5117 Local<Value> data = Local<Value>(),
5122 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) 5118 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
5123 : getter(getter), 5119 : getter(getter),
5124 setter(setter), 5120 setter(setter),
5125 query(query), 5121 query(query),
(...skipping 4367 matching lines...) Expand 10 before | Expand all | Expand 10 after
9493 */ 9489 */
9494 9490
9495 9491
9496 } // namespace v8 9492 } // namespace v8
9497 9493
9498 9494
9499 #undef TYPE_CHECK 9495 #undef TYPE_CHECK
9500 9496
9501 9497
9502 #endif // INCLUDE_V8_H_ 9498 #endif // INCLUDE_V8_H_
OLDNEW
« 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