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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 template <class S> | 431 template <class S> |
432 V8_INLINE MaybeLocal(Local<S> that) | 432 V8_INLINE MaybeLocal(Local<S> that) |
433 : val_(reinterpret_cast<T*>(*that)) { | 433 : val_(reinterpret_cast<T*>(*that)) { |
434 TYPE_CHECK(T, S); | 434 TYPE_CHECK(T, S); |
435 } | 435 } |
436 | 436 |
437 V8_INLINE bool IsEmpty() { return val_ == nullptr; } | 437 V8_INLINE bool IsEmpty() { return val_ == nullptr; } |
438 | 438 |
439 template <class S> | 439 template <class S> |
440 V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { | 440 V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { |
441 if (val_ == NULL) { | 441 if (val_ == nullptr) { |
442 out->val_ = nullptr; | 442 out->val_ = nullptr; |
443 return false; | 443 return false; |
444 } else { | 444 } else { |
445 out->val_ = this->val_; | 445 out->val_ = this->val_; |
446 return true; | 446 return true; |
447 } | 447 } |
448 } | 448 } |
449 | 449 |
450 V8_INLINE Local<T> ToLocalChecked() { | 450 V8_INLINE Local<T> ToLocalChecked() { |
451 // TODO(dcarney): add DCHECK. | 451 // TODO(dcarney): add DCHECK. |
452 return Local<T>(val_); | 452 return Local<T>(val_); |
453 } | 453 } |
454 | 454 |
455 template <class S> | |
456 V8_INLINE Local<S> FromMaybe(Local<S> default_value) const { | |
457 if (val_ == nullptr) return default_value; | |
Sven Panne
2015/03/02 12:37:12
Ternary aversion? :-)
| |
458 return Local<S>(val_); | |
459 } | |
460 | |
455 private: | 461 private: |
456 T* val_; | 462 T* val_; |
457 }; | 463 }; |
458 | 464 |
459 | 465 |
460 // Eternal handles are set-once handles that live for the life of the isolate. | 466 // Eternal handles are set-once handles that live for the life of the isolate. |
461 template <class T> class Eternal { | 467 template <class T> class Eternal { |
462 public: | 468 public: |
463 V8_INLINE Eternal() : index_(kInitialValue) { } | 469 V8_INLINE Eternal() : index_(kInitialValue) { } |
464 template<class S> | 470 template<class S> |
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2483 ALL_CAN_WRITE = 1 << 1, | 2489 ALL_CAN_WRITE = 1 << 1, |
2484 PROHIBITS_OVERWRITING = 1 << 2 | 2490 PROHIBITS_OVERWRITING = 1 << 2 |
2485 }; | 2491 }; |
2486 | 2492 |
2487 | 2493 |
2488 /** | 2494 /** |
2489 * A JavaScript object (ECMA-262, 4.3.3) | 2495 * A JavaScript object (ECMA-262, 4.3.3) |
2490 */ | 2496 */ |
2491 class V8_EXPORT Object : public Value { | 2497 class V8_EXPORT Object : public Value { |
2492 public: | 2498 public: |
2499 // TODO(dcarney): deprecate | |
2493 bool Set(Handle<Value> key, Handle<Value> value); | 2500 bool Set(Handle<Value> key, Handle<Value> value); |
2501 Maybe<bool> Set(Local<Context> context, Local<Value> key, Local<Value> value); | |
2494 | 2502 |
2503 // TODO(dcarney): deprecate | |
2495 bool Set(uint32_t index, Handle<Value> value); | 2504 bool Set(uint32_t index, Handle<Value> value); |
2505 Maybe<bool> Set(Local<Context> context, uint32_t index, Local<Value> value); | |
2496 | 2506 |
2497 // Sets an own property on this object bypassing interceptors and | 2507 // Sets an own property on this object bypassing interceptors and |
2498 // overriding accessors or read-only properties. | 2508 // overriding accessors or read-only properties. |
2499 // | 2509 // |
2500 // Note that if the object has an interceptor the property will be set | 2510 // Note that if the object has an interceptor the property will be set |
2501 // locally, but since the interceptor takes precedence the local property | 2511 // locally, but since the interceptor takes precedence the local property |
2502 // will only be returned if the interceptor doesn't return a value. | 2512 // will only be returned if the interceptor doesn't return a value. |
2503 // | 2513 // |
2504 // Note also that this only works for named properties. | 2514 // Note also that this only works for named properties. |
2515 // TODO(dcarney): deprecate | |
2505 bool ForceSet(Handle<Value> key, | 2516 bool ForceSet(Handle<Value> key, |
2506 Handle<Value> value, | 2517 Handle<Value> value, |
2507 PropertyAttribute attribs = None); | 2518 PropertyAttribute attribs = None); |
2519 Maybe<bool> ForceSet(Local<Context> context, Local<Value> key, | |
2520 Local<Value> value, PropertyAttribute attribs = None); | |
2508 | 2521 |
2522 // TODO(dcarney): deprecate | |
2509 Local<Value> Get(Handle<Value> key); | 2523 Local<Value> Get(Handle<Value> key); |
2524 MaybeLocal<Value> Get(Local<Context> context, Local<Value> key); | |
2510 | 2525 |
2526 // TODO(dcarney): deprecate | |
2511 Local<Value> Get(uint32_t index); | 2527 Local<Value> Get(uint32_t index); |
2528 MaybeLocal<Value> Get(Local<Context> context, uint32_t index); | |
2512 | 2529 |
2513 /** | 2530 /** |
2514 * Gets the property attributes of a property which can be None or | 2531 * Gets the property attributes of a property which can be None or |
2515 * any combination of ReadOnly, DontEnum and DontDelete. Returns | 2532 * any combination of ReadOnly, DontEnum and DontDelete. Returns |
2516 * None when the property doesn't exist. | 2533 * None when the property doesn't exist. |
2517 */ | 2534 */ |
2535 // TODO(dcarney): deprecate | |
2518 PropertyAttribute GetPropertyAttributes(Handle<Value> key); | 2536 PropertyAttribute GetPropertyAttributes(Handle<Value> key); |
2537 Maybe<PropertyAttribute> GetPropertyAttributes(Local<Context> context, | |
2538 Local<Value> key); | |
2519 | 2539 |
2520 /** | 2540 /** |
2521 * Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3. | 2541 * Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3. |
2522 */ | 2542 */ |
2543 // TODO(dcarney): deprecate | |
2523 Local<Value> GetOwnPropertyDescriptor(Local<String> key); | 2544 Local<Value> GetOwnPropertyDescriptor(Local<String> key); |
2545 MaybeLocal<Value> GetOwnPropertyDescriptor(Local<Context> context, | |
2546 Local<String> key); | |
2524 | 2547 |
2548 // TODO(dcarney): deprecate | |
2525 bool Has(Handle<Value> key); | 2549 bool Has(Handle<Value> key); |
2550 Maybe<bool> Has(Local<Context> context, Local<Value> key); | |
2526 | 2551 |
2552 // TODO(dcarney): deprecate | |
2527 bool Delete(Handle<Value> key); | 2553 bool Delete(Handle<Value> key); |
2554 Maybe<bool> Delete(Local<Context> context, Local<Value> key); | |
2528 | 2555 |
2556 // TODO(dcarney): deprecate | |
2529 bool Has(uint32_t index); | 2557 bool Has(uint32_t index); |
2558 Maybe<bool> Has(Local<Context> context, uint32_t index); | |
2530 | 2559 |
2560 // TODO(dcarney): deprecate | |
2531 bool Delete(uint32_t index); | 2561 bool Delete(uint32_t index); |
2562 Maybe<bool> Delete(Local<Context> context, uint32_t index); | |
2532 | 2563 |
2564 // TODO(dcarney): deprecate | |
2533 bool SetAccessor(Handle<String> name, | 2565 bool SetAccessor(Handle<String> name, |
2534 AccessorGetterCallback getter, | 2566 AccessorGetterCallback getter, |
2535 AccessorSetterCallback setter = 0, | 2567 AccessorSetterCallback setter = 0, |
2536 Handle<Value> data = Handle<Value>(), | 2568 Handle<Value> data = Handle<Value>(), |
2537 AccessControl settings = DEFAULT, | 2569 AccessControl settings = DEFAULT, |
2538 PropertyAttribute attribute = None); | 2570 PropertyAttribute attribute = None); |
2539 bool SetAccessor(Handle<Name> name, | 2571 // TODO(dcarney): deprecate |
2540 AccessorNameGetterCallback getter, | 2572 bool SetAccessor(Handle<Name> name, AccessorNameGetterCallback getter, |
2541 AccessorNameSetterCallback setter = 0, | 2573 AccessorNameSetterCallback setter = 0, |
2542 Handle<Value> data = Handle<Value>(), | 2574 Handle<Value> data = Handle<Value>(), |
2543 AccessControl settings = DEFAULT, | 2575 AccessControl settings = DEFAULT, |
2544 PropertyAttribute attribute = None); | 2576 PropertyAttribute attribute = None); |
2577 Maybe<bool> SetAccessor(Local<Context> context, Local<Name> name, | |
2578 AccessorNameGetterCallback getter, | |
2579 AccessorNameSetterCallback setter = 0, | |
2580 MaybeLocal<Value> data = MaybeLocal<Value>(), | |
2581 AccessControl settings = DEFAULT, | |
2582 PropertyAttribute attribute = None); | |
2545 | 2583 |
2546 void SetAccessorProperty(Local<Name> name, | 2584 void SetAccessorProperty(Local<Name> name, |
2547 Local<Function> getter, | 2585 Local<Function> getter, |
2548 Handle<Function> setter = Handle<Function>(), | 2586 Handle<Function> setter = Handle<Function>(), |
2549 PropertyAttribute attribute = None, | 2587 PropertyAttribute attribute = None, |
2550 AccessControl settings = DEFAULT); | 2588 AccessControl settings = DEFAULT); |
2551 | 2589 |
2552 /** | 2590 /** |
2553 * Functionality for private properties. | 2591 * Functionality for private properties. |
2554 * This is an experimental feature, use at your own risk. | 2592 * This is an experimental feature, use at your own risk. |
(...skipping 5091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7646 */ | 7684 */ |
7647 | 7685 |
7648 | 7686 |
7649 } // namespace v8 | 7687 } // namespace v8 |
7650 | 7688 |
7651 | 7689 |
7652 #undef TYPE_CHECK | 7690 #undef TYPE_CHECK |
7653 | 7691 |
7654 | 7692 |
7655 #endif // V8_H_ | 7693 #endif // V8_H_ |
OLD | NEW |