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

Side by Side Diff: include/v8.h

Issue 2244123005: [api] Add PropertyDescriptor and DefineProperty(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename test variables Created 4 years, 4 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') | 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 class Maybe; 88 class Maybe;
89 class Name; 89 class Name;
90 class Number; 90 class Number;
91 class NumberObject; 91 class NumberObject;
92 class Object; 92 class Object;
93 class ObjectOperationDescriptor; 93 class ObjectOperationDescriptor;
94 class ObjectTemplate; 94 class ObjectTemplate;
95 class Platform; 95 class Platform;
96 class Primitive; 96 class Primitive;
97 class Promise; 97 class Promise;
98 class PropertyDescriptor;
98 class Proxy; 99 class Proxy;
99 class RawOperationDescriptor; 100 class RawOperationDescriptor;
100 class Script; 101 class Script;
101 class SharedArrayBuffer; 102 class SharedArrayBuffer;
102 class Signature; 103 class Signature;
103 class StartupData; 104 class StartupData;
104 class StackFrame; 105 class StackFrame;
105 class StackTrace; 106 class StackTrace;
106 class String; 107 class String;
107 class StringObject; 108 class StringObject;
(...skipping 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2686 // Implements DefineOwnProperty. 2687 // Implements DefineOwnProperty.
2687 // 2688 //
2688 // In general, CreateDataProperty will be faster, however, does not allow 2689 // In general, CreateDataProperty will be faster, however, does not allow
2689 // for specifying attributes. 2690 // for specifying attributes.
2690 // 2691 //
2691 // Returns true on success. 2692 // Returns true on success.
2692 V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty( 2693 V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty(
2693 Local<Context> context, Local<Name> key, Local<Value> value, 2694 Local<Context> context, Local<Name> key, Local<Value> value,
2694 PropertyAttribute attributes = None); 2695 PropertyAttribute attributes = None);
2695 2696
2697 // Implements Object.DefineProperty(O, P, Attributes) as in ecma262 19.1.2.4.
2698 //
2699 // The defineProperty function is used to add an own property or
2700 // update the attributes of an existing own property of an object.
2701 //
2702 // Both data and accessor descriptors can be used.
2703 //
2704 // In general, CreateDataProperty is faster, however, does not allow
2705 // for specifying attributes or an accessor descriptor.
2706 //
2707 // Returns true on success.
2708 V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty(
2709 Local<Context> context, Local<Name> key,
2710 const PropertyDescriptor& descriptor);
2711
2696 // Sets an own property on this object bypassing interceptors and 2712 // Sets an own property on this object bypassing interceptors and
2697 // overriding accessors or read-only properties. 2713 // overriding accessors or read-only properties.
2698 // 2714 //
2699 // Note that if the object has an interceptor the property will be set 2715 // Note that if the object has an interceptor the property will be set
2700 // locally, but since the interceptor takes precedence the local property 2716 // locally, but since the interceptor takes precedence the local property
2701 // will only be returned if the interceptor doesn't return a value. 2717 // will only be returned if the interceptor doesn't return a value.
2702 // 2718 //
2703 // Note also that this only works for named properties. 2719 // Note also that this only works for named properties.
2704 V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty", 2720 V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty",
2705 bool ForceSet(Local<Value> key, Local<Value> value, 2721 bool ForceSet(Local<Value> key, Local<Value> value,
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
3430 */ 3446 */
3431 bool HasHandler(); 3447 bool HasHandler();
3432 3448
3433 V8_INLINE static Promise* Cast(Value* obj); 3449 V8_INLINE static Promise* Cast(Value* obj);
3434 3450
3435 private: 3451 private:
3436 Promise(); 3452 Promise();
3437 static void CheckCast(Value* obj); 3453 static void CheckCast(Value* obj);
3438 }; 3454 };
3439 3455
3456 /**
3457 * An instance of a Property Descriptor, see Ecma-262 6.2.4.
3458 *
3459 * This property descriptor is immutable. An invalid descriptor that is both
3460 * a data and accessor descriptor can not be generated. To determine if
3461 * a descriptor is an accessor, data, or generic descriptor, use the
3462 * has_x() functions for appropriate x.
3463 *
3464 * Empty handles for value, get, or set should be treated as undefined.
jochen (gone - plz use gerrit) 2016/08/23 12:38:41 so has_value = true and value.is_empty() is valid?
Franzi 2016/08/23 16:08:23 Because desc = {value: undefined} is different for
Toon Verwaest 2016/08/23 18:01:43 Empty handle would indicate that though. Unlike fo
3465 *
3466 * The difference between hax_x() = false and setting x to its default value
3467 * is important when re-defining a property. When re-defining, has_x() = false
3468 * does not cause a type error if x is already defined differently.
3469 */
3470 class V8_EXPORT PropertyDescriptor {
3471 public:
3472 // GenericDescriptor
3473 PropertyDescriptor(bool enumerable = false, bool has_enumerable = false,
3474 bool configurable = false, bool has_configurable = false)
3475 : enumerable_(enumerable),
3476 has_enumerable_(has_enumerable),
3477 configurable_(configurable),
3478 has_configurable_(has_configurable) {}
3479
3480 // DataDescriptor
3481 PropertyDescriptor(Local<Value> value, bool has_value,
jochen (gone - plz use gerrit) 2016/08/23 12:38:41 it's a bit odd that has_get below has a default va
Franzi 2016/08/23 16:08:23 OK, I'll make the enumerable and configurable prop
3482 bool enumerable = false, bool has_enumerable = false,
3483 bool configurable = false, bool has_configurable = false,
3484 bool writable = false, bool has_writable = false)
3485 : value_(value),
3486 has_value_(has_value),
3487 enumerable_(enumerable),
3488 has_enumerable_(has_enumerable),
3489 configurable_(configurable),
3490 has_configurable_(has_configurable),
3491 writable_(writable),
3492 has_writable_(has_writable) {}
3493
3494 // AccessorDescriptor
3495 PropertyDescriptor(Local<Function> get, bool has_get = false,
jochen (gone - plz use gerrit) 2016/08/23 12:38:41 should we have a version that also takes a Functio
Franzi 2016/08/23 16:08:23 My use case is going to be to convert an internal
3496 Local<Function> set = Local<Function>(),
3497 bool has_set = false, bool enumerable = false,
3498 bool has_enumerable = false, bool configurable = false,
3499 bool has_configurable = false)
3500 : get_(get),
3501 has_get_(has_get),
3502 set_(set),
3503 has_set_(has_set),
3504 enumerable_(enumerable),
3505 has_enumerable_(has_enumerable),
3506 configurable_(configurable),
3507 has_configurable_(has_configurable) {}
3508
3509 Local<Value> value() const { return value_; }
3510 bool has_value() const { return has_value_; }
3511
3512 Local<Function> get() const { return get_; }
3513 bool has_get() const { return has_get_; }
3514 Local<Function> set() const { return set_; }
3515 bool has_set() const { return has_set_; }
3516
3517 bool enumerable() const { return enumerable_; }
3518 bool has_enumerable() const { return has_enumerable_; }
3519 bool configurable() const { return configurable_; }
3520 bool has_configurable() const { return has_configurable_; }
3521 bool writable() const { return writable_; }
3522 bool has_writable() const { return has_writable_; }
3523
3524 private:
3525 Local<Value> value_;
3526 bool has_value_ = false;
3527
3528 Local<Function> get_;
3529 bool has_get_ = false;
3530 Local<Function> set_;
3531 bool has_set_ = false;
3532
3533 bool enumerable_ = false;
3534 bool has_enumerable_ = false;
3535 bool configurable_ = false;
3536 bool has_configurable_ = false;
3537 bool writable_ = false;
3538 bool has_writable_ = false;
3539 };
jochen (gone - plz use gerrit) 2016/08/23 12:38:41 this struct must not be copied / assigned to. just
Franzi 2016/08/23 16:08:22 Done.
3440 3540
3441 /** 3541 /**
3442 * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, 3542 * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
3443 * 26.2.1). 3543 * 26.2.1).
3444 */ 3544 */
3445 class V8_EXPORT Proxy : public Object { 3545 class V8_EXPORT Proxy : public Object {
3446 public: 3546 public:
3447 Local<Object> GetTarget(); 3547 Local<Object> GetTarget();
3448 Local<Value> GetHandler(); 3548 Local<Value> GetHandler();
3449 bool IsRevoked(); 3549 bool IsRevoked();
(...skipping 5536 matching lines...) Expand 10 before | Expand all | Expand 10 after
8986 */ 9086 */
8987 9087
8988 9088
8989 } // namespace v8 9089 } // namespace v8
8990 9090
8991 9091
8992 #undef TYPE_CHECK 9092 #undef TYPE_CHECK
8993 9093
8994 9094
8995 #endif // INCLUDE_V8_H_ 9095 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698