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 };
486
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
649 public:
651 WriteOptions options = REPLACE_INVALID_UTF8);
653 char* operator*() { return str_; }
654 const char* operator*() const { return str_; }
655 size_t length() const { return length_; }
656
657 // Disallow copying and assigning.
658 Utf8Value(const Utf8Value&) = delete;
659 void operator=(const Utf8Value&) = delete;
660
661 private:
662 char* str_;
663 size_t length_;
664 };
665
677 public:
679 "Prefer using String::ValueView if you can, or string->Write to a "
680 "buffer if you cannot.")
681 Value(Isolate* isolate, Local<v8::Value> obj);
683 uint16_t* operator*() { return str_; }
684 const uint16_t* operator*() const { return str_; }
685 uint32_t length() const { return length_; }
686
687 // Disallow copying and assigning.
688 Value(const Value&) = delete;
689 void operator=(const Value&) = delete;
690
691 private:
692 uint16_t* str_;
693 uint32_t length_;
694 };
695
707 public:
710 const uint8_t* data8() const {
711#if V8_ENABLE_CHECKS
712 CheckOneByte(true);
713#endif
714 return data8_;
715 }
716 const uint16_t* data16() const {
717#if V8_ENABLE_CHECKS
718 CheckOneByte(false);
719#endif
720 return data16_;
721 }
722 uint32_t length() const { return length_; }
723 bool is_one_byte() const { return is_one_byte_; }
724
725 // Disallow copying and assigning.
726 ValueView(const ValueView&) = delete;
727 void operator=(const ValueView&) = delete;
728
729 private:
730 void CheckOneByte(bool is_one_byte) const;
731
732 Local<v8::String> flat_str_;
733 union {
734 const uint8_t* data8_;
735 const uint16_t* data16_;
736 };
737 uint32_t length_;
738 bool is_one_byte_;
739 // Avoid exposing the internal DisallowGarbageCollection scope.
740 alignas(internal::Internals::
741 kDisallowGarbageCollectionAlign) char no_gc_debug_scope_
742 [internal::Internals::kDisallowGarbageCollectionSize];
743 };
744
745 private:
746 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
747 Encoding encoding) const;
748 void VerifyExternalStringResource(ExternalStringResource* val) const;
749 ExternalStringResource* GetExternalStringResourceSlow() const;
750 ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
751 String::Encoding* encoding_out) const;
752
753 static Local<v8::String> NewFromUtf8Literal(Isolate* isolate,
754 const char* literal,
755 NewStringType type, int length);
756
757 static void CheckCast(v8::Data* that);
758};
759
760// Zero-length string specialization (templated string size includes
761// terminator).
762template <>
764 Isolate* isolate, const char (&literal)[1], NewStringType type) {
765 return String::Empty(isolate);
766}
767
772 public:
773 virtual ~ExternalResourceVisitor() = default;
774 virtual void VisitExternalString(Local<String> string) {}
775};
776
780class V8_EXPORT Symbol : public Name {
781 public:
786
791 static Local<Symbol> New(Isolate* isolate,
792 Local<String> description = Local<String>());
793
802 static Local<Symbol> For(Isolate* isolate, Local<String> description);
803
808 static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
809
810 // Well-known symbols
824
825 V8_INLINE static Symbol* Cast(Data* data) {
826#ifdef V8_ENABLE_CHECKS
827 CheckCast(data);
828#endif
829 return static_cast<Symbol*>(data);
830 }
831
832 private:
833 Symbol();
834 static void CheckCast(Data* that);
835};
836
842 private:
843 Numeric();
844 static void CheckCast(v8::Data* that);
845};
846
850class V8_EXPORT Number : public Numeric {
851 public:
852 double Value() const;
853 static Local<Number> New(Isolate* isolate, double value);
854 V8_INLINE static Number* Cast(v8::Data* data) {
855#ifdef V8_ENABLE_CHECKS
856 CheckCast(data);
857#endif
858 return static_cast<Number*>(data);
859 }
860
861 private:
862 Number();
863 static void CheckCast(v8::Data* that);
864};
865
869class V8_EXPORT Integer : public Number {
870 public:
871 static Local<Integer> New(Isolate* isolate, int32_t value);
872 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
873 int64_t Value() const;
875#ifdef V8_ENABLE_CHECKS
876 CheckCast(data);
877#endif
878 return static_cast<Integer*>(data);
879 }
880
881 private:
882 Integer();
883 static void CheckCast(v8::Data* that);
884};
885
889class V8_EXPORT Int32 : public Integer {
890 public:
891 int32_t Value() const;
892 V8_INLINE static Int32* Cast(v8::Data* data) {
893#ifdef V8_ENABLE_CHECKS
894 CheckCast(data);
895#endif
896 return static_cast<Int32*>(data);
897 }
898
899 private:
900 Int32();
901 static void CheckCast(v8::Data* that);
902};
903
907class V8_EXPORT Uint32 : public Integer {
908 public:
909 uint32_t Value() const;
910 V8_INLINE static Uint32* Cast(v8::Data* data) {
911#ifdef V8_ENABLE_CHECKS
912 CheckCast(data);
913#endif
914 return static_cast<Uint32*>(data);
915 }
916
917 private:
918 Uint32();
919 static void CheckCast(v8::Data* that);
920};
921
925class V8_EXPORT BigInt : public Numeric {
926 public:
927 static Local<BigInt> New(Isolate* isolate, int64_t value);
928 static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
936 static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
937 int word_count, const uint64_t* words);
938
945 uint64_t Uint64Value(bool* lossless = nullptr) const;
946
952 int64_t Int64Value(bool* lossless = nullptr) const;
953
958 int WordCount() const;
959
968 void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
969
970 V8_INLINE static BigInt* Cast(v8::Data* data) {
971#ifdef V8_ENABLE_CHECKS
972 CheckCast(data);
973#endif
974 return static_cast<BigInt*>(data);
975 }
976
977 private:
978 BigInt();
979 static void CheckCast(v8::Data* that);
980};
981
983 using S = internal::Address;
984 using I = internal::Internals;
985 I::CheckInitialized(isolate);
986 S* slot = I::GetRootSlot(isolate, I::kEmptyStringRootIndex);
987 return Local<String>::FromSlot(slot);
988}
989
991 using A = internal::Address;
992 using I = internal::Internals;
994
996 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
997 Isolate* isolate = I::GetIsolateForSandbox(obj);
998 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
999 isolate, obj, I::kStringResourceOffset);
1000 result = reinterpret_cast<String::ExternalStringResource*>(value);
1001 } else {
1002 result = GetExternalStringResourceSlow();
1003 }
1004#ifdef V8_ENABLE_CHECKS
1005 VerifyExternalStringResource(result);
1006#endif
1007 return result;
1008}
1009
1011 v8::Isolate* isolate, String::Encoding* encoding_out) const {
1012 using A = internal::Address;
1013 using I = internal::Internals;
1015 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1016 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1018 if (type == I::kExternalOneByteRepresentationTag ||
1019 type == I::kExternalTwoByteRepresentationTag) {
1020 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1021 isolate, obj, I::kStringResourceOffset);
1022 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1023 } else {
1024 resource = GetExternalStringResourceBaseSlow(encoding_out);
1025 }
1026#ifdef V8_ENABLE_CHECKS
1027 VerifyExternalStringResourceBase(resource, *encoding_out);
1028#endif
1029 return resource;
1030}
1031
1033 String::Encoding* encoding_out) const {
1034 using A = internal::Address;
1035 using I = internal::Internals;
1037 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1038 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1040 if (type == I::kExternalOneByteRepresentationTag ||
1041 type == I::kExternalTwoByteRepresentationTag) {
1042 Isolate* isolate = I::GetIsolateForSandbox(obj);
1043 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1044 isolate, obj, I::kStringResourceOffset);
1045 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1046 } else {
1047 resource = GetExternalStringResourceBaseSlow(encoding_out);
1048 }
1049#ifdef V8_ENABLE_CHECKS
1050 VerifyExternalStringResourceBase(resource, *encoding_out);
1051#endif
1052 return resource;
1053}
1054
1055// --- Statics ---
1056
1058 using S = internal::Address;
1059 using I = internal::Internals;
1060 I::CheckInitialized(isolate);
1061 S* slot = I::GetRootSlot(isolate, I::kUndefinedValueRootIndex);
1062 return Local<Primitive>::FromSlot(slot);
1063}
1064
1066 using S = internal::Address;
1067 using I = internal::Internals;
1068 I::CheckInitialized(isolate);
1069 S* slot = I::GetRootSlot(isolate, I::kNullValueRootIndex);
1070 return Local<Primitive>::FromSlot(slot);
1071}
1072
1074 using S = internal::Address;
1075 using I = internal::Internals;
1076 I::CheckInitialized(isolate);
1077 S* slot = I::GetRootSlot(isolate, I::kTrueValueRootIndex);
1078 return Local<Boolean>::FromSlot(slot);
1079}
1080
1082 using S = internal::Address;
1083 using I = internal::Internals;
1084 I::CheckInitialized(isolate);
1085 S* slot = I::GetRootSlot(isolate, I::kFalseValueRootIndex);
1086 return Local<Boolean>::FromSlot(slot);
1087}
1088
1089Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
1090 return value ? True(isolate) : False(isolate);
1091}
1092
1093} // namespace v8
1094
1095#endif // INCLUDE_V8_PRIMITIVE_H_
Definition: v8-primitive.h:925
uint64_t Uint64Value(bool *lossless=nullptr) const
static BigInt * Cast(v8::Data *data)
Definition: v8-primitive.h:970
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:1089
static Boolean * Cast(v8::Data *data)
Definition: v8-primitive.h:38
Definition: v8-data.h:18
Definition: v8-primitive.h:771
virtual ~ExternalResourceVisitor()=default
virtual void VisitExternalString(Local< String > string)
Definition: v8-primitive.h:774
Definition: v8-primitive.h:889
static Int32 * Cast(v8::Data *data)
Definition: v8-primitive.h:892
int32_t Value() const
Definition: v8-primitive.h:869
static Integer * Cast(v8::Data *data)
Definition: v8-primitive.h:874
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:274
Definition: v8-local-handle.h:267
Definition: v8-local-handle.h:635
Definition: v8-primitive.h:79
static Name * Cast(Data *data)
Definition: v8-primitive.h:90
int GetIdentityHash()
Definition: v8-primitive.h:850
static Local< Number > New(Isolate *isolate, double value)
static Number * Cast(v8::Data *data)
Definition: v8-primitive.h:854
double Value() const
Definition: v8-primitive.h:841
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:648
char * operator*()
Definition: v8-primitive.h:653
Utf8Value(Isolate *isolate, Local< v8::Value > obj, WriteOptions options=REPLACE_INVALID_UTF8)
Utf8Value(const Utf8Value &)=delete
const char * operator*() const
Definition: v8-primitive.h:654
void operator=(const Utf8Value &)=delete
size_t length() const
Definition: v8-primitive.h:655
Definition: v8-primitive.h:706
bool is_one_byte() const
Definition: v8-primitive.h:723
const uint16_t * data16_
Definition: v8-primitive.h:735
void operator=(const ValueView &)=delete
const uint8_t * data8() const
Definition: v8-primitive.h:710
uint32_t length() const
Definition: v8-primitive.h:722
ValueView(const ValueView &)=delete
const uint16_t * data16() const
Definition: v8-primitive.h:716
ValueView(Isolate *isolate, Local< v8::String > str)
const uint8_t * data8_
Definition: v8-primitive.h:734
Definition: v8-primitive.h:676
const uint16_t * operator*() const
Definition: v8-primitive.h:684
uint32_t length() const
Definition: v8-primitive.h:685
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:1010
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:982
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:990
int Length() const
Definition: v8-primitive.h:780
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:825
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:907
static Uint32 * Cast(v8::Data *data)
Definition: v8-primitive.h:910
uint32_t Value() const
Definition: v8-value.h:32
Definition: v8-internal.h:842
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1688
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
Local< Primitive > Null(Isolate *isolate)
Definition: v8-primitive.h:1065
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1057
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1081
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1073
NewStringType
Definition: v8-primitive.h:107
Definition: v8-primitive.h:215
#define V8_EXPORT
Definition: v8config.h:800
#define V8_INLINE
Definition: v8config.h:500
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:614
#define V8_DEPRECATED(message)
Definition: v8config.h:606
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:671