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
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 V8_INLINE static Number* Cast(v8::Data* data) {
853#ifdef V8_ENABLE_CHECKS
854 CheckCast(data);
855#endif
856 return static_cast<Number*>(data);
857 }
858
859 private:
860 Number();
861 static void CheckCast(v8::Data* that);
862};
863
867class V8_EXPORT Integer : public Number {
868 public:
869 static Local<Integer> New(Isolate* isolate, int32_t value);
870 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
871 int64_t Value() const;
873#ifdef V8_ENABLE_CHECKS
874 CheckCast(data);
875#endif
876 return static_cast<Integer*>(data);
877 }
878
879 private:
880 Integer();
881 static void CheckCast(v8::Data* that);
882};
883
887class V8_EXPORT Int32 : public Integer {
888 public:
889 int32_t Value() const;
890 V8_INLINE static Int32* Cast(v8::Data* data) {
891#ifdef V8_ENABLE_CHECKS
892 CheckCast(data);
893#endif
894 return static_cast<Int32*>(data);
895 }
896
897 private:
898 Int32();
899 static void CheckCast(v8::Data* that);
900};
901
905class V8_EXPORT Uint32 : public Integer {
906 public:
907 uint32_t Value() const;
908 V8_INLINE static Uint32* Cast(v8::Data* data) {
909#ifdef V8_ENABLE_CHECKS
910 CheckCast(data);
911#endif
912 return static_cast<Uint32*>(data);
913 }
914
915 private:
916 Uint32();
917 static void CheckCast(v8::Data* that);
918};
919
923class V8_EXPORT BigInt : public Numeric {
924 public:
925 static Local<BigInt> New(Isolate* isolate, int64_t value);
926 static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
934 static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
935 int word_count, const uint64_t* words);
936
943 uint64_t Uint64Value(bool* lossless = nullptr) const;
944
950 int64_t Int64Value(bool* lossless = nullptr) const;
951
956 int WordCount() const;
957
966 void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
967
968 V8_INLINE static BigInt* Cast(v8::Data* data) {
969#ifdef V8_ENABLE_CHECKS
970 CheckCast(data);
971#endif
972 return static_cast<BigInt*>(data);
973 }
974
975 private:
976 BigInt();
977 static void CheckCast(v8::Data* that);
978};
979
981 using S = internal::Address;
982 using I = internal::Internals;
983 I::CheckInitialized(isolate);
984 S* slot = I::GetRootSlot(isolate, I::kEmptyStringRootIndex);
985 return Local<String>::FromSlot(slot);
986}
987
989 using A = internal::Address;
990 using I = internal::Internals;
992
994 if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
995 Isolate* isolate = I::GetIsolateForSandbox(obj);
996 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
997 isolate, obj, I::kStringResourceOffset);
998 result = reinterpret_cast<String::ExternalStringResource*>(value);
999 } else {
1000 result = GetExternalStringResourceSlow();
1001 }
1002#ifdef V8_ENABLE_CHECKS
1003 VerifyExternalStringResource(result);
1004#endif
1005 return result;
1006}
1007
1009 v8::Isolate* isolate, String::Encoding* encoding_out) const {
1010 using A = internal::Address;
1011 using I = internal::Internals;
1013 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1014 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1016 if (type == I::kExternalOneByteRepresentationTag ||
1017 type == I::kExternalTwoByteRepresentationTag) {
1018 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1019 isolate, obj, I::kStringResourceOffset);
1020 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1021 } else {
1022 resource = GetExternalStringResourceBaseSlow(encoding_out);
1023 }
1024#ifdef V8_ENABLE_CHECKS
1025 VerifyExternalStringResourceBase(resource, *encoding_out);
1026#endif
1027 return resource;
1028}
1029
1031 String::Encoding* encoding_out) const {
1032 using A = internal::Address;
1033 using I = internal::Internals;
1035 int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
1036 *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1038 if (type == I::kExternalOneByteRepresentationTag ||
1039 type == I::kExternalTwoByteRepresentationTag) {
1040 Isolate* isolate = I::GetIsolateForSandbox(obj);
1041 A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1042 isolate, obj, I::kStringResourceOffset);
1043 resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1044 } else {
1045 resource = GetExternalStringResourceBaseSlow(encoding_out);
1046 }
1047#ifdef V8_ENABLE_CHECKS
1048 VerifyExternalStringResourceBase(resource, *encoding_out);
1049#endif
1050 return resource;
1051}
1052
1053// --- Statics ---
1054
1056 using S = internal::Address;
1057 using I = internal::Internals;
1058 I::CheckInitialized(isolate);
1059 S* slot = I::GetRootSlot(isolate, I::kUndefinedValueRootIndex);
1060 return Local<Primitive>::FromSlot(slot);
1061}
1062
1064 using S = internal::Address;
1065 using I = internal::Internals;
1066 I::CheckInitialized(isolate);
1067 S* slot = I::GetRootSlot(isolate, I::kNullValueRootIndex);
1068 return Local<Primitive>::FromSlot(slot);
1069}
1070
1072 using S = internal::Address;
1073 using I = internal::Internals;
1074 I::CheckInitialized(isolate);
1075 S* slot = I::GetRootSlot(isolate, I::kTrueValueRootIndex);
1076 return Local<Boolean>::FromSlot(slot);
1077}
1078
1080 using S = internal::Address;
1081 using I = internal::Internals;
1082 I::CheckInitialized(isolate);
1083 S* slot = I::GetRootSlot(isolate, I::kFalseValueRootIndex);
1084 return Local<Boolean>::FromSlot(slot);
1085}
1086
1087Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
1088 return value ? True(isolate) : False(isolate);
1089}
1090
1091} // namespace v8
1092
1093#endif // INCLUDE_V8_PRIMITIVE_H_
Definition: v8-primitive.h:923
uint64_t Uint64Value(bool *lossless=nullptr) const
static BigInt * Cast(v8::Data *data)
Definition: v8-primitive.h:968
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:1087
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:887
static Int32 * Cast(v8::Data *data)
Definition: v8-primitive.h:890
int32_t Value() const
Definition: v8-primitive.h:867
static Integer * Cast(v8::Data *data)
Definition: v8-primitive.h:872
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:266
Definition: v8-local-handle.h:632
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 Number * Cast(v8::Data *data)
Definition: v8-primitive.h:852
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: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:1008
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:980
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:988
int Length() const
Definition: v8-primitive.h:780
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 > 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:905
static Uint32 * Cast(v8::Data *data)
Definition: v8-primitive.h:908
uint32_t Value() const
Definition: v8-value.h:32
Definition: v8-internal.h:830
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1676
uintptr_t Address
Definition: v8-internal.h:52
Definition: libplatform.h:15
Local< Primitive > Null(Isolate *isolate)
Definition: v8-primitive.h:1063
Local< Primitive > Undefined(Isolate *isolate)
Definition: v8-primitive.h:1055
Local< Boolean > False(Isolate *isolate)
Definition: v8-primitive.h:1079
Local< Boolean > True(Isolate *isolate)
Definition: v8-primitive.h:1071
NewStringType
Definition: v8-primitive.h:107
Definition: v8-primitive.h:215
#define V8_EXPORT
Definition: v8config.h:803
#define V8_INLINE
Definition: v8config.h:499
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:613
#define V8_DEPRECATED(message)
Definition: v8config.h:605
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:670