11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef INCLUDE_V8_PRIMITIVE_OBJECT_H_ 61cb0ef41Sopenharmony_ci#define INCLUDE_V8_PRIMITIVE_OBJECT_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "v8-local-handle.h" // NOLINT(build/include_directory) 91cb0ef41Sopenharmony_ci#include "v8-object.h" // NOLINT(build/include_directory) 101cb0ef41Sopenharmony_ci#include "v8config.h" // NOLINT(build/include_directory) 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cinamespace v8 { 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciclass Isolate; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci/** 171cb0ef41Sopenharmony_ci * A Number object (ECMA-262, 4.3.21). 181cb0ef41Sopenharmony_ci */ 191cb0ef41Sopenharmony_ciclass V8_EXPORT NumberObject : public Object { 201cb0ef41Sopenharmony_ci public: 211cb0ef41Sopenharmony_ci static Local<Value> New(Isolate* isolate, double value); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci double ValueOf() const; 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci V8_INLINE static NumberObject* Cast(Value* value) { 261cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 271cb0ef41Sopenharmony_ci CheckCast(value); 281cb0ef41Sopenharmony_ci#endif 291cb0ef41Sopenharmony_ci return static_cast<NumberObject*>(value); 301cb0ef41Sopenharmony_ci } 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci private: 331cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 341cb0ef41Sopenharmony_ci}; 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci/** 371cb0ef41Sopenharmony_ci * A BigInt object (https://tc39.github.io/proposal-bigint) 381cb0ef41Sopenharmony_ci */ 391cb0ef41Sopenharmony_ciclass V8_EXPORT BigIntObject : public Object { 401cb0ef41Sopenharmony_ci public: 411cb0ef41Sopenharmony_ci static Local<Value> New(Isolate* isolate, int64_t value); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci Local<BigInt> ValueOf() const; 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci V8_INLINE static BigIntObject* Cast(Value* value) { 461cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 471cb0ef41Sopenharmony_ci CheckCast(value); 481cb0ef41Sopenharmony_ci#endif 491cb0ef41Sopenharmony_ci return static_cast<BigIntObject*>(value); 501cb0ef41Sopenharmony_ci } 511cb0ef41Sopenharmony_ci 521cb0ef41Sopenharmony_ci private: 531cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 541cb0ef41Sopenharmony_ci}; 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci/** 571cb0ef41Sopenharmony_ci * A Boolean object (ECMA-262, 4.3.15). 581cb0ef41Sopenharmony_ci */ 591cb0ef41Sopenharmony_ciclass V8_EXPORT BooleanObject : public Object { 601cb0ef41Sopenharmony_ci public: 611cb0ef41Sopenharmony_ci static Local<Value> New(Isolate* isolate, bool value); 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci bool ValueOf() const; 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci V8_INLINE static BooleanObject* Cast(Value* value) { 661cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 671cb0ef41Sopenharmony_ci CheckCast(value); 681cb0ef41Sopenharmony_ci#endif 691cb0ef41Sopenharmony_ci return static_cast<BooleanObject*>(value); 701cb0ef41Sopenharmony_ci } 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci private: 731cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 741cb0ef41Sopenharmony_ci}; 751cb0ef41Sopenharmony_ci 761cb0ef41Sopenharmony_ci/** 771cb0ef41Sopenharmony_ci * A String object (ECMA-262, 4.3.18). 781cb0ef41Sopenharmony_ci */ 791cb0ef41Sopenharmony_ciclass V8_EXPORT StringObject : public Object { 801cb0ef41Sopenharmony_ci public: 811cb0ef41Sopenharmony_ci static Local<Value> New(Isolate* isolate, Local<String> value); 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci Local<String> ValueOf() const; 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci V8_INLINE static StringObject* Cast(Value* value) { 861cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 871cb0ef41Sopenharmony_ci CheckCast(value); 881cb0ef41Sopenharmony_ci#endif 891cb0ef41Sopenharmony_ci return static_cast<StringObject*>(value); 901cb0ef41Sopenharmony_ci } 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci private: 931cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 941cb0ef41Sopenharmony_ci}; 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci/** 971cb0ef41Sopenharmony_ci * A Symbol object (ECMA-262 edition 6). 981cb0ef41Sopenharmony_ci */ 991cb0ef41Sopenharmony_ciclass V8_EXPORT SymbolObject : public Object { 1001cb0ef41Sopenharmony_ci public: 1011cb0ef41Sopenharmony_ci static Local<Value> New(Isolate* isolate, Local<Symbol> value); 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ci Local<Symbol> ValueOf() const; 1041cb0ef41Sopenharmony_ci 1051cb0ef41Sopenharmony_ci V8_INLINE static SymbolObject* Cast(Value* value) { 1061cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 1071cb0ef41Sopenharmony_ci CheckCast(value); 1081cb0ef41Sopenharmony_ci#endif 1091cb0ef41Sopenharmony_ci return static_cast<SymbolObject*>(value); 1101cb0ef41Sopenharmony_ci } 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci private: 1131cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 1141cb0ef41Sopenharmony_ci}; 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci} // namespace v8 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci#endif // INCLUDE_V8_PRIMITIVE_OBJECT_H_ 119