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

Side by Side Diff: include/v8.h

Issue 2272383002: [api] Add interceptor for defineProperty(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@DefineProperty
Patch Set: Add test for intercepting Object.freeze(). 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 | src/api.cc » ('j') | src/objects.cc » ('J')
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 4420 matching lines...) Expand 10 before | Expand all | Expand 10 after
4431 Local<Name> property, const PropertyCallbackInfo<Boolean>& info); 4431 Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
4432 4432
4433 4433
4434 /** 4434 /**
4435 * Returns an array containing the names of the properties the named 4435 * Returns an array containing the names of the properties the named
4436 * property getter intercepts. 4436 * property getter intercepts.
4437 */ 4437 */
4438 typedef void (*GenericNamedPropertyEnumeratorCallback)( 4438 typedef void (*GenericNamedPropertyEnumeratorCallback)(
4439 const PropertyCallbackInfo<Array>& info); 4439 const PropertyCallbackInfo<Array>& info);
4440 4440
4441 /**
4442 * Interceptor for defineProperty requests on an object.
4443 *
4444 * Use `info.GetReturnValue()` to indicate whether the request was intercepted
4445 * or not. If the definer successfully intercepts the request, i.e., if the
4446 * request should not be further executed, call
4447 * `info.GetReturnValue().Set(value)`. If the definer
4448 * did not intercept the request, i.e., if the request should be handled as
4449 * if no interceptor is present, do not not call `Set()`.
4450 *
4451 * \param property The name of the property for which the request was
4452 * intercepted.
4453 * \param desc The property descriptor which will be used to define the
4454 * property if the request is not intercepted.
4455 * \param info Information about the intercepted request, such as
4456 * isolate, receiver, return value, or whether running in `'use strict'` mode.
4457 * See `PropertyCallbackInfo`.
4458 *
4459 * See also `ObjectTemplate::SetNamedPropertyHandler`.
4460 */
4461 typedef void (*GenericNamedPropertyDefinerCallback)(
4462 Local<Name> key, const PropertyDescriptor& desc,
4463 const PropertyCallbackInfo<Value>& info);
4441 4464
4442 /** 4465 /**
4443 * Returns the value of the property if the getter intercepts the 4466 * Returns the value of the property if the getter intercepts the
4444 * request. Otherwise, returns an empty handle. 4467 * request. Otherwise, returns an empty handle.
4445 */ 4468 */
4446 typedef void (*IndexedPropertyGetterCallback)( 4469 typedef void (*IndexedPropertyGetterCallback)(
4447 uint32_t index, 4470 uint32_t index,
4448 const PropertyCallbackInfo<Value>& info); 4471 const PropertyCallbackInfo<Value>& info);
4449 4472
4450 4473
(...skipping 26 matching lines...) Expand all
4477 const PropertyCallbackInfo<Boolean>& info); 4500 const PropertyCallbackInfo<Boolean>& info);
4478 4501
4479 4502
4480 /** 4503 /**
4481 * Returns an array containing the indices of the properties the 4504 * Returns an array containing the indices of the properties the
4482 * indexed property getter intercepts. 4505 * indexed property getter intercepts.
4483 */ 4506 */
4484 typedef void (*IndexedPropertyEnumeratorCallback)( 4507 typedef void (*IndexedPropertyEnumeratorCallback)(
4485 const PropertyCallbackInfo<Array>& info); 4508 const PropertyCallbackInfo<Array>& info);
4486 4509
4510 typedef void (*IndexedPropertyDefinerCallback)(
4511 uint32_t index, const PropertyDescriptor& desc,
4512 const PropertyCallbackInfo<Value>& info);
4487 4513
4488 /** 4514 /**
4489 * Access type specification. 4515 * Access type specification.
4490 */ 4516 */
4491 enum AccessType { 4517 enum AccessType {
4492 ACCESS_GET, 4518 ACCESS_GET,
4493 ACCESS_SET, 4519 ACCESS_SET,
4494 ACCESS_HAS, 4520 ACCESS_HAS,
4495 ACCESS_DELETE, 4521 ACCESS_DELETE,
4496 ACCESS_KEYS 4522 ACCESS_KEYS
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
4739 GenericNamedPropertyQueryCallback query = 0, 4765 GenericNamedPropertyQueryCallback query = 0,
4740 GenericNamedPropertyDeleterCallback deleter = 0, 4766 GenericNamedPropertyDeleterCallback deleter = 0,
4741 GenericNamedPropertyEnumeratorCallback enumerator = 0, 4767 GenericNamedPropertyEnumeratorCallback enumerator = 0,
4742 Local<Value> data = Local<Value>(), 4768 Local<Value> data = Local<Value>(),
4743 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) 4769 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4744 : getter(getter), 4770 : getter(getter),
4745 setter(setter), 4771 setter(setter),
4746 query(query), 4772 query(query),
4747 deleter(deleter), 4773 deleter(deleter),
4748 enumerator(enumerator), 4774 enumerator(enumerator),
4775 definer(0),
4749 data(data), 4776 data(data),
4750 flags(flags) {} 4777 flags(flags) {}
4751 4778
4779 NamedPropertyHandlerConfiguration(
4780 GenericNamedPropertyGetterCallback getter,
4781 GenericNamedPropertySetterCallback setter,
4782 GenericNamedPropertyQueryCallback query,
4783 GenericNamedPropertyDeleterCallback deleter,
4784 GenericNamedPropertyEnumeratorCallback enumerator,
4785 GenericNamedPropertyDefinerCallback definer,
4786 Local<Value> data = Local<Value>(),
4787 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4788 : getter(getter),
4789 setter(setter),
4790 query(query),
4791 deleter(deleter),
4792 enumerator(enumerator),
4793 definer(definer),
4794 data(data),
4795 flags(flags) {}
4796
4752 GenericNamedPropertyGetterCallback getter; 4797 GenericNamedPropertyGetterCallback getter;
4753 GenericNamedPropertySetterCallback setter; 4798 GenericNamedPropertySetterCallback setter;
4754 GenericNamedPropertyQueryCallback query; 4799 GenericNamedPropertyQueryCallback query;
4755 GenericNamedPropertyDeleterCallback deleter; 4800 GenericNamedPropertyDeleterCallback deleter;
4756 GenericNamedPropertyEnumeratorCallback enumerator; 4801 GenericNamedPropertyEnumeratorCallback enumerator;
4802 GenericNamedPropertyDefinerCallback definer;
4757 Local<Value> data; 4803 Local<Value> data;
4758 PropertyHandlerFlags flags; 4804 PropertyHandlerFlags flags;
4759 }; 4805 };
4760 4806
4761 4807
4762 struct IndexedPropertyHandlerConfiguration { 4808 struct IndexedPropertyHandlerConfiguration {
4763 IndexedPropertyHandlerConfiguration( 4809 IndexedPropertyHandlerConfiguration(
4764 /** Note: getter is required **/ 4810 /** Note: getter is required **/
4765 IndexedPropertyGetterCallback getter = 0, 4811 IndexedPropertyGetterCallback getter = 0,
4766 IndexedPropertySetterCallback setter = 0, 4812 IndexedPropertySetterCallback setter = 0,
4767 IndexedPropertyQueryCallback query = 0, 4813 IndexedPropertyQueryCallback query = 0,
4768 IndexedPropertyDeleterCallback deleter = 0, 4814 IndexedPropertyDeleterCallback deleter = 0,
4769 IndexedPropertyEnumeratorCallback enumerator = 0, 4815 IndexedPropertyEnumeratorCallback enumerator = 0,
4770 Local<Value> data = Local<Value>(), 4816 Local<Value> data = Local<Value>(),
4771 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) 4817 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4772 : getter(getter), 4818 : getter(getter),
4773 setter(setter), 4819 setter(setter),
4774 query(query), 4820 query(query),
4775 deleter(deleter), 4821 deleter(deleter),
4776 enumerator(enumerator), 4822 enumerator(enumerator),
4823 definer(0),
4777 data(data), 4824 data(data),
4778 flags(flags) {} 4825 flags(flags) {}
4779 4826
4827 IndexedPropertyHandlerConfiguration(
4828 IndexedPropertyGetterCallback getter,
4829 IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query,
4830 IndexedPropertyDeleterCallback deleter,
4831 IndexedPropertyEnumeratorCallback enumerator,
4832 IndexedPropertyDefinerCallback definer,
4833 Local<Value> data = Local<Value>(),
4834 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
4835 : getter(getter),
4836 setter(setter),
4837 query(query),
4838 deleter(deleter),
4839 enumerator(enumerator),
4840 definer(0),
4841 data(data),
4842 flags(flags) {}
4843
4780 IndexedPropertyGetterCallback getter; 4844 IndexedPropertyGetterCallback getter;
4781 IndexedPropertySetterCallback setter; 4845 IndexedPropertySetterCallback setter;
4782 IndexedPropertyQueryCallback query; 4846 IndexedPropertyQueryCallback query;
4783 IndexedPropertyDeleterCallback deleter; 4847 IndexedPropertyDeleterCallback deleter;
4784 IndexedPropertyEnumeratorCallback enumerator; 4848 IndexedPropertyEnumeratorCallback enumerator;
4849 IndexedPropertyDefinerCallback definer;
4785 Local<Value> data; 4850 Local<Value> data;
4786 PropertyHandlerFlags flags; 4851 PropertyHandlerFlags flags;
4787 }; 4852 };
4788 4853
4789 4854
4790 /** 4855 /**
4791 * An ObjectTemplate is used to create objects at runtime. 4856 * An ObjectTemplate is used to create objects at runtime.
4792 * 4857 *
4793 * Properties added to an ObjectTemplate are added to each object 4858 * Properties added to an ObjectTemplate are added to each object
4794 * created from the ObjectTemplate. 4859 * created from the ObjectTemplate.
(...skipping 4311 matching lines...) Expand 10 before | Expand all | Expand 10 after
9106 */ 9171 */
9107 9172
9108 9173
9109 } // namespace v8 9174 } // namespace v8
9110 9175
9111 9176
9112 #undef TYPE_CHECK 9177 #undef TYPE_CHECK
9113 9178
9114 9179
9115 #endif // INCLUDE_V8_H_ 9180 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698