V8 Project
v8::Promise::Resolver Class Reference

#include <v8.h>

+ Inheritance diagram for v8::Promise::Resolver:
+ Collaboration diagram for v8::Promise::Resolver:

Public Member Functions

Local< PromiseGetPromise ()
 Extract the associated promise. More...
 
void Resolve (Handle< Value > value)
 Resolve/reject the associated promise with a given value. More...
 
void Reject (Handle< Value > value)
 
- Public Member Functions inherited from v8::Object
bool Set (Handle< Value > key, Handle< Value > value)
 
bool Set (uint32_t index, Handle< Value > value)
 
bool ForceSet (Handle< Value > key, Handle< Value > value, PropertyAttribute attribs=None)
 
Local< ValueGet (Handle< Value > key)
 
Local< ValueGet (uint32_t index)
 
PropertyAttribute GetPropertyAttributes (Handle< Value > key)
 Gets the property attributes of a property which can be None or any combination of ReadOnly, DontEnum and DontDelete. More...
 
Local< ValueGetOwnPropertyDescriptor (Local< String > key)
 Returns Object.getOwnPropertyDescriptor as per ES5 section 15.2.3.3. More...
 
bool Has (Handle< Value > key)
 
bool Delete (Handle< Value > key)
 
bool ForceDelete (Handle< Value > key)
 
bool Has (uint32_t index)
 
bool Delete (uint32_t index)
 
bool SetAccessor (Handle< String > name, AccessorGetterCallback getter, AccessorSetterCallback setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
 
bool SetAccessor (Handle< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=0, Handle< Value > data=Handle< Value >(), AccessControl settings=DEFAULT, PropertyAttribute attribute=None)
 
bool SetDeclaredAccessor (Local< Name > name, Local< DeclaredAccessorDescriptor > descriptor, PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
 
void SetAccessorProperty (Local< Name > name, Local< Function > getter, Handle< Function > setter=Handle< Function >(), PropertyAttribute attribute=None, AccessControl settings=DEFAULT)
 
bool HasPrivate (Handle< Private > key)
 Functionality for private properties. More...
 
bool SetPrivate (Handle< Private > key, Handle< Value > value)
 
bool DeletePrivate (Handle< Private > key)
 
Local< ValueGetPrivate (Handle< Private > key)
 
Local< ArrayGetPropertyNames ()
 Returns an array containing the names of the enumerable properties of this object, including properties from prototype objects. More...
 
Local< ArrayGetOwnPropertyNames ()
 This function has the same functionality as GetPropertyNames but the returned array doesn't contain the names of properties from prototype objects. More...
 
Local< ValueGetPrototype ()
 Get the prototype object. More...
 
bool SetPrototype (Handle< Value > prototype)
 Set the prototype object. More...
 
Local< ObjectFindInstanceInPrototypeChain (Handle< FunctionTemplate > tmpl)
 Finds an instance of the given function template in the prototype chain. More...
 
Local< StringObjectProtoToString ()
 Call builtin Object.prototype.toString on this object. More...
 
Local< StringGetConstructorName ()
 Returns the name of the function invoked as a constructor for this object. More...
 
int InternalFieldCount ()
 Gets the number of internal fields for this Object. More...
 
Local< ValueGetInternalField (int index)
 Gets the value from an internal field. More...
 
void SetInternalField (int index, Handle< Value > value)
 Sets the value in an internal field. More...
 
void * GetAlignedPointerFromInternalField (int index)
 Gets a 2-byte-aligned native pointer from an internal field. More...
 
void SetAlignedPointerInInternalField (int index, void *value)
 Sets a 2-byte-aligned native pointer in an internal field. More...
 
bool HasOwnProperty (Handle< String > key)
 
bool HasRealNamedProperty (Handle< String > key)
 
bool HasRealIndexedProperty (uint32_t index)
 
bool HasRealNamedCallbackProperty (Handle< String > key)
 
Local< ValueGetRealNamedPropertyInPrototypeChain (Handle< String > key)
 If result.IsEmpty() no real property was located in the prototype chain. More...
 
Local< ValueGetRealNamedProperty (Handle< String > key)
 If result.IsEmpty() no real property was located on the object or in the prototype chain. More...
 
bool HasNamedLookupInterceptor ()
 Tests for a named lookup interceptor. More...
 
bool HasIndexedLookupInterceptor ()
 Tests for an index lookup interceptor. More...
 
void TurnOnAccessCheck ()
 Turns on access check on the object if the object is an instance of a template that has access check callbacks. More...
 
int GetIdentityHash ()
 Returns the identity hash for this object. More...
 
bool SetHiddenValue (Handle< String > key, Handle< Value > value)
 Access hidden properties on JavaScript objects. More...
 
Local< ValueGetHiddenValue (Handle< String > key)
 
bool DeleteHiddenValue (Handle< String > key)
 
bool IsDirty ()
 Returns true if this is an instance of an api function (one created from a function created from a function template) and has been modified since it was created. More...
 
Local< ObjectClone ()
 Clone this object with a fast but shallow copy. More...
 
Local< ContextCreationContext ()
 Returns the context in which the object was created. More...
 
void SetIndexedPropertiesToPixelData (uint8_t *data, int length)
 Set the backing store of the indexed properties to be managed by the embedding layer. More...
 
bool HasIndexedPropertiesInPixelData ()
 
uint8_t * GetIndexedPropertiesPixelData ()
 
int GetIndexedPropertiesPixelDataLength ()
 
void SetIndexedPropertiesToExternalArrayData (void *data, ExternalArrayType array_type, int number_of_elements)
 Set the backing store of the indexed properties to be managed by the embedding layer. More...
 
bool HasIndexedPropertiesInExternalArrayData ()
 
void * GetIndexedPropertiesExternalArrayData ()
 
ExternalArrayType GetIndexedPropertiesExternalArrayDataType ()
 
int GetIndexedPropertiesExternalArrayDataLength ()
 
bool IsCallable ()
 Checks whether a callback is set by the ObjectTemplate::SetCallAsFunctionHandler method. More...
 
Local< ValueCallAsFunction (Handle< Value > recv, int argc, Handle< Value > argv[])
 Call an Object as a function if a callback is set by the ObjectTemplate::SetCallAsFunctionHandler method. More...
 
Local< ValueCallAsConstructor (int argc, Handle< Value > argv[])
 Call an Object as a constructor if a callback is set by the ObjectTemplate::SetCallAsFunctionHandler method. More...
 
- Public Member Functions inherited from v8::Value
bool IsUndefined () const
 Returns true if this value is the undefined value. More...
 
bool IsNull () const
 Returns true if this value is the null value. More...
 
bool IsTrue () const
 Returns true if this value is true. More...
 
bool IsFalse () const
 Returns true if this value is false. More...
 
bool IsName () const
 Returns true if this value is a symbol or a string. More...
 
bool IsString () const
 Returns true if this value is an instance of the String type. More...
 
bool IsSymbol () const
 Returns true if this value is a symbol. More...
 
bool IsFunction () const
 Returns true if this value is a function. More...
 
bool IsArray () const
 Returns true if this value is an array. More...
 
bool IsObject () const
 Returns true if this value is an object. More...
 
bool IsBoolean () const
 Returns true if this value is boolean. More...
 
bool IsNumber () const
 Returns true if this value is a number. More...
 
bool IsExternal () const
 Returns true if this value is external. More...
 
bool IsInt32 () const
 Returns true if this value is a 32-bit signed integer. More...
 
bool IsUint32 () const
 Returns true if this value is a 32-bit unsigned integer. More...
 
bool IsDate () const
 Returns true if this value is a Date. More...
 
bool IsArgumentsObject () const
 Returns true if this value is an Arguments object. More...
 
bool IsBooleanObject () const
 Returns true if this value is a Boolean object. More...
 
bool IsNumberObject () const
 Returns true if this value is a Number object. More...
 
bool IsStringObject () const
 Returns true if this value is a String object. More...
 
bool IsSymbolObject () const
 Returns true if this value is a Symbol object. More...
 
bool IsNativeError () const
 Returns true if this value is a NativeError. More...
 
bool IsRegExp () const
 Returns true if this value is a RegExp. More...
 
bool IsGeneratorFunction () const
 Returns true if this value is a Generator function. More...
 
bool IsGeneratorObject () const
 Returns true if this value is a Generator object (iterator). More...
 
bool IsPromise () const
 Returns true if this value is a Promise. More...
 
bool IsMap () const
 Returns true if this value is a Map. More...
 
bool IsSet () const
 Returns true if this value is a Set. More...
 
bool IsWeakMap () const
 Returns true if this value is a WeakMap. More...
 
bool IsWeakSet () const
 Returns true if this value is a WeakSet. More...
 
bool IsArrayBuffer () const
 Returns true if this value is an ArrayBuffer. More...
 
bool IsArrayBufferView () const
 Returns true if this value is an ArrayBufferView. More...
 
bool IsTypedArray () const
 Returns true if this value is one of TypedArrays. More...
 
bool IsUint8Array () const
 Returns true if this value is an Uint8Array. More...
 
bool IsUint8ClampedArray () const
 Returns true if this value is an Uint8ClampedArray. More...
 
bool IsInt8Array () const
 Returns true if this value is an Int8Array. More...
 
bool IsUint16Array () const
 Returns true if this value is an Uint16Array. More...
 
bool IsInt16Array () const
 Returns true if this value is an Int16Array. More...
 
bool IsUint32Array () const
 Returns true if this value is an Uint32Array. More...
 
bool IsInt32Array () const
 Returns true if this value is an Int32Array. More...
 
bool IsFloat32Array () const
 Returns true if this value is a Float32Array. More...
 
bool IsFloat64Array () const
 Returns true if this value is a Float64Array. More...
 
bool IsDataView () const
 Returns true if this value is a DataView. More...
 
Local< BooleanToBoolean () const
 
Local< NumberToNumber () const
 
Local< StringToString () const
 
Local< StringToDetailString () const
 
Local< ObjectToObject () const
 
Local< IntegerToInteger () const
 
Local< Uint32ToUint32 () const
 
Local< Int32ToInt32 () const
 
Local< Uint32ToArrayIndex () const
 Attempts to convert a string to an array index. More...
 
bool BooleanValue () const
 
double NumberValue () const
 
int64_t IntegerValue () const
 
uint32_t Uint32Value () const
 
int32_t Int32Value () const
 
bool Equals (Handle< Value > that) const
 JS ==. More...
 
bool StrictEquals (Handle< Value > that) const
 
bool SameValue (Handle< Value > that) const
 

Static Public Member Functions

static Local< ResolverNew (Isolate *isolate)
 Create a new resolver, along with an associated promise in pending state. More...
 
static ResolverCast (Value *obj)
 
- Static Public Member Functions inherited from v8::Object
static int InternalFieldCount (const PersistentBase< Object > &object)
 Same as above, but works for Persistents. More...
 
static void * GetAlignedPointerFromInternalField (const PersistentBase< Object > &object, int index)
 Same as above, but works for Persistents. More...
 
static Local< ObjectNew (Isolate *isolate)
 
static ObjectCast (Value *obj)
 
- Static Public Member Functions inherited from v8::Value
template<class T >
static ValueCast (T *value)
 

Private Member Functions

 Resolver ()
 

Static Private Member Functions

static void CheckCast (Value *obj)
 

Detailed Description

Definition at line 2797 of file v8.h.

Constructor & Destructor Documentation

◆ Resolver()

v8::Promise::Resolver::Resolver ( )
private

Member Function Documentation

◆ Cast()

Promise::Resolver * v8::Promise::Resolver::Cast ( v8::Value value)
inlinestatic

Definition at line 6678 of file v8.h.

6678  {
6679 #ifdef V8_ENABLE_CHECKS
6680  CheckCast(value);
6681 #endif
6682  return static_cast<Promise::Resolver*>(value);
6683 }
static void CheckCast(Value *obj)
Definition: api.cc:2777

◆ CheckCast()

void v8::Promise::Resolver::CheckCast ( Value obj)
staticprivate

Definition at line 2777 of file api.cc.

2777  {
2778  Utils::ApiCheck(that->IsPromise(),
2779  "v8::Promise::Resolver::Cast()",
2780  "Could not convert to promise resolver");
2781 }
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:177

References v8::Utils::ApiCheck(), and v8::Value::IsPromise().

+ Here is the call graph for this function:

◆ GetPromise()

Local< Promise > v8::Promise::Resolver::GetPromise ( )

Extract the associated promise.

Definition at line 5890 of file api.cc.

5890  {
5891  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5892  return Local<Promise>::Cast(Utils::ToLocal(promise));
5893 }
static Local< T > Cast(Local< S > that)
Definition: v8.h:348
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288

References v8::Local< T >::Cast(), v8::Utils::OpenHandle(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ New()

Local< Promise::Resolver > v8::Promise::Resolver::New ( Isolate isolate)
static

Create a new resolver, along with an associated promise in pending state.

Definition at line 5873 of file api.cc.

5873  {
5874  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
5875  LOG_API(isolate, "Promise::Resolver::New");
5876  ENTER_V8(isolate);
5877  EXCEPTION_PREAMBLE(isolate);
5878  i::Handle<i::Object> result;
5879  has_pending_exception = !i::Execution::Call(
5880  isolate,
5881  isolate->promise_create(),
5882  isolate->factory()->undefined_value(),
5883  0, NULL,
5884  false).ToHandle(&result);
5885  EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise::Resolver>());
5887 }
#define LOG_API(isolate, expr)
Definition: api.cc:52
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:93
#define ENTER_V8(isolate)
Definition: api.cc:54
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:67
Factory * factory()
Definition: isolate.h:982
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

References v8::Local< T >::Cast(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), LOG_API, NULL, and v8::Utils::ToLocal().

+ Here is the call graph for this function:

◆ Reject()

void v8::Promise::Resolver::Reject ( Handle< Value value)

Definition at line 5913 of file api.cc.

5913  {
5914  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5915  i::Isolate* isolate = promise->GetIsolate();
5916  LOG_API(isolate, "Promise::Resolver::Reject");
5917  ENTER_V8(isolate);
5918  EXCEPTION_PREAMBLE(isolate);
5919  i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5920  has_pending_exception = i::Execution::Call(
5921  isolate,
5922  isolate->promise_reject(),
5923  isolate->factory()->undefined_value(),
5924  arraysize(argv), argv,
5925  false).is_null();
5926  EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5927 }
#define arraysize(array)
Definition: macros.h:86

References arraysize, ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ Resolve()

void v8::Promise::Resolver::Resolve ( Handle< Value value)

Resolve/reject the associated promise with a given value.

Ignored if the promise is no longer pending.

Definition at line 5896 of file api.cc.

5896  {
5897  i::Handle<i::JSObject> promise = Utils::OpenHandle(this);
5898  i::Isolate* isolate = promise->GetIsolate();
5899  LOG_API(isolate, "Promise::Resolver::Resolve");
5900  ENTER_V8(isolate);
5901  EXCEPTION_PREAMBLE(isolate);
5902  i::Handle<i::Object> argv[] = { promise, Utils::OpenHandle(*value) };
5903  has_pending_exception = i::Execution::Call(
5904  isolate,
5905  isolate->promise_resolve(),
5906  isolate->factory()->undefined_value(),
5907  arraysize(argv), argv,
5908  false).is_null();
5909  EXCEPTION_BAILOUT_CHECK(isolate, /* void */ ;);
5910 }

References arraysize, ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: