V8 Project
v8::Integer Class Reference

A JavaScript value representing a signed integer. More...

#include <v8.h>

+ Inheritance diagram for v8::Integer:
+ Collaboration diagram for v8::Integer:

Public Member Functions

int64_t Value () const
 
- Public Member Functions inherited from v8::Number
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< IntegerNew (Isolate *isolate, int32_t value)
 
static Local< IntegerNewFromUnsigned (Isolate *isolate, uint32_t value)
 
static IntegerCast (v8::Value *obj)
 
- Static Public Member Functions inherited from v8::Number
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

 Integer ()
 

Static Private Member Functions

static void CheckCast (v8::Value *obj)
 

Detailed Description

A JavaScript value representing a signed integer.

Definition at line 2176 of file v8.h.

Constructor & Destructor Documentation

◆ Integer()

v8::Integer::Integer ( )
private

Member Function Documentation

◆ Cast()

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

Definition at line 6598 of file v8.h.

6598  {
6599 #ifdef V8_ENABLE_CHECKS
6600  CheckCast(value);
6601 #endif
6602  return static_cast<Integer*>(value);
6603 }
static void CheckCast(v8::Value *obj)
Definition: api.cc:2754

◆ CheckCast()

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

Definition at line 2754 of file api.cc.

2754  {
2756  Utils::ApiCheck(obj->IsNumber(),
2757  "v8::Integer::Cast()",
2758  "Could not convert to number");
2759 }
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< Integer > v8::Integer::New ( Isolate isolate,
int32_t  value 
)
static

Definition at line 6281 of file api.cc.

6281  {
6282  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6283  DCHECK(internal_isolate->IsInitialized());
6284  if (i::Smi::IsValid(value)) {
6286  internal_isolate));
6287  }
6288  ENTER_V8(internal_isolate);
6289  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6290  return Utils::IntegerToLocal(result);
6291 }
#define ENTER_V8(isolate)
Definition: api.cc:54
static Local< Integer > IntegerToLocal(v8::internal::Handle< v8::internal::Object > obj)
Factory * factory()
Definition: isolate.h:982
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
static bool IsValid(intptr_t value)
Definition: objects-inl.h:1334
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, ENTER_V8, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::Utils::IntegerToLocal(), v8::internal::Isolate::IsInitialized(), and v8::internal::Smi::IsValid().

Referenced by v8::ReadLineEditor::CompletionGenerator(), v8::Message::GetScriptOrigin(), v8::Function::GetScriptOrigin(), v8::ExecArgs::Init(), NewFromUnsigned(), v8::Template::Set(), v8::ReturnValue< T >::Set(), and v8::Template::SetAccessorProperty().

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

◆ NewFromUnsigned()

Local< Integer > v8::Integer::NewFromUnsigned ( Isolate isolate,
uint32_t  value 
)
static

Definition at line 6294 of file api.cc.

6294  {
6295  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6296  DCHECK(internal_isolate->IsInitialized());
6297  bool fits_into_int32_t = (value & (1 << 31)) == 0;
6298  if (fits_into_int32_t) {
6299  return Integer::New(isolate, static_cast<int32_t>(value));
6300  }
6301  ENTER_V8(internal_isolate);
6302  i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6303  return Utils::IntegerToLocal(result);
6304 }
static Local< Integer > New(Isolate *isolate, int32_t value)
Definition: api.cc:6281
int int32_t
Definition: unicode.cc:24

References DCHECK, ENTER_V8, v8::internal::Isolate::factory(), v8::Utils::IntegerToLocal(), v8::internal::Isolate::IsInitialized(), and New().

Referenced by v8::ReturnValue< T >::Set().

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

◆ Value()

int64_t v8::Integer::Value ( ) const

Definition at line 4956 of file api.cc.

4956  {
4958  if (obj->IsSmi()) {
4959  return i::Smi::cast(*obj)->value();
4960  } else {
4961  return static_cast<int64_t>(obj->Number());
4962  }
4963 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

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