Loading...
Searching...
No Matches
v8-object.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_OBJECT_H_
6#define INCLUDE_V8_OBJECT_H_
7
10#include "v8-internal.h" // NOLINT(build/include_directory)
11#include "v8-local-handle.h" // NOLINT(build/include_directory)
12#include "v8-maybe.h" // NOLINT(build/include_directory)
13#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
14#include "v8-primitive.h" // NOLINT(build/include_directory)
15#include "v8-sandbox.h" // NOLINT(build/include_directory)
16#include "v8-traced-handle.h" // NOLINT(build/include_directory)
17#include "v8-value.h" // NOLINT(build/include_directory)
18#include "v8config.h" // NOLINT(build/include_directory)
19
20namespace v8 {
21
22class Array;
23class Function;
24class FunctionTemplate;
25template <typename T>
26class PropertyCallbackInfo;
27
34using EmbedderDataTypeTag = uint16_t;
35
37
40
46class V8_EXPORT Private : public Data {
47 public:
52
56 static Local<Private> New(Isolate* isolate,
58
69
70 V8_INLINE static Private* Cast(Data* data);
71
72 private:
73 Private();
74
75 static void CheckCast(Data* that);
76};
77
107 public:
108 // GenericDescriptor
110
111 // DataDescriptor
113
114 // DataDescriptor with writable property
115 PropertyDescriptor(Local<Value> value, bool writable);
116
117 // AccessorDescriptor
119
121
123 bool has_value() const;
124
126 bool has_get() const;
128 bool has_set() const;
129
130 void set_enumerable(bool enumerable);
131 bool enumerable() const;
132 bool has_enumerable() const;
133
134 void set_configurable(bool configurable);
135 bool configurable() const;
136 bool has_configurable() const;
137
138 bool writable() const;
139 bool has_writable() const;
140
141 struct PrivateData;
142 PrivateData* get_private() const { return private_; }
143
145 void operator=(const PropertyDescriptor&) = delete;
146
147 private:
148 PrivateData* private_;
149};
150
156 None = 0,
158 ReadOnly = 1 << 0,
160 DontEnum = 1 << 1,
162 DontDelete = 1 << 2
164
180 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
181
202 void (*)(Local<Name> property, Local<Value> value,
204// TODO(https://crbug.com/348660658): deprecate and remove.
206 V8_DEPRECATE_SOON("Use AccessorNameSetterCallbackV2 instead.") =
207 void (*)(Local<Name> property, Local<Value> value,
208 const PropertyCallbackInfo<void>& info);
209
219 SKIP_SYMBOLS = 16
221
232enum class SideEffectType {
236};
237
246
252
258
263
267class V8_EXPORT Object : public Value {
268 public:
274 Local<Value> key, Local<Value> value);
276 Local<Value> key, Local<Value> value,
277 MaybeLocal<Object> receiver);
278
280 Local<Value> value);
281
293 Local<Name> key,
294 Local<Value> value);
296 uint32_t index,
297 Local<Value> value);
298
309 Local<Context> context, Local<Name> key, Local<Value> value,
310 PropertyAttribute attributes = None);
311
329 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
330
332 Local<Value> key);
334 Local<Value> key,
335 MaybeLocal<Object> receiver);
336
338 uint32_t index);
339
350 Local<Context> context, Local<Value> key);
360 Local<Context> context, Local<Value> key,
361 PropertyAttribute* out_attributes);
362
368 Local<Context> context, Local<Name> key);
369
386 Local<Value> key);
387
389 Local<Value> key);
390
392
394 uint32_t index);
395
402 PropertyAttribute attributes = None);
403
409 Local<Context> context, Local<Name> name,
411 AccessorNameSetterCallbackV2 setter = nullptr,
412 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
413 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
414 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
415
425 Local<Context> context, Local<Name> name,
427 PropertyAttribute attributes = None,
428 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
429 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
430
439 Local<Value> value);
442
450 Local<Context> context);
452 Local<Context> context, KeyCollectionMode mode,
453 PropertyFilter property_filter, IndexFilter index_filter,
454 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
455
462 Local<Context> context);
463
471 Local<Context> context, PropertyFilter filter,
472 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
473
479
485 Local<Value> prototype);
486
492
499 Local<Context> context);
500
505
510
513
516 const PersistentBase<Object>& object) {
517 return object.template value<Object>()->InternalFieldCount();
518 }
519
522 const BasicTracedReference<Object>& object) {
523 return object.template value<Object>()->InternalFieldCount();
524 }
525
536 V8_INLINE Local<Data> GetInternalField(int index);
537
539 void SetInternalField(int index, Local<Data> data);
540
546 V8_INLINE void* GetAlignedPointerFromInternalField(int index,
548 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
549 int index,
551
554 const PersistentBase<Object>& object, int index,
556 return object.template value<Object>()->GetAlignedPointerFromInternalField(
557 index, tag);
558 }
559
562 const BasicTracedReference<Object>& object, int index,
564 return object.template value<Object>()->GetAlignedPointerFromInternalField(
565 index, tag);
566 }
567
573 void SetAlignedPointerInInternalField(int index, void* value,
575
576 // Type information for a Wrappable object that got wrapped with
577 // `v8::Object::Wrap()`.
579 const int16_t type_id;
580 };
581
582 // v8::Object::Wrappable serves as the base class for all C++ objects that can
583 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
584 //
585 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
586 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
587 class Wrappable : public cppgc::GarbageCollected<Wrappable>,
588 public cppgc::NameProvider {
589 public:
590 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
591 return nullptr;
592 }
593
594 const char* GetHumanReadableName() const override { return "internal"; }
595
596 virtual void Trace(cppgc::Visitor* visitor) const {}
597 };
598
609 template <CppHeapPointerTag tag, typename T = void>
610 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
611 const v8::Local<v8::Object>& wrapper);
612 template <CppHeapPointerTag tag, typename T = void>
613 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
614 const PersistentBase<Object>& wrapper);
615 template <CppHeapPointerTag tag, typename T = void>
616 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
617 const BasicTracedReference<Object>& wrapper);
618
619 template <typename T = void>
620 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
621 const v8::Local<v8::Object>& wrapper,
622 CppHeapPointerTagRange tag_range);
623 template <typename T = void>
624 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
625 const PersistentBase<Object>& wrapper,
626 CppHeapPointerTagRange tag_range);
627 template <typename T = void>
628 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
629 const BasicTracedReference<Object>& wrapper,
630 CppHeapPointerTagRange tag_range);
631
641 template <CppHeapPointerTag tag>
642 static V8_INLINE void Wrap(v8::Isolate* isolate,
643 const v8::Local<v8::Object>& wrapper,
644 Wrappable* wrappable);
645 template <CppHeapPointerTag tag>
646 static V8_INLINE void Wrap(v8::Isolate* isolate,
647 const PersistentBase<Object>& wrapper,
648 Wrappable* wrappable);
649 template <CppHeapPointerTag tag>
650 static V8_INLINE void Wrap(v8::Isolate* isolate,
651 const BasicTracedReference<Object>& wrapper,
652 Wrappable* wrappable);
653 static V8_INLINE void Wrap(v8::Isolate* isolate,
654 const v8::Local<v8::Object>& wrapper,
655 Wrappable* wrappable, CppHeapPointerTag tag);
656 static V8_INLINE void Wrap(v8::Isolate* isolate,
657 const PersistentBase<Object>& wrapper,
658 Wrappable* wrappable, CppHeapPointerTag tag);
659 static V8_INLINE void Wrap(v8::Isolate* isolate,
660 const BasicTracedReference<Object>& wrapper,
661 Wrappable* wrappable, CppHeapPointerTag tag);
662
663 // Version of Wrap() function for v8::Context::Global() objects.
664 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
665 // prototype (JSGlobalObject or remote object).
666 static void WrapGlobal(v8::Isolate* isolate,
667 const v8::Local<v8::Object>& wrapper,
668 Wrappable* wrappable, CppHeapPointerTag tag);
669
670 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
671 // the same.
672 static bool CheckGlobalWrappable(v8::Isolate* isolate,
673 const v8::Local<v8::Object>& wrapper,
674 CppHeapPointerTagRange tag_range);
675
683 Local<Name> key);
685 uint32_t index);
700 Local<Name> key);
702 Local<Context> context, uint32_t index);
704 Local<Context> context, Local<Name> key);
705
711 Local<Context> context, Local<Name> key);
712
720 Local<Name> key);
721
728 Local<Context> context, Local<Name> key);
729
736 Local<Context> context, Local<Name> key);
737
740
743
752
761
768 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
769 MaybeLocal<Context> GetCreationContext();
770
776 Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
777 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
778 Local<Context> GetCreationContextChecked();
779
781 V8_INLINE static MaybeLocal<Context> GetCreationContext(
782 v8::Isolate* isolate, const PersistentBase<Object>& object) {
783 return object.template value<Object>()->GetCreationContext(isolate);
784 }
785 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
786 V8_INLINE static MaybeLocal<Context> GetCreationContext(
787 const PersistentBase<Object>& object);
788
808 void* GetAlignedPointerFromEmbedderDataInCreationContext(
809 v8::Isolate* isolate, int index, EmbedderDataTypeTag tag);
810 void* GetAlignedPointerFromEmbedderDataInCreationContext(
811 int index, EmbedderDataTypeTag tag);
812
813 void* GetAlignedPointerFromEmbedderDataInCreationContext(
814 v8::Isolate* isolate, int index, CppHeapPointerTag tag) {
815 // TODO(ahaas): This is a temporary implementation, the actual
816 // implementation will follow with the refactoring of EmbedderDataSlots.
817 // The refactoring will regress the existing API, as the fast path will move
818 // to this new API.
819 // By using this temporary implementation, blink's ScriptState can already
820 // switch to the new API, and thereby switch from the old fast path to the
821 // new fast path directly.
822 return GetAlignedPointerFromEmbedderDataInCreationContext(
823 isolate, index, kEmbedderDataTypeTagDefault);
824 }
830 bool IsCallable() const;
831
835 bool IsConstructor() const;
836
848 bool IsApiWrapper() const;
849
855 bool IsUndetectable() const;
856
862 Local<Value> recv,
863 int argc,
864 Local<Value> argv[]);
865
872 Local<Context> context, int argc, Local<Value> argv[]);
873
884
885 static Local<Object> New(Isolate* isolate);
886
895 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
896 Local<Name>* names, Local<Value>* values,
897 size_t length);
898
899 V8_INLINE static Object* Cast(Value* obj);
900
909 bool IsCodeLike(Isolate* isolate) const;
910
911 private:
912 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
913 CppHeapPointerTagRange tag_range);
914 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
915 CppHeapPointerTag tag, void* wrappable);
916
917 Object();
918 static void CheckCast(Value* obj);
919 Local<Data> SlowGetInternalField(int index);
920 void* SlowGetAlignedPointerFromInternalField(int index,
922 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index,
924};
925
926// --- Implementation ---
927
929#ifndef V8_ENABLE_CHECKS
930 using A = internal::Address;
931 using I = internal::Internals;
933 // Fast path: If the object is a plain JSObject, which is the common case, we
934 // know where to find the internal fields and can return the value directly.
935 int instance_type = I::GetInstanceType(obj);
936 if (I::CanHaveInternalField(instance_type)) {
937 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
938 (I::kEmbedderDataSlotSize * index);
939 A value = I::ReadRawField<A>(obj, offset);
940#ifdef V8_COMPRESS_POINTERS
941 // We read the full pointer value and then decompress it in order to avoid
942 // dealing with potential endianness issues.
943 value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
944#endif
945
946 auto* isolate = I::GetCurrentIsolate();
947 return Local<Data>::New(isolate, value);
948 }
949#endif
950 return SlowGetInternalField(index);
951}
952
954 int index,
956#if !defined(V8_ENABLE_CHECKS)
957 using A = internal::Address;
958 using I = internal::Internals;
960 // Fast path: If the object is a plain JSObject, which is the common case, we
961 // know where to find the internal fields and can return the value directly.
962 auto instance_type = I::GetInstanceType(obj);
963 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
964 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
965 (I::kEmbedderDataSlotSize * index) +
966 I::kEmbedderDataSlotExternalPointerOffset;
967 A value = I::ReadExternalPointerField(isolate, obj, offset,
969 return reinterpret_cast<void*>(value);
970 }
971#endif
972 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
973}
974
977#if !defined(V8_ENABLE_CHECKS)
978 using A = internal::Address;
979 using I = internal::Internals;
981 // Fast path: If the object is a plain JSObject, which is the common case, we
982 // know where to find the internal fields and can return the value directly.
983 auto instance_type = I::GetInstanceType(obj);
984 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
985 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
986 (I::kEmbedderDataSlotSize * index) +
987 I::kEmbedderDataSlotExternalPointerOffset;
988 Isolate* isolate = I::GetCurrentIsolateForSandbox();
989 A value = I::ReadExternalPointerField(isolate, obj, offset,
991 return reinterpret_cast<void*>(value);
992 }
993#endif
994 return SlowGetAlignedPointerFromInternalField(index, tag);
995}
996
997// static
998template <CppHeapPointerTag tag, typename T>
1000 CppHeapPointerTagRange tag_range(tag, tag);
1001 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1002#if !defined(V8_ENABLE_CHECKS)
1003 return internal::ReadCppHeapPointerField<T>(
1004 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1005#else // defined(V8_ENABLE_CHECKS)
1006 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1007#endif // defined(V8_ENABLE_CHECKS)
1008}
1009
1010// static
1011template <CppHeapPointerTag tag, typename T>
1013 CppHeapPointerTagRange tag_range(tag, tag);
1014 auto obj =
1015 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1016#if !defined(V8_ENABLE_CHECKS)
1017 return internal::ReadCppHeapPointerField<T>(
1018 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1019#else // defined(V8_ENABLE_CHECKS)
1020 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1021#endif // defined(V8_ENABLE_CHECKS)
1022}
1023
1024// static
1025template <CppHeapPointerTag tag, typename T>
1027 const BasicTracedReference<Object>& wrapper) {
1028 CppHeapPointerTagRange tag_range(tag, tag);
1029 auto obj =
1030 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1031#if !defined(V8_ENABLE_CHECKS)
1032 return internal::ReadCppHeapPointerField<T>(
1033 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1034#else // defined(V8_ENABLE_CHECKS)
1035 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1036#endif // defined(V8_ENABLE_CHECKS)
1037}
1038
1039// static
1040template <typename T>
1042 CppHeapPointerTagRange tag_range) {
1043 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1044#if !defined(V8_ENABLE_CHECKS)
1045 return internal::ReadCppHeapPointerField<T>(
1046 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1047#else // defined(V8_ENABLE_CHECKS)
1048 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1049#endif // defined(V8_ENABLE_CHECKS)
1050}
1051
1052// static
1053template <typename T>
1055 CppHeapPointerTagRange tag_range) {
1056 auto obj =
1057 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1058#if !defined(V8_ENABLE_CHECKS)
1059 return internal::ReadCppHeapPointerField<T>(
1060 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1061#else // defined(V8_ENABLE_CHECKS)
1062
1063 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1064#endif // defined(V8_ENABLE_CHECKS)
1065}
1066
1067// static
1068template <typename T>
1070 const BasicTracedReference<Object>& wrapper,
1071 CppHeapPointerTagRange tag_range) {
1072 auto obj =
1073 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1074#if !defined(V8_ENABLE_CHECKS)
1075 return internal::ReadCppHeapPointerField<T>(
1076 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1077#else // defined(V8_ENABLE_CHECKS)
1078 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1079#endif // defined(V8_ENABLE_CHECKS)
1080}
1081
1082// static
1083template <CppHeapPointerTag tag>
1084void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1085 v8::Object::Wrappable* wrappable) {
1086 static_assert(kObjectWrappableTagRange.Contains(tag),
1087 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1088 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1089 Wrap(isolate, obj, tag, wrappable);
1090}
1091
1092// static
1093template <CppHeapPointerTag tag>
1095 v8::Object::Wrappable* wrappable) {
1096 static_assert(kObjectWrappableTagRange.Contains(tag),
1097 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1098 auto obj =
1099 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1100 Wrap(isolate, obj, tag, wrappable);
1101}
1102
1103// static
1104template <CppHeapPointerTag tag>
1106 const BasicTracedReference<Object>& wrapper,
1107 v8::Object::Wrappable* wrappable) {
1108 static_assert(kObjectWrappableTagRange.Contains(tag),
1109 "CppHeapPointerTag must be within kObjectWrappableTagRange");
1110 auto obj =
1111 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1112 Wrap(isolate, obj, tag, wrappable);
1113}
1114
1115// static
1116void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1117 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1118 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1119 Wrap(isolate, obj, tag, wrappable);
1120}
1121
1122// static
1124 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1125 auto obj =
1126 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1127 Wrap(isolate, obj, tag, wrappable);
1128}
1129
1130// static
1132 const BasicTracedReference<Object>& wrapper,
1133 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1134 auto obj =
1135 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1136 Wrap(isolate, obj, tag, wrappable);
1137}
1138
1140#ifdef V8_ENABLE_CHECKS
1141 CheckCast(data);
1142#endif
1143 return reinterpret_cast<Private*>(data);
1144}
1145
1147#ifdef V8_ENABLE_CHECKS
1148 CheckCast(value);
1149#endif
1150 return static_cast<Object*>(value);
1151}
1152
1153} // namespace v8
1154
1155#endif // INCLUDE_V8_OBJECT_H_
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: visitor.h:78
Definition: v8-traced-handle.h:124
Definition: v8-context.h:53
Definition: v8-data.h:18
Definition: v8-isolate.h:292
Definition: v8-local-handle.h:366
static Local< T > New(Isolate *isolate, Local< T > that)
Definition: v8-local-handle.h:448
Definition: v8-local-handle.h:734
Definition: v8-maybe.h:39
Definition: v8-object.h:588
const char * GetHumanReadableName() const override
Definition: v8-object.h:594
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:590
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:596
Definition: v8-object.h:267
Maybe< PropertyAttribute > GetRealNamedPropertyAttributesInPrototypeChain(Local< Context > context, Local< Name > key)
Maybe< PropertyAttribute > GetPropertyAttributes(Local< Context > context, Local< Value > key)
Maybe< bool > CreateDataProperty(Local< Context > context, uint32_t index, Local< Value > value)
MaybeLocal< Value > GetOwnPropertyDescriptor(Local< Context > context, Local< Name > key)
static Object * Cast(Value *obj)
Definition: v8-object.h:1146
bool HasNamedLookupInterceptor() const
Maybe< bool > SetPrivate(Local< Context > context, Local< Private > key, Local< Value > value)
Maybe< bool > HasRealNamedProperty(Local< Context > context, Local< Name > key)
MaybeLocal< Array > GetPropertyNames(Local< Context > context)
Maybe< bool > Delete(Local< Context > context, uint32_t index)
MaybeLocal< Value > GetRealNamedProperty(Local< Context > context, Local< Name > key)
Maybe< bool > DefineProperty(Local< Context > context, Local< Name > key, PropertyDescriptor &descriptor)
Maybe< bool > SetPrototype(Local< Context > context, Local< Value > prototype)
Maybe< bool > Delete(Local< Context > context, Local< Value > key)
bool IsConstructor() const
bool IsUndetectable() const
MaybeLocal< Value > CallAsFunction(Local< Context > context, Local< Value > recv, int argc, Local< Value > argv[])
Local< Object > Clone()
Maybe< bool > DefineOwnProperty(Local< Context > context, Local< Name > key, Local< Value > value, PropertyAttribute attributes=None)
static void * GetAlignedPointerFromInternalField(const PersistentBase< Object > &object, int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:553
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:515
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:521
Maybe< bool > Has(Local< Context > context, Local< Value > key)
void SetAlignedPointerInInternalField(int index, void *value, EmbedderDataTypeTag tag)
void * GetAlignedPointerFromInternalField(int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:975
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context)
bool IsCodeLike(Isolate *isolate) const
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value)
MaybeLocal< Value > CallAsConstructor(Local< Context > context, int argc, Local< Value > argv[])
Local< Value > GetPrototype()
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
void SetAccessorProperty(Local< Name > name, Local< Function > getter, Local< Function > setter=Local< Function >(), PropertyAttribute attributes=None)
Maybe< bool > CreateDataProperty(Local< Context > context, Local< Name > key, Local< Value > value)
static void * GetAlignedPointerFromInternalField(const BasicTracedReference< Object > &object, int index, EmbedderDataTypeTag tag)
Definition: v8-object.h:561
Maybe< bool > HasRealIndexedProperty(Local< Context > context, uint32_t index)
MaybeLocal< String > ObjectProtoToString(Local< Context > context)
Maybe< bool > SetLazyDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
bool IsApiWrapper() const
static void Wrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable)
Definition: v8-object.h:1084
MaybeLocal< Value > Get(Local< Context > context, uint32_t index)
static void WrapGlobal(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, Wrappable *wrappable, CppHeapPointerTag tag)
Maybe< bool > SetIntegrityLevel(Local< Context > context, IntegrityLevel level)
MaybeLocal< Array > GetPropertyNames(Local< Context > context, KeyCollectionMode mode, PropertyFilter property_filter, IndexFilter index_filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
int InternalFieldCount() const
Local< Data > GetInternalField(int index)
Definition: v8-object.h:928
Maybe< PropertyAttribute > GetRealNamedPropertyAttributes(Local< Context > context, Local< Name > key)
static bool CheckGlobalWrappable(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper, CppHeapPointerTagRange tag_range)
Maybe< bool > HasPrivate(Local< Context > context, Local< Private > key)
Maybe< bool > GetPropertyAttributes(Local< Context > context, Local< Value > key, PropertyAttribute *out_attributes)
Local< Object > FindInstanceInPrototypeChain(Local< FunctionTemplate > tmpl)
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key)
static Local< Object > New(Isolate *isolate)
int GetIdentityHash()
MaybeLocal< Context > GetCreationContext(v8::Isolate *isolate)
void SetInternalField(int index, Local< Data > data)
static T * Unwrap(v8::Isolate *isolate, const v8::Local< v8::Object > &wrapper)
Definition: v8-object.h:999
MaybeLocal< Array > GetOwnPropertyNames(Local< Context > context, PropertyFilter filter, KeyConversionMode key_conversion=KeyConversionMode::kKeepNumbers)
Maybe< bool > Set(Local< Context > context, uint32_t index, Local< Value > value)
Local< Object > Clone(v8::Isolate *isolate)
Maybe< bool > HasOwnProperty(Local< Context > context, Local< Name > key)
Maybe< bool > Has(Local< Context > context, uint32_t index)
MaybeLocal< Array > PreviewEntries(bool *is_key_value)
bool IsCallable() const
Maybe< bool > DeletePrivate(Local< Context > context, Local< Private > key)
Local< String > GetConstructorName()
MaybeLocal< Value > Get(Local< Context > context, Local< Value > key, MaybeLocal< Object > receiver)
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallbackV2 setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
Maybe< bool > HasRealNamedCallbackProperty(Local< Context > context, Local< Name > key)
Maybe< bool > Set(Local< Context > context, Local< Value > key, Local< Value > value, MaybeLocal< Object > receiver)
Maybe< bool > HasOwnProperty(Local< Context > context, uint32_t index)
static Local< Object > New(Isolate *isolate, Local< Value > prototype_or_null, Local< Name > *names, Local< Value > *values, size_t length)
bool HasIndexedLookupInterceptor() const
Definition: v8-persistent-handle.h:93
Definition: v8-object.h:46
static Private * Cast(Data *data)
Definition: v8-object.h:1139
Local< Value > Name() const
static Local< Private > ForApi(Isolate *isolate, Local< String > name)
static Local< Private > New(Isolate *isolate, Local< String > name=Local< String >())
Definition: v8-function-callback.h:224
Definition: v8-object.h:106
void set_enumerable(bool enumerable)
bool has_writable() const
bool has_value() const
Local< Value > get() const
Local< Value > set() const
PropertyDescriptor(Local< Value > get, Local< Value > set)
bool has_enumerable() const
PropertyDescriptor(Local< Value > value)
PrivateData * get_private() const
Definition: v8-object.h:142
void operator=(const PropertyDescriptor &)=delete
Local< Value > value() const
bool enumerable() const
PropertyDescriptor(Local< Value > value, bool writable)
void set_configurable(bool configurable)
PropertyDescriptor(const PropertyDescriptor &)=delete
bool has_configurable() const
bool configurable() const
Definition: v8-value.h:32
Definition: v8-internal.h:975
static const int kJSObjectHeaderSize
Definition: v8-internal.h:992
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1850
ExternalPointerTag
Definition: v8-internal.h:673
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:262
PropertyAttribute
Definition: v8-object.h:154
@ DontEnum
Definition: v8-object.h:160
@ None
Definition: v8-object.h:156
@ DontDelete
Definition: v8-object.h:162
@ ReadOnly
Definition: v8-object.h:158
internal::ExternalPointerTag ToExternalPointerTag(v8::EmbedderDataTypeTag api_tag)
KeyCollectionMode
Definition: v8-object.h:245
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:180
SideEffectType
Definition: v8-object.h:232
IndexFilter
Definition: v8-object.h:251
KeyConversionMode
Definition: v8-object.h:257
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:36
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:203
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:208
constexpr CppHeapPointerTagRange kObjectWrappableTagRange(CppHeapPointerTag::kFirstObjectWrappableTag, CppHeapPointerTag::kLastObjectWrappableTag)
PropertyFilter
Definition: v8-object.h:213
@ ONLY_CONFIGURABLE
Definition: v8-object.h:217
@ SKIP_SYMBOLS
Definition: v8-object.h:219
@ ONLY_WRITABLE
Definition: v8-object.h:215
@ ALL_PROPERTIES
Definition: v8-object.h:214
@ SKIP_STRINGS
Definition: v8-object.h:218
@ ONLY_ENUMERABLE
Definition: v8-object.h:216
Definition: v8-object.h:578
const int16_t type_id
Definition: v8-object.h:579
Definition: v8-internal.h:517
constexpr bool Contains(Tag tag) const
Definition: v8-internal.h:552
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:624
#define V8_LIKELY(condition)
Definition: v8config.h:671
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:681