V8 Project
v8::Value Class Reference

The superclass of all JavaScript values and objects. More...

#include <v8.h>

+ Inheritance diagram for v8::Value:
+ Collaboration diagram for v8::Value:

Public Member Functions

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

template<class T >
static ValueCast (T *value)
 

Private Member Functions

bool QuickIsUndefined () const
 
bool QuickIsNull () const
 
bool QuickIsString () const
 
bool FullIsUndefined () const
 
bool FullIsNull () const
 
bool FullIsString () const
 

Detailed Description

The superclass of all JavaScript values and objects.

Definition at line 1440 of file v8.h.

Member Function Documentation

◆ BooleanValue()

bool v8::Value::BooleanValue ( ) const

Definition at line 2895 of file api.cc.

2895  {
2896  return Utils::OpenHandle(this)->BooleanValue();
2897 }
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ Cast()

template<class T >
Value * v8::Value::Cast ( T value)
inlinestatic

Definition at line 6569 of file v8.h.

6569  {
6570  return static_cast<Value*>(value);
6571 }

◆ Equals()

bool v8::Value::Equals ( Handle< Value that) const

JS ==.

Definition at line 3025 of file api.cc.

3025  {
3026  i::Isolate* isolate = i::Isolate::Current();
3027  i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
3028  if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
3029  "v8::Value::Equals()",
3030  "Reading from empty handle")) {
3031  return false;
3032  }
3033  LOG_API(isolate, "Equals");
3034  ENTER_V8(isolate);
3035  i::Handle<i::Object> other = Utils::OpenHandle(*that);
3036  // If both obj and other are JSObjects, we'd better compare by identity
3037  // immediately when going into JS builtin. The reason is Invoke
3038  // would overwrite global object receiver with global proxy.
3039  if (obj->IsJSObject() && other->IsJSObject()) {
3040  return *obj == *other;
3041  }
3042  i::Handle<i::Object> args[] = { other };
3043  EXCEPTION_PREAMBLE(isolate);
3044  i::Handle<i::Object> result;
3045  has_pending_exception = !CallV8HeapFunction(
3046  "EQUALS", obj, arraysize(args), args).ToHandle(&result);
3047  EXCEPTION_BAILOUT_CHECK(isolate, false);
3048  return *result == i::Smi::FromInt(i::EQUAL);
3049 }
#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
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:177
bool is_null() const
Definition: handles.h:124
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
#define arraysize(array)
Definition: macros.h:86
static MUST_USE_RESULT i::MaybeHandle< i::Object > CallV8HeapFunction(const char *name, i::Handle< i::Object > recv, int argc, i::Handle< i::Object > argv[])
Definition: api.cc:2112

References v8::Utils::ApiCheck(), arraysize, v8::CallV8HeapFunction(), ENTER_V8, v8::internal::EQUAL, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Smi::FromInt(), v8::internal::Handle< T >::is_null(), v8::Handle< T >::IsEmpty(), LOG_API, and v8::Utils::OpenHandle().

Referenced by CheckEqualsHelper(), and CheckNonEqualsHelper().

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

◆ FullIsNull()

bool v8::Value::FullIsNull ( ) const
private

Definition at line 2392 of file api.cc.

2392  {
2393  bool result = Utils::OpenHandle(this)->IsNull();
2394  DCHECK_EQ(result, QuickIsNull());
2395  return result;
2396 }
bool QuickIsNull() const
Definition: v8.h:6542
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206

References DCHECK_EQ, v8::Utils::OpenHandle(), and QuickIsNull().

+ Here is the call graph for this function:

◆ FullIsString()

bool v8::Value::FullIsString ( ) const
private

Definition at line 2419 of file api.cc.

2419  {
2420  bool result = Utils::OpenHandle(this)->IsString();
2421  DCHECK_EQ(result, QuickIsString());
2422  return result;
2423 }
bool QuickIsString() const
Definition: v8.h:6560

References DCHECK_EQ, v8::Utils::OpenHandle(), and QuickIsString().

+ Here is the call graph for this function:

◆ FullIsUndefined()

bool v8::Value::FullIsUndefined ( ) const
private

Definition at line 2385 of file api.cc.

2385  {
2386  bool result = Utils::OpenHandle(this)->IsUndefined();
2387  DCHECK_EQ(result, QuickIsUndefined());
2388  return result;
2389 }
bool QuickIsUndefined() const
Definition: v8.h:6524

References DCHECK_EQ, v8::Utils::OpenHandle(), and QuickIsUndefined().

+ Here is the call graph for this function:

◆ Int32Value()

int32_t v8::Value::Int32Value ( ) const

Definition at line 3004 of file api.cc.

3004  {
3006  if (obj->IsSmi()) {
3007  return i::Smi::cast(*obj)->value();
3008  } else {
3009  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
3010  LOG_API(isolate, "Int32Value (slow)");
3011  ENTER_V8(isolate);
3012  EXCEPTION_PREAMBLE(isolate);
3014  has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num);
3015  EXCEPTION_BAILOUT_CHECK(isolate, 0);
3016  if (num->IsSmi()) {
3017  return i::Smi::cast(*num)->value();
3018  } else {
3019  return static_cast<int32_t>(num->Number());
3020  }
3021  }
3022 }
int int32_t
Definition: unicode.cc:24

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

Referenced by v8::internal::JSObject::GetElementAttributeWithInterceptor(), and v8::internal::JSObject::GetPropertyAttributesWithInterceptor().

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

◆ IntegerValue()

int64_t v8::Value::IntegerValue ( ) const

Definition at line 2918 of file api.cc.

2918  {
2921  if (obj->IsNumber()) {
2922  num = obj;
2923  } else {
2924  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2925  LOG_API(isolate, "IntegerValue");
2926  ENTER_V8(isolate);
2927  EXCEPTION_PREAMBLE(isolate);
2928  has_pending_exception = !i::Execution::ToInteger(
2929  isolate, obj).ToHandle(&num);
2930  EXCEPTION_BAILOUT_CHECK(isolate, 0);
2931  }
2932  if (num->IsSmi()) {
2933  return i::Smi::cast(*num)->value();
2934  } else {
2935  return static_cast<int64_t>(num->Number());
2936  }
2937 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsArgumentsObject()

bool v8::Value::IsArgumentsObject ( ) const

Returns true if this value is an Arguments object.

◆ IsArray()

bool v8::Value::IsArray ( ) const

Returns true if this value is an array.

Definition at line 2431 of file api.cc.

2431  {
2432  return Utils::OpenHandle(this)->IsJSArray();
2433 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsArrayBuffer()

bool v8::Value::IsArrayBuffer ( ) const

Returns true if this value is an ArrayBuffer.

This is an experimental feature.

Definition at line 2436 of file api.cc.

2436  {
2437  return Utils::OpenHandle(this)->IsJSArrayBuffer();
2438 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsArrayBufferView()

bool v8::Value::IsArrayBufferView ( ) const

Returns true if this value is an ArrayBufferView.

This is an experimental feature.

Definition at line 2441 of file api.cc.

2441  {
2442  return Utils::OpenHandle(this)->IsJSArrayBufferView();
2443 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsBoolean()

bool v8::Value::IsBoolean ( ) const

Returns true if this value is boolean.

Definition at line 2500 of file api.cc.

2500  {
2501  return Utils::OpenHandle(this)->IsBoolean();
2502 }

References v8::Utils::OpenHandle().

Referenced by v8::internal::JSObject::DeleteElementWithInterceptor(), and v8::internal::JSObject::DeletePropertyWithInterceptor().

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

◆ IsBooleanObject()

bool v8::Value::IsBooleanObject ( ) const

Returns true if this value is a Boolean object.

◆ IsDataView()

bool v8::Value::IsDataView ( ) const

Returns true if this value is a DataView.

This is an experimental feature.

Definition at line 2463 of file api.cc.

2463  {
2464  return Utils::OpenHandle(this)->IsJSDataView();
2465 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsDate()

bool v8::Value::IsDate ( ) const

Returns true if this value is a Date.

◆ IsExternal()

bool v8::Value::IsExternal ( ) const

Returns true if this value is external.

Definition at line 2505 of file api.cc.

2505  {
2506  return Utils::OpenHandle(this)->IsExternal();
2507 }

References v8::Utils::OpenHandle().

Referenced by v8::External::CheckCast().

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

◆ IsFalse()

bool v8::Value::IsFalse ( ) const

Returns true if this value is false.

Definition at line 2404 of file api.cc.

2404  {
2405  return Utils::OpenHandle(this)->IsFalse();
2406 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsFloat32Array()

bool v8::Value::IsFloat32Array ( ) const

Returns true if this value is a Float32Array.

This is an experimental feature.

◆ IsFloat64Array()

bool v8::Value::IsFloat64Array ( ) const

Returns true if this value is a Float64Array.

This is an experimental feature.

◆ IsFunction()

bool v8::Value::IsFunction ( ) const

Returns true if this value is a function.

Definition at line 2409 of file api.cc.

2409  {
2410  return Utils::OpenHandle(this)->IsJSFunction();
2411 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsGeneratorFunction()

bool v8::Value::IsGeneratorFunction ( ) const

Returns true if this value is a Generator function.

This is an experimental feature.

Definition at line 2571 of file api.cc.

2571  {
2573  if (!obj->IsJSFunction()) return false;
2575  return func->shared()->is_generator();
2576 }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116

References v8::internal::Handle< T >::cast(), and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsGeneratorObject()

bool v8::Value::IsGeneratorObject ( ) const

Returns true if this value is a Generator object (iterator).

This is an experimental feature.

Definition at line 2579 of file api.cc.

2579  {
2580  return Utils::OpenHandle(this)->IsJSGeneratorObject();
2581 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsInt16Array()

bool v8::Value::IsInt16Array ( ) const

Returns true if this value is an Int16Array.

This is an experimental feature.

◆ IsInt32()

bool v8::Value::IsInt32 ( ) const

Returns true if this value is a 32-bit signed integer.

Definition at line 2510 of file api.cc.

2510  {
2512  if (obj->IsSmi()) return true;
2513  if (obj->IsNumber()) {
2514  return i::IsInt32Double(obj->Number());
2515  }
2516  return false;
2517 }
static bool IsInt32Double(double value)
Definition: conversions.h:169

References v8::internal::IsInt32Double(), and v8::Utils::OpenHandle().

Referenced by v8::internal::JSObject::GetPropertyAttributesWithInterceptor().

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

◆ IsInt32Array()

bool v8::Value::IsInt32Array ( ) const

Returns true if this value is an Int32Array.

This is an experimental feature.

◆ IsInt8Array()

bool v8::Value::IsInt8Array ( ) const

Returns true if this value is an Int8Array.

This is an experimental feature.

◆ IsMap()

bool v8::Value::IsMap ( ) const

Returns true if this value is a Map.

This is an experimental feature.

◆ IsName()

bool v8::Value::IsName ( ) const

Returns true if this value is a symbol or a string.

This is an experimental feature.

Definition at line 2414 of file api.cc.

2414  {
2415  return Utils::OpenHandle(this)->IsName();
2416 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsNativeError()

bool v8::Value::IsNativeError ( ) const

Returns true if this value is a NativeError.

Definition at line 2547 of file api.cc.

2547  {
2549  if (obj->IsJSObject()) {
2550  i::Handle<i::JSObject> js_obj(i::JSObject::cast(*obj));
2551  i::Isolate* isolate = js_obj->GetIsolate();
2552  return CheckConstructor(isolate, js_obj, "$Error") ||
2553  CheckConstructor(isolate, js_obj, "$EvalError") ||
2554  CheckConstructor(isolate, js_obj, "$RangeError") ||
2555  CheckConstructor(isolate, js_obj, "$ReferenceError") ||
2556  CheckConstructor(isolate, js_obj, "$SyntaxError") ||
2557  CheckConstructor(isolate, js_obj, "$TypeError") ||
2558  CheckConstructor(isolate, js_obj, "$URIError");
2559  } else {
2560  return false;
2561  }
2562 }
static bool CheckConstructor(i::Isolate *isolate, i::Handle< i::JSObject > obj, const char *class_name)
Definition: api.cc:2534

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

+ Here is the call graph for this function:

◆ IsNull()

bool v8::Value::IsNull ( ) const
inline

Returns true if this value is the null value.

See ECMA-262 4.3.11.

Definition at line 6534 of file v8.h.

6534  {
6535 #ifdef V8_ENABLE_CHECKS
6536  return FullIsNull();
6537 #else
6538  return QuickIsNull();
6539 #endif
6540 }
bool FullIsNull() const
Definition: api.cc:2392

◆ IsNumber()

bool v8::Value::IsNumber ( ) const

Returns true if this value is a number.

Definition at line 2473 of file api.cc.

2473  {
2474  return Utils::OpenHandle(this)->IsNumber();
2475 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsNumberObject()

bool v8::Value::IsNumberObject ( ) const

Returns true if this value is a Number object.

◆ IsObject()

bool v8::Value::IsObject ( ) const

Returns true if this value is an object.

Definition at line 2468 of file api.cc.

2468  {
2469  return Utils::OpenHandle(this)->IsJSObject();
2470 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsPromise()

bool v8::Value::IsPromise ( ) const

Returns true if this value is a Promise.

This is an experimental feature.

Definition at line 5852 of file api.cc.

5852  {
5854  if (!val->IsJSObject()) return false;
5856  i::Isolate* isolate = obj->GetIsolate();
5857  LOG_API(isolate, "IsPromise");
5858  ENTER_V8(isolate);
5859  EXCEPTION_PREAMBLE(isolate);
5860  i::Handle<i::Object> argv[] = { obj };
5862  has_pending_exception = !i::Execution::Call(
5863  isolate,
5864  isolate->is_promise(),
5865  isolate->factory()->undefined_value(),
5866  arraysize(argv), argv,
5867  false).ToHandle(&b);
5868  EXCEPTION_BAILOUT_CHECK(isolate, false);
5869  return b->BooleanValue();
5870 }
Factory * factory()
Definition: isolate.h:982

References arraysize, v8::internal::Handle< T >::cast(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), LOG_API, and v8::Utils::OpenHandle().

Referenced by v8::Promise::Resolver::CheckCast(), and v8::Promise::CheckCast().

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

◆ IsRegExp()

bool v8::Value::IsRegExp ( ) const

Returns true if this value is a RegExp.

Definition at line 2565 of file api.cc.

2565  {
2567  return obj->IsJSRegExp();
2568 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsSet()

bool v8::Value::IsSet ( ) const

Returns true if this value is a Set.

This is an experimental feature.

◆ IsString()

bool v8::Value::IsString ( ) const
inline

Returns true if this value is an instance of the String type.

See ECMA-262 8.4.

Definition at line 6552 of file v8.h.

6552  {
6553 #ifdef V8_ENABLE_CHECKS
6554  return FullIsString();
6555 #else
6556  return QuickIsString();
6557 #endif
6558 }
bool FullIsString() const
Definition: api.cc:2419

Referenced by v8::Object::ObjectProtoToString().

+ Here is the caller graph for this function:

◆ IsStringObject()

bool v8::Value::IsStringObject ( ) const

Returns true if this value is a String object.

◆ IsSymbol()

bool v8::Value::IsSymbol ( ) const

Returns true if this value is a symbol.

This is an experimental feature.

Definition at line 2426 of file api.cc.

2426  {
2427  return Utils::OpenHandle(this)->IsSymbol();
2428 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsSymbolObject()

bool v8::Value::IsSymbolObject ( ) const

Returns true if this value is a Symbol object.

This is an experimental feature.

◆ IsTrue()

bool v8::Value::IsTrue ( ) const

Returns true if this value is true.

Definition at line 2399 of file api.cc.

2399  {
2400  return Utils::OpenHandle(this)->IsTrue();
2401 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsTypedArray()

bool v8::Value::IsTypedArray ( ) const

Returns true if this value is one of TypedArrays.

This is an experimental feature.

Definition at line 2446 of file api.cc.

2446  {
2447  return Utils::OpenHandle(this)->IsJSTypedArray();
2448 }

References v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsUint16Array()

bool v8::Value::IsUint16Array ( ) const

Returns true if this value is an Uint16Array.

This is an experimental feature.

◆ IsUint32()

bool v8::Value::IsUint32 ( ) const

Returns true if this value is a 32-bit unsigned integer.

Definition at line 2520 of file api.cc.

2520  {
2522  if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
2523  if (obj->IsNumber()) {
2524  double value = obj->Number();
2525  return !i::IsMinusZero(value) &&
2526  value >= 0 &&
2527  value <= i::kMaxUInt32 &&
2528  value == i::FastUI2D(i::FastD2UI(value));
2529  }
2530  return false;
2531 }
unsigned int FastD2UI(double x)
double FastUI2D(unsigned x)
Definition: conversions.h:72
static bool IsMinusZero(double value)
Definition: conversions.h:154
const uint32_t kMaxUInt32
Definition: globals.h:120

References v8::internal::FastD2UI(), v8::internal::FastUI2D(), v8::internal::IsMinusZero(), v8::internal::kMaxUInt32, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ IsUint32Array()

bool v8::Value::IsUint32Array ( ) const

Returns true if this value is an Uint32Array.

This is an experimental feature.

◆ IsUint8Array()

bool v8::Value::IsUint8Array ( ) const

Returns true if this value is an Uint8Array.

This is an experimental feature.

◆ IsUint8ClampedArray()

bool v8::Value::IsUint8ClampedArray ( ) const

Returns true if this value is an Uint8ClampedArray.

This is an experimental feature.

◆ IsUndefined()

bool v8::Value::IsUndefined ( ) const
inline

Returns true if this value is the undefined value.

See ECMA-262 4.3.10.

Definition at line 6516 of file v8.h.

6516  {
6517 #ifdef V8_ENABLE_CHECKS
6518  return FullIsUndefined();
6519 #else
6520  return QuickIsUndefined();
6521 #endif
6522 }
bool FullIsUndefined() const
Definition: api.cc:2385

◆ IsWeakMap()

bool v8::Value::IsWeakMap ( ) const

Returns true if this value is a WeakMap.

This is an experimental feature.

◆ IsWeakSet()

bool v8::Value::IsWeakSet ( ) const

Returns true if this value is a WeakSet.

This is an experimental feature.

◆ NumberValue()

double v8::Value::NumberValue ( ) const

Definition at line 2900 of file api.cc.

2900  {
2903  if (obj->IsNumber()) {
2904  num = obj;
2905  } else {
2906  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2907  LOG_API(isolate, "NumberValue");
2908  ENTER_V8(isolate);
2909  EXCEPTION_PREAMBLE(isolate);
2910  has_pending_exception = !i::Execution::ToNumber(
2911  isolate, obj).ToHandle(&num);
2913  }
2914  return num->Number();
2915 }
static double nan_value()
int ToNumber(Register reg)

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, v8::base::OS::nan_value(), v8::Utils::OpenHandle(), and v8::internal::ToNumber().

+ Here is the call graph for this function:

◆ QuickIsNull()

bool v8::Value::QuickIsNull ( ) const
inlineprivate

Definition at line 6542 of file v8.h.

6542  {
6543  typedef internal::Object O;
6544  typedef internal::Internals I;
6545  O* obj = *reinterpret_cast<O* const*>(this);
6546  if (!I::HasHeapObjectTag(obj)) return false;
6547  if (I::GetInstanceType(obj) != I::kOddballType) return false;
6548  return (I::GetOddballKind(obj) == I::kNullOddballKind);
6549 }
kSerializedDataOffset Object
Definition: objects-inl.h:5322
#define I(name, number_of_args, result_size)
Definition: runtime.cc:9248

References I.

Referenced by FullIsNull().

+ Here is the caller graph for this function:

◆ QuickIsString()

bool v8::Value::QuickIsString ( ) const
inlineprivate

Definition at line 6560 of file v8.h.

6560  {
6561  typedef internal::Object O;
6562  typedef internal::Internals I;
6563  O* obj = *reinterpret_cast<O* const*>(this);
6564  if (!I::HasHeapObjectTag(obj)) return false;
6565  return (I::GetInstanceType(obj) < I::kFirstNonstringType);
6566 }

References I.

Referenced by FullIsString().

+ Here is the caller graph for this function:

◆ QuickIsUndefined()

bool v8::Value::QuickIsUndefined ( ) const
inlineprivate

Definition at line 6524 of file v8.h.

6524  {
6525  typedef internal::Object O;
6526  typedef internal::Internals I;
6527  O* obj = *reinterpret_cast<O* const*>(this);
6528  if (!I::HasHeapObjectTag(obj)) return false;
6529  if (I::GetInstanceType(obj) != I::kOddballType) return false;
6530  return (I::GetOddballKind(obj) == I::kUndefinedOddballKind);
6531 }

References I.

Referenced by FullIsUndefined().

+ Here is the caller graph for this function:

◆ SameValue()

bool v8::Value::SameValue ( Handle< Value that) const

Definition at line 3085 of file api.cc.

3085  {
3086  i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
3087  if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
3088  "v8::Value::SameValue()",
3089  "Reading from empty handle")) {
3090  return false;
3091  }
3092  i::Handle<i::Object> other = Utils::OpenHandle(*that);
3093  return obj->SameValue(*other);
3094 }

References v8::Utils::ApiCheck(), v8::internal::Handle< T >::is_null(), v8::Handle< T >::IsEmpty(), and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ StrictEquals()

bool v8::Value::StrictEquals ( Handle< Value that) const

Definition at line 3052 of file api.cc.

3052  {
3053  i::Isolate* isolate = i::Isolate::Current();
3054  i::Handle<i::Object> obj = Utils::OpenHandle(this, true);
3055  if (!Utils::ApiCheck(!obj.is_null() && !that.IsEmpty(),
3056  "v8::Value::StrictEquals()",
3057  "Reading from empty handle")) {
3058  return false;
3059  }
3060  LOG_API(isolate, "StrictEquals");
3061  i::Handle<i::Object> other = Utils::OpenHandle(*that);
3062  // Must check HeapNumber first, since NaN !== NaN.
3063  if (obj->IsHeapNumber()) {
3064  if (!other->IsNumber()) return false;
3065  double x = obj->Number();
3066  double y = other->Number();
3067  // Must check explicitly for NaN:s on Windows, but -0 works fine.
3068  return x == y && !std::isnan(x) && !std::isnan(y);
3069  } else if (*obj == *other) { // Also covers Booleans.
3070  return true;
3071  } else if (obj->IsSmi()) {
3072  return other->IsNumber() && obj->Number() == other->Number();
3073  } else if (obj->IsString()) {
3074  return other->IsString() &&
3077  } else if (obj->IsUndefined() || obj->IsUndetectableObject()) {
3078  return other->IsUndefined() || other->IsUndetectableObject();
3079  } else {
3080  return false;
3081  }
3082 }
bool Equals(String *other)
Definition: objects-inl.h:3336
int isnan(double x)

References v8::Utils::ApiCheck(), v8::internal::String::Equals(), v8::internal::Handle< T >::is_null(), v8::Handle< T >::IsEmpty(), LOG_API, v8::Utils::OpenHandle(), and v8::base::internal::y.

+ Here is the call graph for this function:

◆ ToArrayIndex()

Local< Uint32 > v8::Value::ToArrayIndex ( ) const

Attempts to convert a string to an array index.

Returns an empty handle if the conversion fails.

Definition at line 2975 of file api.cc.

2975  {
2977  if (obj->IsSmi()) {
2978  if (i::Smi::cast(*obj)->value() >= 0) return Utils::Uint32ToLocal(obj);
2979  return Local<Uint32>();
2980  }
2981  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2982  LOG_API(isolate, "ToArrayIndex");
2983  ENTER_V8(isolate);
2984  EXCEPTION_PREAMBLE(isolate);
2985  i::Handle<i::Object> string_obj;
2986  has_pending_exception = !i::Execution::ToString(
2987  isolate, obj).ToHandle(&string_obj);
2988  EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2990  uint32_t index;
2991  if (str->AsArrayIndex(&index)) {
2992  i::Handle<i::Object> value;
2993  if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) {
2994  value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate);
2995  } else {
2996  value = isolate->factory()->NewNumber(index);
2997  }
2998  return Utils::Uint32ToLocal(value);
2999  }
3000  return Local<Uint32>();
3001 }
static Local< Uint32 > Uint32ToLocal(v8::internal::Handle< v8::internal::Object > obj)
static const int kMaxValue
Definition: objects.h:1272

References v8::internal::Handle< T >::cast(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::Isolate::factory(), v8::internal::Smi::FromInt(), v8::internal::Smi::kMaxValue, LOG_API, v8::Utils::OpenHandle(), and v8::Utils::Uint32ToLocal().

+ Here is the call graph for this function:

◆ ToBoolean()

Local< Boolean > v8::Value::ToBoolean ( ) const

Definition at line 2638 of file api.cc.

2638  {
2640  if (obj->IsBoolean()) {
2641  return ToApiHandle<Boolean>(obj);
2642  } else {
2643  i::Isolate* isolate = i::Isolate::Current();
2644  LOG_API(isolate, "ToBoolean");
2645  ENTER_V8(isolate);
2646  i::Handle<i::Object> val =
2647  isolate->factory()->ToBoolean(obj->BooleanValue());
2648  return ToApiHandle<Boolean>(val);
2649  }
2650 }

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

+ Here is the call graph for this function:

◆ ToDetailString()

Local< String > v8::Value::ToDetailString ( ) const

Definition at line 2602 of file api.cc.

2602  {
2605  if (obj->IsString()) {
2606  str = obj;
2607  } else {
2608  i::Isolate* isolate = i::Isolate::Current();
2609  LOG_API(isolate, "ToDetailString");
2610  ENTER_V8(isolate);
2611  EXCEPTION_PREAMBLE(isolate);
2612  has_pending_exception = !i::Execution::ToDetailString(
2613  isolate, obj).ToHandle(&str);
2614  EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2615  }
2616  return ToApiHandle<String>(str);
2617 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ ToInt32()

Local< Int32 > v8::Value::ToInt32 ( ) const

Definition at line 2940 of file api.cc.

2940  {
2943  if (obj->IsSmi()) {
2944  num = obj;
2945  } else {
2946  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2947  LOG_API(isolate, "ToInt32");
2948  ENTER_V8(isolate);
2949  EXCEPTION_PREAMBLE(isolate);
2950  has_pending_exception = !i::Execution::ToInt32(isolate, obj).ToHandle(&num);
2951  EXCEPTION_BAILOUT_CHECK(isolate, Local<Int32>());
2952  }
2953  return ToApiHandle<Int32>(num);
2954 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ ToInteger()

Local< Integer > v8::Value::ToInteger ( ) const

Definition at line 2671 of file api.cc.

2671  {
2674  if (obj->IsSmi()) {
2675  num = obj;
2676  } else {
2677  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2678  LOG_API(isolate, "ToInteger");
2679  ENTER_V8(isolate);
2680  EXCEPTION_PREAMBLE(isolate);
2681  has_pending_exception = !i::Execution::ToInteger(
2682  isolate, obj).ToHandle(&num);
2683  EXCEPTION_BAILOUT_CHECK(isolate, Local<Integer>());
2684  }
2685  return ToApiHandle<Integer>(num);
2686 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ ToNumber()

Local< Number > v8::Value::ToNumber ( ) const

Definition at line 2653 of file api.cc.

2653  {
2656  if (obj->IsNumber()) {
2657  num = obj;
2658  } else {
2659  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2660  LOG_API(isolate, "ToNumber");
2661  ENTER_V8(isolate);
2662  EXCEPTION_PREAMBLE(isolate);
2663  has_pending_exception = !i::Execution::ToNumber(
2664  isolate, obj).ToHandle(&num);
2665  EXCEPTION_BAILOUT_CHECK(isolate, Local<Number>());
2666  }
2667  return ToApiHandle<Number>(num);
2668 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, v8::Utils::OpenHandle(), and v8::internal::ToNumber().

+ Here is the call graph for this function:

◆ ToObject()

Local< v8::Object > v8::Value::ToObject ( ) const

Definition at line 2620 of file api.cc.

2620  {
2623  if (obj->IsJSObject()) {
2624  val = obj;
2625  } else {
2626  i::Isolate* isolate = i::Isolate::Current();
2627  LOG_API(isolate, "ToObject");
2628  ENTER_V8(isolate);
2629  EXCEPTION_PREAMBLE(isolate);
2630  has_pending_exception = !i::Execution::ToObject(
2631  isolate, obj).ToHandle(&val);
2632  EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>());
2633  }
2634  return ToApiHandle<Object>(val);
2635 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ ToString()

Local< String > v8::Value::ToString ( ) const

Definition at line 2584 of file api.cc.

2584  {
2587  if (obj->IsString()) {
2588  str = obj;
2589  } else {
2590  i::Isolate* isolate = i::Isolate::Current();
2591  LOG_API(isolate, "ToString");
2592  ENTER_V8(isolate);
2593  EXCEPTION_PREAMBLE(isolate);
2594  has_pending_exception = !i::Execution::ToString(
2595  isolate, obj).ToHandle(&str);
2596  EXCEPTION_BAILOUT_CHECK(isolate, Local<String>());
2597  }
2598  return ToApiHandle<String>(str);
2599 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

Referenced by v8::String::Utf8Value::Utf8Value(), and v8::String::Value::Value().

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

◆ ToUint32()

Local< Uint32 > v8::Value::ToUint32 ( ) const

Definition at line 2957 of file api.cc.

2957  {
2960  if (obj->IsSmi()) {
2961  num = obj;
2962  } else {
2963  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2964  LOG_API(isolate, "ToUInt32");
2965  ENTER_V8(isolate);
2966  EXCEPTION_PREAMBLE(isolate);
2967  has_pending_exception = !i::Execution::ToUint32(
2968  isolate, obj).ToHandle(&num);
2969  EXCEPTION_BAILOUT_CHECK(isolate, Local<Uint32>());
2970  }
2971  return ToApiHandle<Uint32>(num);
2972 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, LOG_API, and v8::Utils::OpenHandle().

+ Here is the call graph for this function:

◆ Uint32Value()

uint32_t v8::Value::Uint32Value ( ) const

Definition at line 3097 of file api.cc.

3097  {
3099  if (obj->IsSmi()) {
3100  return i::Smi::cast(*obj)->value();
3101  } else {
3102  i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
3103  LOG_API(isolate, "Uint32Value");
3104  ENTER_V8(isolate);
3105  EXCEPTION_PREAMBLE(isolate);
3107  has_pending_exception = !i::Execution::ToUint32(
3108  isolate, obj).ToHandle(&num);
3109  EXCEPTION_BAILOUT_CHECK(isolate, 0);
3110  if (num->IsSmi()) {
3111  return i::Smi::cast(*num)->value();
3112  } else {
3113  return static_cast<uint32_t>(num->Number());
3114  }
3115  }
3116 }

References ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, 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: