V8 Project
v8::Number Class Reference

A JavaScript number value (ECMA-262, 4.3.20) More...

#include <v8.h>

+ Inheritance diagram for v8::Number:
+ Collaboration diagram for v8::Number:

Public Member Functions

double Value () const
 
- 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< NumberNew (Isolate *isolate, double value)
 
static NumberCast (v8::Value *obj)
 
- Static Public Member Functions inherited from v8::Value
template<class T >
static ValueCast (T *value)
 

Private Member Functions

 Number ()
 

Static Private Member Functions

static void CheckCast (v8::Value *obj)
 

Detailed Description

A JavaScript number value (ECMA-262, 4.3.20)

Definition at line 2162 of file v8.h.

Constructor & Destructor Documentation

◆ Number()

v8::Number::Number ( )
private

Member Function Documentation

◆ Cast()

Number * v8::Number::Cast ( v8::Value obj)
inlinestatic

Definition at line 6590 of file v8.h.

6590  {
6591 #ifdef V8_ENABLE_CHECKS
6592  CheckCast(value);
6593 #endif
6594  return static_cast<Number*>(value);
6595 }
static void CheckCast(v8::Value *obj)
Definition: api.cc:2746

◆ CheckCast()

void v8::Number::CheckCast ( v8::Value obj)
staticprivate

Definition at line 2746 of file api.cc.

2746  {
2748  Utils::ApiCheck(obj->IsNumber(),
2749  "v8::Number::Cast()",
2750  "Could not convert to number");
2751 }
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:177
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288

References v8::Utils::ApiCheck(), and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ New()

Local< Number > v8::Number::New ( Isolate isolate,
double  value 
)
static

Definition at line 6268 of file api.cc.

6268  {
6269  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6270  DCHECK(internal_isolate->IsInitialized());
6271  if (std::isnan(value)) {
6272  // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
6273  value = base::OS::nan_value();
6274  }
6275  ENTER_V8(internal_isolate);
6276  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6277  return Utils::NumberToLocal(result);
6278 }
#define ENTER_V8(isolate)
Definition: api.cc:54
static Local< Number > NumberToLocal(v8::internal::Handle< v8::internal::Object > obj)
static double nan_value()
Factory * factory()
Definition: isolate.h:982
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, ENTER_V8, v8::internal::Isolate::factory(), v8::internal::Isolate::IsInitialized(), v8::base::OS::nan_value(), and v8::Utils::NumberToLocal().

Referenced by v8::internal::AddCounter(), v8::internal::AddNumber(), v8::internal::AddNumber64(), and v8::ReturnValue< T >::Set().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Value()

double v8::Number::Value ( ) const

Definition at line 4944 of file api.cc.

4944  {
4946  return obj->Number();
4947 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

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