Loading...
Searching...
No Matches
v8-primitive.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_PRIMITIVE_H_
6#define INCLUDE_V8_PRIMITIVE_H_
7
8#include "v8-data.h" // NOLINT(build/include_directory)
9#include "v8-internal.h" // NOLINT(build/include_directory)
10#include "v8-local-handle.h" // NOLINT(build/include_directory)
11#include "v8-value.h" // NOLINT(build/include_directory)
12#include "v8config.h" // NOLINT(build/include_directory)
13
14namespace v8 {
15
16class Context;
17class Isolate;
18class String;
19
20namespace internal {
21class ExternalString;
22class ScopedExternalStringLock;
23class StringForwardingTable;
24} // namespace internal
25
29class V8_EXPORT Primitive : public Value {};
30
35class V8_EXPORT Boolean : public Primitive {
36 public:
37 bool Value() const;
38 V8_INLINE static Boolean* Cast(v8::Data* data) {
39#ifdef V8_ENABLE_CHECKS
40 CheckCast(data);
41#endif
42 return static_cast<Boolean*>(data);
43 }
44
45 V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
46
47 private:
48 static void CheckCast(v8::Data* that);
49};
50
59 public:
60 static Local<PrimitiveArray> New(Isolate* isolate, int length);
61 int Length() const;
62 void Set(Isolate* isolate, int index, Local<Primitive> item);
63 Local<Primitive> Get(Isolate* isolate, int index);
64
66#ifdef V8_ENABLE_CHECKS
67 CheckCast(data);
68#endif
69 return reinterpret_cast<PrimitiveArray*>(data);
70 }
71
72 private:
73 static void CheckCast(Data* obj);
74};
75
79class V8_EXPORT Name : public Primitive {
80 public:
89
90 V8_INLINE static Name* Cast(Data* data) {
91#ifdef V8_ENABLE_CHECKS
92 CheckCast(data);
93#endif
94 return static_cast<Name*>(data);
95 }
96
97 private:
98 static void CheckCast(Data* that);
99};
100
107enum class NewStringType {
111 kNormal,
112
119};
120
124class V8_EXPORT String : public Name {
125 public:
126 static constexpr int kMaxLength =
127 internal::kApiSystemPointerSize == 4 ? (1 << 28) - 16 : (1 << 29) - 24;
128
129 enum Encoding {
130 UNKNOWN_ENCODING = 0x1,
131 TWO_BYTE_ENCODING = 0x0,
132 ONE_BYTE_ENCODING = 0x8
133 };
137 int Length() const;
138
143 V8_DEPRECATED("Use Utf8LengthV2 instead.")
144 int Utf8Length(Isolate* isolate) const;
145
149 size_t Utf8LengthV2(Isolate* isolate) const;
150
157 bool IsOneByte() const;
158
164 bool ContainsOnlyOneByte() const;
165
192 NO_OPTIONS = 0,
193 HINT_MANY_WRITES_EXPECTED = 1,
194 NO_NULL_TERMINATION = 2,
195 PRESERVE_ONE_BYTE_NULL = 4,
196 // Used by WriteUtf8 to replace orphan surrogate code units with the
197 // unicode replacement character. Needs to be set to guarantee valid UTF-8
198 // output.
199 REPLACE_INVALID_UTF8 = 8
200 };
201
202 // 16-bit character codes.
203 V8_DEPRECATED("Use WriteV2 instead.")
204 int Write(Isolate* isolate, uint16_t* buffer, int start = 0, int length = -1,
205 int options = NO_OPTIONS) const;
206 // One byte characters.
207 V8_DEPRECATED("Use WriteOneByteV2 instead.")
208 int WriteOneByte(Isolate* isolate, uint8_t* buffer, int start = 0,
209 int length = -1, int options = NO_OPTIONS) const;
210 // UTF-8 encoded characters.
211 V8_DEPRECATED("Use WriteUtf8V2 instead.")
212 int WriteUtf8(Isolate* isolate, char* buffer, int length = -1,
213 int* nchars_ref = nullptr, int options = NO_OPTIONS) const;
214
215 struct WriteFlags {
216 enum {
217 kNone = 0,
218 // Indicates that the output string should be null-terminated. In that
219 // case, the output buffer must include sufficient space for the
220 // additional null character.
221 kNullTerminate = 1,
222 // Used by WriteUtf8 to replace orphan surrogate code units with the
223 // unicode replacement character. Needs to be set to guarantee valid UTF-8
224 // output.
225 kReplaceInvalidUtf8 = 2
226 };
227 };
228
241 void WriteV2(Isolate* isolate, uint32_t offset, uint32_t length,
242 uint16_t* buffer, int flags = WriteFlags::kNone) const;
243 void WriteOneByteV2(Isolate* isolate, uint32_t offset, uint32_t length,
244 uint8_t* buffer, int flags = WriteFlags::kNone) const;
245
265 size_t WriteUtf8V2(Isolate* isolate, char* buffer, size_t capacity,
266 int flags = WriteFlags::kNone,
267 size_t* processed_characters_return = nullptr) const;
268
272 V8_INLINE static Local<String> Empty(Isolate* isolate);
273
277 bool IsExternal() const;
278
282 bool IsExternalTwoByte() const;
283
287 bool IsExternalOneByte() const;
288
294
296 public:
297 virtual ~ExternalStringResourceBase() = default;
298
304 virtual bool IsCacheable() const { return true; }
305
311 virtual void Unaccount(Isolate* isolate) {}
312
322 virtual size_t EstimateMemoryUsage() const {
323 return kDefaultMemoryEstimate;
324 }
325 static constexpr size_t kDefaultMemoryEstimate = static_cast<size_t>(-1);
326
328 public:
333 virtual void RecordSharedMemoryUsage(const void* location,
334 size_t size) = 0;
335 };
336
342 SharedMemoryUsageRecorder* recorder) const {}
343
344 // Disallow copying and assigning.
347
348 protected:
350
357 virtual void Dispose() { delete this; }
358
370 virtual void Lock() const {}
371
375 virtual void Unlock() const {}
376
377 private:
378 friend class internal::ExternalString;
379 friend class v8::String;
380 friend class internal::StringForwardingTable;
381 friend class internal::ScopedExternalStringLock;
382 };
383
391 public:
396 ~ExternalStringResource() override = default;
397
402 virtual const uint16_t* data() const = 0;
403
407 virtual size_t length() const = 0;
408
414 const uint16_t* cached_data() const {
415 CheckCachedDataInvariants();
416 return cached_data_;
417 }
418
424
425 protected:
427
428 private:
429 void CheckCachedDataInvariants() const;
430
431 const uint16_t* cached_data_ = nullptr;
432 };
433
446 public:
451 ~ExternalOneByteStringResource() override = default;
452
457 virtual const char* data() const = 0;
458
460 virtual size_t length() const = 0;
461
467 const char* cached_data() const {
468 CheckCachedDataInvariants();
469 return cached_data_;
470 }
471
477
478 protected:
480
481 private:
482 void CheckCachedDataInvariants() const;
483
484 const char* cached_data_ = nullptr;
485 };
492 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
493 v8::Isolate* isolate, Encoding* encoding_out) const;
494 V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
495 Encoding* encoding_out) const;
496
501 V8_INLINE ExternalStringResource* GetExternalStringResource() const;
502
508
509 V8_INLINE static String* Cast(v8::Data* data) {
510#ifdef V8_ENABLE_CHECKS
511 CheckCast(data);
512#endif
513 return static_cast<String*>(data);
514 }
515
525 template <int N>
527 Isolate* isolate, const char (&literal)[N],
528 NewStringType type = NewStringType::kNormal) {
529 static_assert(N <= kMaxLength, "String is too long");
530 return NewFromUtf8Literal(isolate, literal, type, N - 1);
531 }
532
536 Isolate* isolate, const char* data,
537 NewStringType type = NewStringType::kNormal, int length = -1);
538
542 Isolate* isolate, const uint8_t* data,
543 NewStringType type = NewStringType::kNormal, int length = -1);
544
548 Isolate* isolate, const uint16_t* data,
549 NewStringType type = NewStringType::kNormal, int length = -1);
550
556 Local<String> right);
557
567 Isolate* isolate, ExternalStringResource* resource);
568
578 V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
579 bool MakeExternal(ExternalStringResource* resource);
580
590 bool MakeExternal(Isolate* isolate, ExternalStringResource* resource);
591
600 static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
601 Isolate* isolate, ExternalOneByteStringResource* resource);
602
612 V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
613 bool MakeExternal(ExternalOneByteStringResource* resource);
614
624 bool MakeExternal(Isolate* isolate, ExternalOneByteStringResource* resource);
625
630 bool CanMakeExternal(Encoding encoding) const;
631
635 bool StringEquals(Local<String> str) const;
636
648 public:
651 char* operator*() { return str_; }
652 const char* operator*() const { return str_; }
653 size_t length() const { return length_; }
654
655 // Disallow copying and assigning.
656 Utf8Value(const Utf8Value&) = delete;
657 void operator=(const Utf8Value&) = delete;
658
659 private:
660 char* str_;
661 size_t length_;
662 };
663
675 public:
677 "Prefer using String::ValueView if you can, or string->Write to a "
678 "buffer if you cannot.")
679 Value(Isolate* isolate, Local<v8::Value> obj);
681 uint16_t* operator*() { return str_; }
682 const uint16_t* operator*() const { return str_; }
683 uint32_t length() const { return length_; }
684
685 // Disallow copying and assigning.
686 Value(const Value&) = delete;
687 void operator=(const Value&) = delete;
688
689 private:
690 uint16_t* str_;
691 uint32_t length_;
692 };
693
705 public:
708 const uint8_t* data8() const {
709#if V8_ENABLE_CHECKS
710 CheckOneByte(true);
711#endif
712 return data8_;
713 }
714 const uint16_t* data16() const {
715#if V8_ENABLE_CHECKS
716 CheckOneByte(false);
717#endif
718 return data16_;
719 }
720 uint32_t length() const { return length_; }
721 bool is_one_byte() const { return is_one_byte_; }
722
723 // Disallow copying and assigning.
724 ValueView(const ValueView&) = delete;
725 void operator=(const ValueView&) = delete;
726
727 private:
728 void CheckOneByte(bool is_one_byte) const;
729
730 Local<v8::String> flat_str_;
731 union {
732 const uint8_t* data8_;
733 const uint16_t* data16_;
734 };
735 uint32_t length_;
736 bool is_one_byte_;
737 // Avoid exposing the internal DisallowGarbageCollection scope.
738 alignas(internal::Internals::
739 kDisallowGarbageCollectionAlign) char no_gc_debug_scope_
740 [internal::Internals::kDisallowGarbageCollectionSize];
741 };
742
743 private:
744 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
745 Encoding encoding) const;
746 void VerifyExternalStringResource(ExternalStringResource* val) const;
747 ExternalStringResource* GetExternalStringResourceSlow() const;
748 ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
749 String::Encoding* encoding_out) const;
750
751 static Local<v8::String> NewFromUtf8Literal(Isolate* isolate,
752 const char* literal,
753 NewStringType type, int length);
754
755 static void CheckCast(v8::Data* that);
756};
757
758// Zero-length string specialization (templated string size includes
759// terminator).
760template <>
762 Isolate* isolate, const char (&literal)[1], NewStringType type) {
763 return String::Empty(isolate);
764}
765
770 public:
771 virtual ~ExternalResourceVisitor() = default;
772 virtual void VisitExternalString(Local<String> string) {}
773};
774
778class V8_EXPORT Symbol : public Name {
779 public:
784
789 static Local<Symbol> New(Isolate* isolate,
790 Local<String> description = Local<String>());
791
800 static Local<Symbol> For(Isolate* isolate, Local<String> description);
801
806 static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
807
808 // Well-known symbols
822
823 V8_INLINE static Symbol* Cast(Data* data) {
824#ifdef V8_ENABLE_CHECKS
825 CheckCast(data);
826#endif
827 return static_cast<Symbol*>(data);
828 }
829
830 private:
831 Symbol();
832 static void CheckCast(Data* that);
833};
834
840 private:
841 Numeric();
842 static void CheckCast(v8::Data* that);
843};
844
848class V8_EXPORT Number : public Numeric {
849 public:
850 double Value() const;
851 static Local<Number> New(Isolate* isolate, double value);
852 template <typename Int>
853 requires(std::is_integral<Int>::value && !std::is_same<Int, bool>::value &&
854 std::is_signed_v<Int> && sizeof(Int) <= sizeof(int32_t))
855 V8_INLINE static Local<Number> New(Isolate* isolate, Int value) {
856 return NewFromInt32(isolate, value);
857 }
858 template <typename UInt>
859 requires(std::is_integral<UInt>::value &&
860 !std::is_same<UInt, bool>::value && std::is_unsigned_v<UInt> &&
861 sizeof(UInt) <= sizeof(uint32_t))
862 V8_INLINE static Local<Number> New(Isolate* isolate, UInt value) {
863 return NewFromUint32(isolate, value);
864 }
865 V8_INLINE static Number* Cast(v8::Data* data) {
866#ifdef V8_ENABLE_CHECKS
867 CheckCast(data);
868#endif
869 return static_cast<Number*>(data);
870 }
871
872 private:
873 Number();
874 static Local<Number> NewFromInt32(Isolate* isolate, int32_t value);
875 static Local<Number> NewFromUint32(Isolate* isolate, uint32_t value);
876 static void CheckCast(v8::Data* that);
877};
878
882class V8_EXPORT Integer : public Number {
883 public:
884 static Local<Integer> New(Isolate* isolate, int32_t value);
885 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
886 int64_t Value() const;
888#ifdef V8_ENABLE_CHECKS
889 CheckCast(data);
890#endif
891 return static_cast<Integer*>(data);
892 }
893
894 private:
895 Integer();
896 static void CheckCast(v8::Data* that);
897};
898
902class V8_EXPORT Int32 : public Integer {
903 public:
904 int32_t Value() const;
905 V8_INLINE static Int32* Cast(v8::Data* data) {
906#ifdef V8_ENABLE_CHECKS
907 CheckCast(data);
908#endif
909 return static_cast<Int32*>(data);
910 }
911
912 private:
913 Int32();
914 static void CheckCast(v8::Data* that);
915};
916
920class V8_EXPORT Uint32 : public Integer {
921 public:
922 uint32_t Value() const;
923 V8_INLINE static Uint32* Cast(v8::Data* data) {
924#ifdef V8_ENABLE_CHECKS
925 CheckCast(data);
926#endif
927 return static_cast<Uint32*>(data);
928 }
929
930 private:
931 Uint32();
932 static void CheckCast(v8::Data* that);
933};
934
938class V8_EXPORT BigInt : public Numeric {
939 public:
940 static Local<BigInt> New(Isolate* isolate, int64_t value);
941 static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
949 static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
950 int word_count, const uint64_t* words);
951
958 uint64_t Uint64Value(bool* lossless = nullptr) const;
959
965 int64_t Int64Value(bool* lossless = nullptr) const;
966
971 int WordCount() const;
972
981 void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
982
983 V8_INLINE static BigInt* Cast(v8::Data* data) {
984#ifdef V8_ENABLE_CHECKS
985 CheckCast(data);
986#endif
987 return static_cast<BigInt*>(data);
988 }
989
990 private:
991 BigInt();
992 static void CheckCast(v8::Data* that);
993};
994
996 using S = internal::Address;
997 using I = internal::Internals;
998 I::CheckInitialized(isolate);
999 S* slot = I::GetRootSlot(isolate, I::kEmptyStringRootIndex);
1000 return Local<String>::FromSlot(slot);
1001}
1002
1004 using A = internal::Address;
1005 using I = internal::Internals;
1007
1008 ExternalStringResource* result;
1009 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
1010 Isolate* isolate = I::GetCurrentIsolateForSandbox();
1011 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1012 isolate, obj, I::kStringResourceOffset);
1013 result = reinterpret_cast<String::ExternalStringResource*>(value);
1014 } else {
1015 result = GetExternalStringResourceSlow();
1016 }
1017#ifdef V8_ENABLE_CHECKS
1018 VerifyExternalStringResource(result);
1019#endif
1020 return result;
1021}
1022
1024 v8::Isolate* isolate, String::Encoding* encoding_out) const {
1025 using A = internal::Address;
1026 using I = internal::Internals;
1028 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1029 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1031 if (type == I::kExternalOneByteRepresentationTag ||
1032 type == I::kExternalTwoByteRepresentationTag) {
1033 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1034 isolate, obj, I::kStringResourceOffset);
1035 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1036 } else {
1037 resource = GetExternalStringResourceBaseSlow(encoding_out);
1038 }
1039#ifdef V8_ENABLE_CHECKS
1040 VerifyExternalStringResourceBase(resource, *encoding_out);
1041#endif
1042 return resource;
1043}
1044
1046 String::Encoding* encoding_out) const {
1047 using A = internal::Address;
1048 using I = internal::Internals;
1050 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1051 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1053 if (type == I::kExternalOneByteRepresentationTag ||
1054 type == I::kExternalTwoByteRepresentationTag) {
1055 Isolate* isolate = I::GetCurrentIsolateForSandbox();
1056 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1057 isolate, obj, I::kStringResourceOffset);
1058 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1059 } else {
1060 resource = GetExternalStringResourceBaseSlow(encoding_out);
1061 }
1062#ifdef V8_ENABLE_CHECKS
1063 VerifyExternalStringResourceBase(resource, *encoding_out);
1064#endif
1065 return resource;
1066}
1067
1068// --- Statics ---
1069
1071 using S = internal::Address;
1072 using I = internal::Internals;
1073 I::CheckInitialized(isolate);
1074 S* slot = I::GetRootSlot(isolate, I::kUndefinedValueRootIndex);
1075 return Local<Primitive>::FromSlot(slot);
1076}
1077
1079 using S = internal::Address;
1080 using I = internal::Internals;
1081 I::CheckInitialized(isolate);
1082 S* slot = I::GetRootSlot(isolate, I::kNullValueRootIndex);
1083 return Local<Primitive>::FromSlot(slot);
1084}
1085
1087 using S = internal::Address;
1088 using I = internal::Internals;
1089 I::CheckInitialized(isolate);
1090 S* slot = I::GetRootSlot(isolate, I::kTrueValueRootIndex);
1091 return Local<Boolean>::FromSlot(slot);
1092}
1093
1095 using S = internal::Address;
1096 using I = internal::Internals;
1097 I::CheckInitialized(isolate);
1098 S* slot = I::GetRootSlot(isolate, I::kFalseValueRootIndex);
1099 return Local<Boolean>::FromSlot(slot);
1100}
1101
1102Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
1103 return value ? True(isolate) : False(isolate);
1104}
1105
1106} // namespace v8
1107
1108#endif // INCLUDE_V8_PRIMITIVE_H_
Definition: v8-primitive.h:938
uint64_t Uint64Value(bool *lossless=nullptr) const
static BigInt * Cast(v8::Data *data)
Definition: v8-primitive.h:983
static Local< BigInt > New(Isolate *isolate, int64_t value)
int64_t Int64Value(bool *lossless=nullptr) const
static MaybeLocal< BigInt > NewFromWords(Local< Context > context, int sign_bit, int word_count, const uint64_t *words)
int WordCount() const
static Local< BigInt > NewFromUnsigned(Isolate *isolate, uint64_t value)
void ToWordsArray(int *sign_bit, int *word_count, uint64_t *words) const
Definition: v8-primitive.h:35
bool Value() const
static Local< Boolean > New(Isolate *isolate, bool value)
Definition: v8-primitive.h:1102
static Boolean * Cast(v8::Data *data)
Definition: v8-primitive.h:38
Definition: v8-data.h:18
Definition: v8-primitive.h:769
virtual ~ExternalResourceVisitor()=default
virtual void VisitExternalString(Local< String > string)
Definition: v8-primitive.h:772
Definition: v8-primitive.h:902
static Int32 * Cast(v8::Data *data)
Definition: v8-primitive.h:905
int32_t Value() const
Definition: v8-primitive.h:882
static Integer * Cast(v8::Data *data)
Definition: v8-primitive.h:887
static Local< Integer > New(Isolate *isolate, int32_t value)
static Local< Integer > NewFromUnsigned(Isolate *isolate, uint32_t value)
int64_t Value() const
Definition: v8-isolate.h:290
Definition: v8-local-handle.h:364
Definition: v8-local-handle.h:732
Definition: v8-primitive.h:79
static Name * Cast(Data *data)
Definition: v8-primitive.h:90
int GetIdentityHash()
Definition: v8-primitive.h:848
static Local< Number > New(Isolate *isolate, double value)
static Local< Number > New(Isolate *isolate, Int value)
Definition: v8-primitive.h:855
static Local< Number > New(Isolate *isolate, UInt value)
Definition: v8-primitive.h:862
static Number * Cast(v8::Data *data)
Definition: v8-primitive.h:865
double Value() const
Definition: v8-primitive.h:839
Definition: v8-primitive.h:58
static Local< PrimitiveArray > New(Isolate *isolate, int length)
Local< Primitive > Get(Isolate *isolate, int index)
static PrimitiveArray * Cast(Data *data)
Definition: v8-primitive.h:65
int Length() const
void Set(Isolate *isolate, int index, Local< Primitive > item)
Definition: v8-primitive.h:29
Definition: v8-primitive.h:445
const char * cached_data() const
Definition: v8-primitive.h:467
~ExternalOneByteStringResource() override=default
virtual const char * data() const =0
virtual void RecordSharedMemoryUsage(const void *location, size_t size)=0
Definition: v8-primitive.h:295
void operator=(const ExternalStringResourceBase &)=delete
virtual void Unaccount(Isolate *isolate)
Definition: v8-primitive.h:311
ExternalStringResourceBase(const ExternalStringResourceBase &)=delete
virtual ~ExternalStringResourceBase()=default
virtual void Unlock() const
Definition: v8-primitive.h:375
virtual void EstimateSharedMemoryUsage(SharedMemoryUsageRecorder *recorder) const
Definition: v8-primitive.h:341
virtual bool IsCacheable() const
Definition: v8-primitive.h:304
virtual void Lock() const
Definition: v8-primitive.h:370
virtual size_t EstimateMemoryUsage() const
Definition: v8-primitive.h:322
virtual void Dispose()
Definition: v8-primitive.h:357
Definition: v8-primitive.h:390
virtual const uint16_t * data() const =0
const uint16_t * cached_data() const
Definition: v8-primitive.h:414
virtual size_t length() const =0
~ExternalStringResource() override=default
Definition: v8-primitive.h:647
char * operator*()
Definition: v8-primitive.h:651
Utf8Value(Isolate *isolate, Local< v8::Value > obj)
Utf8Value(const Utf8Value &)=delete
const char * operator*() const
Definition: v8-primitive.h:652
void operator=(const Utf8Value &)=delete
size_t length() const
Definition: v8-primitive.h:653
Definition: v8-primitive.h:704
bool is_one_byte() const
Definition: v8-primitive.h:721
const uint16_t * data16_
Definition: v8-primitive.h:733
void operator=(const ValueView &)=delete
const uint8_t * data8() const
Definition: v8-primitive.h:708
uint32_t length() const
Definition: v8-primitive.h:720
ValueView(const ValueView &)=delete
const uint16_t * data16() const
Definition: v8-primitive.h:714
ValueView(Isolate *isolate, Local< v8::String > str)
const uint8_t * data8_
Definition: v8-primitive.h:732
Definition: v8-primitive.h:674
const uint16_t * operator*() const
Definition: v8-primitive.h:682
uint32_t length() const
Definition: v8-primitive.h:683
Value(const Value &)=delete
void operator=(const Value &)=delete
Definition: v8-primitive.h:124
bool IsExternalTwoByte() const
bool IsExternal() const
static Local< String > Concat(Isolate *isolate, Local< String > left, Local< String > right)
bool IsExternalOneByte() const
ExternalStringResourceBase * GetExternalStringResourceBase(v8::Isolate *isolate, Encoding *encoding_out) const
Definition: v8-primitive.h:1023
Encoding
Definition: v8-primitive.h:129
void WriteOneByteV2(Isolate *isolate, uint32_t offset, uint32_t length, uint8_t *buffer, int flags=WriteFlags::kNone) const
Local< String > InternalizeString(Isolate *isolate)
static MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=NewStringType::kNormal, int length=-1)
void WriteV2(Isolate *isolate, uint32_t offset, uint32_t length, uint16_t *buffer, int flags=WriteFlags::kNone) const
const ExternalOneByteStringResource * GetExternalOneByteStringResource() const
size_t WriteUtf8V2(Isolate *isolate, char *buffer, size_t capacity, int flags=WriteFlags::kNone, size_t *processed_characters_return=nullptr) const
static MaybeLocal< String > NewExternalTwoByte(Isolate *isolate, ExternalStringResource *resource)
static MaybeLocal< String > NewFromOneByte(Isolate *isolate, const uint8_t *data, NewStringType type=NewStringType::kNormal, int length=-1)
static String * Cast(v8::Data *data)
Definition: v8-primitive.h:509
WriteOptions
Definition: v8-primitive.h:191
static Local< String > Empty(Isolate *isolate)
Definition: v8-primitive.h:995
static MaybeLocal< String > NewFromTwoByte(Isolate *isolate, const uint16_t *data, NewStringType type=NewStringType::kNormal, int length=-1)
static Local< String > NewFromUtf8Literal(Isolate *isolate, const char(&literal)[N], NewStringType type=NewStringType::kNormal)
Definition: v8-primitive.h:526
ExternalStringResource * GetExternalStringResource() const
Definition: v8-primitive.h:1003
int Length() const
Definition: v8-primitive.h:778
static Local< Symbol > GetDispose(Isolate *isolate)
static Local< Symbol > GetMatch(Isolate *isolate)
static Local< Symbol > GetIterator(Isolate *isolate)
static Symbol * Cast(Data *data)
Definition: v8-primitive.h:823
static Local< Symbol > ForApi(Isolate *isolate, Local< String > description)
static Local< Symbol > GetSearch(Isolate *isolate)
static Local< Symbol > GetToPrimitive(Isolate *isolate)
static Local< Symbol > GetAsyncIterator(Isolate *isolate)
static Local< Symbol > GetIsConcatSpreadable(Isolate *isolate)
static Local< Symbol > New(Isolate *isolate, Local< String > description=Local< String >())
static Local< Symbol > GetReplace(Isolate *isolate)
static Local< Symbol > GetAsyncDispose(Isolate *isolate)
static Local< Symbol > GetToStringTag(Isolate *isolate)
static Local< Symbol > GetSplit(Isolate *isolate)
static Local< Symbol > GetUnscopables(Isolate *isolate)
static Local< Symbol > For(Isolate *isolate, Local< String > description)
Local< Value > Description(Isolate *isolate) const
static Local< Symbol > GetHasInstance(Isolate *isolate)
Definition: v8-primitive.h:920
static Uint32 * Cast(v8::Data *data)
Definition: v8-primitive.h:923
uint32_t Value() const
Definition: v8-value.h:32
Definition: v8-internal.h:874
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1748
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
Local< Primitive > Null(Isolate *isolate)
Definition: v8-primitive.h:1078
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1070
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1094
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1086
NewStringType
Definition: v8-primitive.h:107
Definition: v8-primitive.h:215
#define V8_EXPORT
Definition: v8config.h:849
#define V8_INLINE
Definition: v8config.h:513
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:627
#define V8_DEPRECATED(message)
Definition: v8config.h:619
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:684