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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 class Maybe; | 89 class Maybe; |
90 class Name; | 90 class Name; |
91 class Number; | 91 class Number; |
92 class NumberObject; | 92 class NumberObject; |
93 class Object; | 93 class Object; |
94 class ObjectOperationDescriptor; | 94 class ObjectOperationDescriptor; |
95 class ObjectTemplate; | 95 class ObjectTemplate; |
96 class Platform; | 96 class Platform; |
97 class Primitive; | 97 class Primitive; |
98 class Promise; | 98 class Promise; |
| 99 class PropertyDescriptor; |
99 class Proxy; | 100 class Proxy; |
100 class RawOperationDescriptor; | 101 class RawOperationDescriptor; |
101 class Script; | 102 class Script; |
102 class SharedArrayBuffer; | 103 class SharedArrayBuffer; |
103 class Signature; | 104 class Signature; |
104 class StartupData; | 105 class StartupData; |
105 class StackFrame; | 106 class StackFrame; |
106 class StackTrace; | 107 class StackTrace; |
107 class String; | 108 class String; |
108 class StringObject; | 109 class StringObject; |
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2803 // Implements DefineOwnProperty. | 2804 // Implements DefineOwnProperty. |
2804 // | 2805 // |
2805 // In general, CreateDataProperty will be faster, however, does not allow | 2806 // In general, CreateDataProperty will be faster, however, does not allow |
2806 // for specifying attributes. | 2807 // for specifying attributes. |
2807 // | 2808 // |
2808 // Returns true on success. | 2809 // Returns true on success. |
2809 V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty( | 2810 V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty( |
2810 Local<Context> context, Local<Name> key, Local<Value> value, | 2811 Local<Context> context, Local<Name> key, Local<Value> value, |
2811 PropertyAttribute attributes = None); | 2812 PropertyAttribute attributes = None); |
2812 | 2813 |
| 2814 // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4. |
| 2815 // |
| 2816 // The defineProperty function is used to add an own property or |
| 2817 // update the attributes of an existing own property of an object. |
| 2818 // |
| 2819 // Both data and accessor descriptors can be used. |
| 2820 // |
| 2821 // In general, CreateDataProperty is faster, however, does not allow |
| 2822 // for specifying attributes or an accessor descriptor. |
| 2823 // |
| 2824 // The PropertyDescriptor can change when redefining a property. |
| 2825 // |
| 2826 // Returns true on success. |
| 2827 V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty( |
| 2828 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor); |
| 2829 |
2813 // Sets an own property on this object bypassing interceptors and | 2830 // Sets an own property on this object bypassing interceptors and |
2814 // overriding accessors or read-only properties. | 2831 // overriding accessors or read-only properties. |
2815 // | 2832 // |
2816 // Note that if the object has an interceptor the property will be set | 2833 // Note that if the object has an interceptor the property will be set |
2817 // locally, but since the interceptor takes precedence the local property | 2834 // locally, but since the interceptor takes precedence the local property |
2818 // will only be returned if the interceptor doesn't return a value. | 2835 // will only be returned if the interceptor doesn't return a value. |
2819 // | 2836 // |
2820 // Note also that this only works for named properties. | 2837 // Note also that this only works for named properties. |
2821 V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty", | 2838 V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty", |
2822 bool ForceSet(Local<Value> key, Local<Value> value, | 2839 bool ForceSet(Local<Value> key, Local<Value> value, |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3620 */ | 3637 */ |
3621 bool HasHandler(); | 3638 bool HasHandler(); |
3622 | 3639 |
3623 V8_INLINE static Promise* Cast(Value* obj); | 3640 V8_INLINE static Promise* Cast(Value* obj); |
3624 | 3641 |
3625 private: | 3642 private: |
3626 Promise(); | 3643 Promise(); |
3627 static void CheckCast(Value* obj); | 3644 static void CheckCast(Value* obj); |
3628 }; | 3645 }; |
3629 | 3646 |
| 3647 /** |
| 3648 * An instance of a Property Descriptor, see Ecma-262 6.2.4. |
| 3649 * |
| 3650 * Properties in a descriptor are present or absent. If you do not set |
| 3651 * `enumerable`, `configurable`, and `writable`, they are absent. If `value`, |
| 3652 * `get`, or `set` are absent, but you must specify them in the constructor, use |
| 3653 * empty handles. |
| 3654 * |
| 3655 * Accessors `get` and `set` must be callable or undefined if they are present. |
| 3656 * |
| 3657 * \note Only query properties if they are present, i.e., call `x()` only if |
| 3658 * `has_x()` returns true. |
| 3659 * |
| 3660 * \code |
| 3661 * // var desc = {writable: false} |
| 3662 * v8::PropertyDescriptor d(Local<Value>()), false); |
| 3663 * d.value(); // error, value not set |
| 3664 * if (d.has_writable()) { |
| 3665 * d.writable(); // false |
| 3666 * } |
| 3667 * |
| 3668 * // var desc = {value: undefined} |
| 3669 * v8::PropertyDescriptor d(v8::Undefined(isolate)); |
| 3670 * |
| 3671 * // var desc = {get: undefined} |
| 3672 * v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>())); |
| 3673 * \endcode |
| 3674 */ |
| 3675 class V8_EXPORT PropertyDescriptor { |
| 3676 public: |
| 3677 // GenericDescriptor |
| 3678 PropertyDescriptor(); |
| 3679 |
| 3680 // DataDescriptor |
| 3681 PropertyDescriptor(Local<Value> value); |
| 3682 |
| 3683 // DataDescriptor with writable property |
| 3684 PropertyDescriptor(Local<Value> value, bool writable); |
| 3685 |
| 3686 // AccessorDescriptor |
| 3687 PropertyDescriptor(Local<Value> get, Local<Value> set); |
| 3688 |
| 3689 ~PropertyDescriptor(); |
| 3690 |
| 3691 Local<Value> value() const; |
| 3692 bool has_value() const; |
| 3693 |
| 3694 Local<Value> get() const; |
| 3695 bool has_get() const; |
| 3696 Local<Value> set() const; |
| 3697 bool has_set() const; |
| 3698 |
| 3699 void set_enumerable(bool enumerable); |
| 3700 bool enumerable() const; |
| 3701 bool has_enumerable() const; |
| 3702 |
| 3703 void set_configurable(bool configurable); |
| 3704 bool configurable() const; |
| 3705 bool has_configurable() const; |
| 3706 |
| 3707 bool writable() const; |
| 3708 bool has_writable() const; |
| 3709 |
| 3710 struct PrivateData; |
| 3711 PrivateData* get_private() const { return private_; } |
| 3712 |
| 3713 PropertyDescriptor(const PropertyDescriptor&) = delete; |
| 3714 void operator=(const PropertyDescriptor&) = delete; |
| 3715 |
| 3716 private: |
| 3717 PrivateData* private_; |
| 3718 }; |
3630 | 3719 |
3631 /** | 3720 /** |
3632 * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, | 3721 * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, |
3633 * 26.2.1). | 3722 * 26.2.1). |
3634 */ | 3723 */ |
3635 class V8_EXPORT Proxy : public Object { | 3724 class V8_EXPORT Proxy : public Object { |
3636 public: | 3725 public: |
3637 Local<Object> GetTarget(); | 3726 Local<Object> GetTarget(); |
3638 Local<Value> GetHandler(); | 3727 Local<Value> GetHandler(); |
3639 bool IsRevoked(); | 3728 bool IsRevoked(); |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 /** | 4574 /** |
4486 * Returns an array containing the names of the properties the named | 4575 * Returns an array containing the names of the properties the named |
4487 * property getter intercepts. | 4576 * property getter intercepts. |
4488 */ | 4577 */ |
4489 typedef void (*NamedPropertyEnumeratorCallback)( | 4578 typedef void (*NamedPropertyEnumeratorCallback)( |
4490 const PropertyCallbackInfo<Array>& info); | 4579 const PropertyCallbackInfo<Array>& info); |
4491 | 4580 |
4492 | 4581 |
4493 // TODO(dcarney): Deprecate and remove previous typedefs, and replace | 4582 // TODO(dcarney): Deprecate and remove previous typedefs, and replace |
4494 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. | 4583 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. |
| 4584 |
4495 /** | 4585 /** |
4496 * Interceptor for get requests on an object. | 4586 * Interceptor for get requests on an object. |
4497 * | 4587 * |
4498 * Use `info.GetReturnValue().Set()` to set the return value of the | 4588 * Use `info.GetReturnValue().Set()` to set the return value of the |
4499 * intercepted get request. | 4589 * intercepted get request. |
4500 * | 4590 * |
4501 * \param property The name of the property for which the request was | 4591 * \param property The name of the property for which the request was |
4502 * intercepted. | 4592 * intercepted. |
4503 * \param info Information about the intercepted request, such as | 4593 * \param info Information about the intercepted request, such as |
4504 * isolate, receiver, return value, or whether running in `'use strict`' mode. | 4594 * isolate, receiver, return value, or whether running in `'use strict`' mode. |
(...skipping 4758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9263 */ | 9353 */ |
9264 | 9354 |
9265 | 9355 |
9266 } // namespace v8 | 9356 } // namespace v8 |
9267 | 9357 |
9268 | 9358 |
9269 #undef TYPE_CHECK | 9359 #undef TYPE_CHECK |
9270 | 9360 |
9271 | 9361 |
9272 #endif // INCLUDE_V8_H_ | 9362 #endif // INCLUDE_V8_H_ |
OLD | NEW |