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
171 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
172
174 void (*)(Local<Name> property, Local<Value> value,
175 const PropertyCallbackInfo<void>& info);
176
186 SKIP_SYMBOLS = 16
188
199enum class SideEffectType {
203};
204
213
219
225
230
234class V8_EXPORT Object : public Value {
235 public:
241 Local<Value> key, Local<Value> value);
243 Local<Value> key, Local<Value> value,
244 MaybeLocal<Object> receiver);
245
247 Local<Value> value);
248
260 Local<Name> key,
261 Local<Value> value);
263 uint32_t index,
264 Local<Value> value);
265
276 Local<Context> context, Local<Name> key, Local<Value> value,
277 PropertyAttribute attributes = None);
278
296 Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor);
297
299 Local<Value> key);
301 Local<Value> key,
302 MaybeLocal<Object> receiver);
303
305 uint32_t index);
306
313 Local<Context> context, Local<Value> key);
314
320 Local<Context> context, Local<Name> key);
321
338 Local<Value> key);
339
341 Local<Value> key);
342
344
346 uint32_t index);
347
354 PropertyAttribute attributes = None);
355
361 Local<Context> context, Local<Name> name,
363 AccessorNameSetterCallback setter = nullptr,
364 Local<Value> data = Local<Value>(), PropertyAttribute attributes = None,
365 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
366 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
367
377 Local<Context> context, Local<Name> name,
379 PropertyAttribute attributes = None,
380 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
381 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
382
391 Local<Value> value);
394
402 Local<Context> context);
404 Local<Context> context, KeyCollectionMode mode,
405 PropertyFilter property_filter, IndexFilter index_filter,
406 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
407
414 Local<Context> context);
415
423 Local<Context> context, PropertyFilter filter,
424 KeyConversionMode key_conversion = KeyConversionMode::kKeepNumbers);
425
432
439 Local<Value> prototype);
440
446
453 Local<Context> context);
454
459
464
467
470 const PersistentBase<Object>& object) {
471 return object.template value<Object>()->InternalFieldCount();
472 }
473
476 const BasicTracedReference<Object>& object) {
477 return object.template value<Object>()->InternalFieldCount();
478 }
479
490 V8_INLINE Local<Data> GetInternalField(int index);
491
493 void SetInternalField(int index, Local<Data> data);
494
500 V8_INLINE void* GetAlignedPointerFromInternalField(int index,
502 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
503 int index,
505
507 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
508 "parameter instead.")
509 V8_INLINE void* GetAlignedPointerFromInternalField(int index) {
510 return GetAlignedPointerFromInternalField(index,
512 }
513
515 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
516 "parameter instead.")
517 V8_INLINE void* GetAlignedPointerFromInternalField(v8::Isolate* isolate,
518 int index) {
519 return GetAlignedPointerFromInternalField(isolate, index,
521 }
522
525 const PersistentBase<Object>& object, int index,
527 return object.template value<Object>()->GetAlignedPointerFromInternalField(
528 index, tag);
529 }
530
532 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
533 "parameter instead.")
534 V8_INLINE static void* GetAlignedPointerFromInternalField(
535 const PersistentBase<Object>& object, int index) {
536 return object.template value<Object>()->GetAlignedPointerFromInternalField(
537 index);
538 }
539
542 const BasicTracedReference<Object>& object, int index,
544 return object.template value<Object>()->GetAlignedPointerFromInternalField(
545 index, tag);
546 }
547
549 "Use GetAlignedPointerFromInternalField with EmbedderDataTypeTag "
550 "parameter instead.")
551 V8_INLINE static void* GetAlignedPointerFromInternalField(
552 const BasicTracedReference<Object>& object, int index) {
553 return object.template value<Object>()->GetAlignedPointerFromInternalField(
554 index);
555 }
556
562 void SetAlignedPointerInInternalField(int index, void* value,
564
566 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag parameter "
567 "instead.")
568 void SetAlignedPointerInInternalField(int index, void* value) {
569 SetAlignedPointerInInternalField(index, value, kEmbedderDataTypeTagDefault);
570 }
571
573 "Use SetAlignedPointerInInternalField with EmbedderDataTypeTag "
574 "parameter instead.")
575 void SetAlignedPointerInInternalFields(int argc, int indices[],
576 void* values[]);
577
578 // Type information for a Wrappable object that got wrapped with
579 // `v8::Object::Wrap()`.
581 const int16_t type_id;
582 };
583
584 // v8::Object::Wrappable serves as the base class for all C++ objects that can
585 // be wrapped by a JavaScript object using `v8::Object::Wrap()`.
586 //
587 // Note that v8::Object::Wrappable` inherits from `NameProvider` and provides
588 // `GetWrapperTypeInfo` to allow subclasses to have smaller object sizes.
589 class Wrappable : public cppgc::GarbageCollected<Wrappable>,
590 public cppgc::NameProvider {
591 public:
592 virtual const WrapperTypeInfo* GetWrapperTypeInfo() const {
593 return nullptr;
594 }
595
596 const char* GetHumanReadableName() const override { return "internal"; }
597
598 virtual void Trace(cppgc::Visitor* visitor) const {}
599 };
600
611 template <CppHeapPointerTag tag, typename T = void>
612 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
613 const v8::Local<v8::Object>& wrapper);
614 template <CppHeapPointerTag tag, typename T = void>
615 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
616 const PersistentBase<Object>& wrapper);
617 template <CppHeapPointerTag tag, typename T = void>
618 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
619 const BasicTracedReference<Object>& wrapper);
620
621 template <typename T = void>
622 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
623 const v8::Local<v8::Object>& wrapper,
624 CppHeapPointerTagRange tag_range);
625 template <typename T = void>
626 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
627 const PersistentBase<Object>& wrapper,
628 CppHeapPointerTagRange tag_range);
629 template <typename T = void>
630 static V8_INLINE T* Unwrap(v8::Isolate* isolate,
631 const BasicTracedReference<Object>& wrapper,
632 CppHeapPointerTagRange tag_range);
633
643 template <CppHeapPointerTag tag>
644 static V8_INLINE void Wrap(v8::Isolate* isolate,
645 const v8::Local<v8::Object>& wrapper,
646 Wrappable* wrappable);
647 template <CppHeapPointerTag tag>
648 static V8_INLINE void Wrap(v8::Isolate* isolate,
649 const PersistentBase<Object>& wrapper,
650 Wrappable* wrappable);
651 template <CppHeapPointerTag tag>
652 static V8_INLINE void Wrap(v8::Isolate* isolate,
653 const BasicTracedReference<Object>& wrapper,
654 Wrappable* wrappable);
655 static V8_INLINE void Wrap(v8::Isolate* isolate,
656 const v8::Local<v8::Object>& wrapper,
657 Wrappable* wrappable, CppHeapPointerTag tag);
658 static V8_INLINE void Wrap(v8::Isolate* isolate,
659 const PersistentBase<Object>& wrapper,
660 Wrappable* wrappable, CppHeapPointerTag tag);
661 static V8_INLINE void Wrap(v8::Isolate* isolate,
662 const BasicTracedReference<Object>& wrapper,
663 Wrappable* wrappable, CppHeapPointerTag tag);
664
665 // Version of Wrap() function for v8::Context::Global() objects.
666 // Unlike the functions above it wraps both JSGlobalProxy and its hidden
667 // prototype (JSGlobalObject or remote object).
668 static void WrapGlobal(v8::Isolate* isolate,
669 const v8::Local<v8::Object>& wrapper,
670 Wrappable* wrappable, CppHeapPointerTag tag);
671
672 // Checks that wrappables set on JSGlobalProxy and its hidden prototype are
673 // the same.
674 static bool CheckGlobalWrappable(v8::Isolate* isolate,
675 const v8::Local<v8::Object>& wrapper,
676 CppHeapPointerTagRange tag_range);
677
685 Local<Name> key);
687 uint32_t index);
702 Local<Name> key);
704 Local<Context> context, uint32_t index);
706 Local<Context> context, Local<Name> key);
707
713 Local<Context> context, Local<Name> key);
714
722 Local<Name> key);
723
730 Local<Context> context, Local<Name> key);
731
738 Local<Context> context, Local<Name> key);
739
742
745
754
763
770 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
771 MaybeLocal<Context> GetCreationContext();
772
778 Local<Context> GetCreationContextChecked(v8::Isolate* isolate);
779 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
780 Local<Context> GetCreationContextChecked();
781
783 V8_INLINE static MaybeLocal<Context> GetCreationContext(
784 v8::Isolate* isolate, const PersistentBase<Object>& object) {
785 return object.template value<Object>()->GetCreationContext(isolate);
786 }
787 V8_DEPRECATE_SOON("Use the version with the isolate argument.")
788 V8_INLINE static MaybeLocal<Context> GetCreationContext(
789 const PersistentBase<Object>& object);
790
805 void* GetAlignedPointerFromEmbedderDataInCreationContext(
806 v8::Isolate* isolate, int index, EmbedderDataTypeTag tag);
807 void* GetAlignedPointerFromEmbedderDataInCreationContext(
808 int index, EmbedderDataTypeTag tag);
809
811 "Use GetAlignedPointerFromEmbedderDataInCreationContext with "
812 "EmbedderDataTypeTag parameter instead.")
813 void* GetAlignedPointerFromEmbedderDataInCreationContext(v8::Isolate* isolate,
814 int index) {
815 return GetAlignedPointerFromEmbedderDataInCreationContext(
816 isolate, index, kEmbedderDataTypeTagDefault);
817 }
818
820 "Use GetAlignedPointerFromEmbedderDataInCreationContext with "
821 "EmbedderDataTypeTag parameter instead.")
822 void* GetAlignedPointerFromEmbedderDataInCreationContext(int index) {
823 return GetAlignedPointerFromEmbedderDataInCreationContext(
825 }
826
832 bool IsCallable() const;
833
837 bool IsConstructor() const;
838
850 bool IsApiWrapper() const;
851
857 bool IsUndetectable() const;
858
864 Local<Value> recv,
865 int argc,
866 Local<Value> argv[]);
867
874 Local<Context> context, int argc, Local<Value> argv[]);
875
886
887 static Local<Object> New(Isolate* isolate);
888
897 static Local<Object> New(Isolate* isolate, Local<Value> prototype_or_null,
898 Local<Name>* names, Local<Value>* values,
899 size_t length);
900
901 V8_INLINE static Object* Cast(Value* obj);
902
911 bool IsCodeLike(Isolate* isolate) const;
912
913 private:
914 static void* Unwrap(v8::Isolate* isolate, internal::Address wrapper_obj,
915 CppHeapPointerTagRange tag_range);
916 static void Wrap(v8::Isolate* isolate, internal::Address wrapper_obj,
917 CppHeapPointerTag tag, void* wrappable);
918
919 Object();
920 static void CheckCast(Value* obj);
921 Local<Data> SlowGetInternalField(int index);
922 void* SlowGetAlignedPointerFromInternalField(int index,
924 void* SlowGetAlignedPointerFromInternalField(v8::Isolate* isolate, int index,
926};
927
928// --- Implementation ---
929
931#ifndef V8_ENABLE_CHECKS
932 using A = internal::Address;
933 using I = internal::Internals;
935 // Fast path: If the object is a plain JSObject, which is the common case, we
936 // know where to find the internal fields and can return the value directly.
937 int instance_type = I::GetInstanceType(obj);
938 if (I::CanHaveInternalField(instance_type)) {
939 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
940 (I::kEmbedderDataSlotSize * index);
941 A value = I::ReadRawField<A>(obj, offset);
942#ifdef V8_COMPRESS_POINTERS
943 // We read the full pointer value and then decompress it in order to avoid
944 // dealing with potential endianness issues.
945 value = I::DecompressTaggedField(obj, static_cast<uint32_t>(value));
946#endif
947
948 auto* isolate = I::GetCurrentIsolate();
949 return Local<Data>::New(isolate, value);
950 }
951#endif
952 return SlowGetInternalField(index);
953}
954
956 int index,
958#if !defined(V8_ENABLE_CHECKS)
959 using A = internal::Address;
960 using I = internal::Internals;
962 // Fast path: If the object is a plain JSObject, which is the common case, we
963 // know where to find the internal fields and can return the value directly.
964 auto instance_type = I::GetInstanceType(obj);
965 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
966 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
967 (I::kEmbedderDataSlotSize * index) +
968 I::kEmbedderDataSlotExternalPointerOffset;
969 A value = I::ReadExternalPointerField(isolate, obj, offset,
971 return reinterpret_cast<void*>(value);
972 }
973#endif
974 return SlowGetAlignedPointerFromInternalField(isolate, index, tag);
975}
976
979#if !defined(V8_ENABLE_CHECKS)
980 using A = internal::Address;
981 using I = internal::Internals;
983 // Fast path: If the object is a plain JSObject, which is the common case, we
984 // know where to find the internal fields and can return the value directly.
985 auto instance_type = I::GetInstanceType(obj);
986 if (V8_LIKELY(I::CanHaveInternalField(instance_type))) {
987 int offset = I::kJSAPIObjectWithEmbedderSlotsHeaderSize +
988 (I::kEmbedderDataSlotSize * index) +
989 I::kEmbedderDataSlotExternalPointerOffset;
990 Isolate* isolate = I::GetCurrentIsolateForSandbox();
991 A value = I::ReadExternalPointerField(isolate, obj, offset,
993 return reinterpret_cast<void*>(value);
994 }
995#endif
996 return SlowGetAlignedPointerFromInternalField(index, tag);
997}
998
999// static
1000template <CppHeapPointerTag tag, typename T>
1002 CppHeapPointerTagRange tag_range(tag, tag);
1003 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1004#if !defined(V8_ENABLE_CHECKS)
1005 return internal::ReadCppHeapPointerField<T>(
1006 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1007#else // defined(V8_ENABLE_CHECKS)
1008 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1009#endif // defined(V8_ENABLE_CHECKS)
1010}
1011
1012// static
1013template <CppHeapPointerTag tag, typename T>
1015 CppHeapPointerTagRange tag_range(tag, tag);
1016 auto obj =
1017 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1018#if !defined(V8_ENABLE_CHECKS)
1019 return internal::ReadCppHeapPointerField<T>(
1020 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1021#else // defined(V8_ENABLE_CHECKS)
1022 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1023#endif // defined(V8_ENABLE_CHECKS)
1024}
1025
1026// static
1027template <CppHeapPointerTag tag, typename T>
1029 const BasicTracedReference<Object>& wrapper) {
1030 CppHeapPointerTagRange tag_range(tag, tag);
1031 auto obj =
1032 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1033#if !defined(V8_ENABLE_CHECKS)
1034 return internal::ReadCppHeapPointerField<T>(
1035 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1036#else // defined(V8_ENABLE_CHECKS)
1037 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1038#endif // defined(V8_ENABLE_CHECKS)
1039}
1040
1041// static
1042template <typename T>
1044 CppHeapPointerTagRange tag_range) {
1045 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1046#if !defined(V8_ENABLE_CHECKS)
1047 return internal::ReadCppHeapPointerField<T>(
1048 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1049#else // defined(V8_ENABLE_CHECKS)
1050 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1051#endif // defined(V8_ENABLE_CHECKS)
1052}
1053
1054// static
1055template <typename T>
1057 CppHeapPointerTagRange tag_range) {
1058 auto obj =
1059 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1060#if !defined(V8_ENABLE_CHECKS)
1061 return internal::ReadCppHeapPointerField<T>(
1062 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1063#else // defined(V8_ENABLE_CHECKS)
1064
1065 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1066#endif // defined(V8_ENABLE_CHECKS)
1067}
1068
1069// static
1070template <typename T>
1072 const BasicTracedReference<Object>& wrapper,
1073 CppHeapPointerTagRange tag_range) {
1074 auto obj =
1075 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1076#if !defined(V8_ENABLE_CHECKS)
1077 return internal::ReadCppHeapPointerField<T>(
1078 isolate, obj, internal::Internals::kJSObjectHeaderSize, tag_range);
1079#else // defined(V8_ENABLE_CHECKS)
1080 return reinterpret_cast<T*>(Unwrap(isolate, obj, tag_range));
1081#endif // defined(V8_ENABLE_CHECKS)
1082}
1083
1084// static
1085template <CppHeapPointerTag tag>
1086void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1087 v8::Object::Wrappable* wrappable) {
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 auto obj =
1097 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1098 Wrap(isolate, obj, tag, wrappable);
1099}
1100
1101// static
1102template <CppHeapPointerTag tag>
1104 const BasicTracedReference<Object>& wrapper,
1105 v8::Object::Wrappable* wrappable) {
1106 auto obj =
1107 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1108 Wrap(isolate, obj, tag, wrappable);
1109}
1110
1111// static
1112void Object::Wrap(v8::Isolate* isolate, const v8::Local<v8::Object>& wrapper,
1113 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1114 auto obj = internal::ValueHelper::ValueAsAddress(*wrapper);
1115 Wrap(isolate, obj, tag, wrappable);
1116}
1117
1118// static
1120 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1121 auto obj =
1122 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1123 Wrap(isolate, obj, tag, wrappable);
1124}
1125
1126// static
1128 const BasicTracedReference<Object>& wrapper,
1129 v8::Object::Wrappable* wrappable, CppHeapPointerTag tag) {
1130 auto obj =
1131 internal::ValueHelper::ValueAsAddress(wrapper.template value<Object>());
1132 Wrap(isolate, obj, tag, wrappable);
1133}
1134
1136#ifdef V8_ENABLE_CHECKS
1137 CheckCast(data);
1138#endif
1139 return reinterpret_cast<Private*>(data);
1140}
1141
1143#ifdef V8_ENABLE_CHECKS
1144 CheckCast(value);
1145#endif
1146 return static_cast<Object*>(value);
1147}
1148
1149} // namespace v8
1150
1151#endif // INCLUDE_V8_OBJECT_H_
Definition: garbage-collected.h:53
Definition: name-provider.h:26
Definition: visitor.h:75
Definition: v8-traced-handle.h:124
Definition: v8-context.h:48
Definition: v8-data.h:18
Definition: v8-isolate.h:291
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:590
const char * GetHumanReadableName() const override
Definition: v8-object.h:596
virtual const WrapperTypeInfo * GetWrapperTypeInfo() const
Definition: v8-object.h:592
virtual void Trace(cppgc::Visitor *visitor) const
Definition: v8-object.h:598
Definition: v8-object.h:234
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:1142
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 > 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:524
Maybe< bool > SetNativeDataProperty(Local< Context > context, Local< Name > name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter=nullptr, Local< Value > data=Local< Value >(), PropertyAttribute attributes=None, SideEffectType getter_side_effect_type=SideEffectType::kHasSideEffect, SideEffectType setter_side_effect_type=SideEffectType::kHasSideEffect)
static int InternalFieldCount(const PersistentBase< Object > &object)
Definition: v8-object.h:469
MaybeLocal< Value > GetRealNamedPropertyInPrototypeChain(Local< Context > context, Local< Name > key)
static int InternalFieldCount(const BasicTracedReference< Object > &object)
Definition: v8-object.h:475
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:977
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[])
MaybeLocal< Value > GetPrivate(Local< Context > context, Local< Private > key)
Maybe< bool > SetPrototypeV2(Local< Context > context, Local< Value > prototype)
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:541
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:1086
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:930
Local< Value > GetPrototypeV2()
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)
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:1001
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 > 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:1135
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:187
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:878
static const int kJSObjectHeaderSize
Definition: v8-internal.h:895
static Address ValueAsAddress(const T *value)
Definition: v8-internal.h:1723
ExternalPointerTag
Definition: v8-internal.h:548
uintptr_t Address
Definition: v8-internal.h:38
Definition: libplatform.h:15
IntegrityLevel
Definition: v8-object.h:229
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:212
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:171
SideEffectType
Definition: v8-object.h:199
IndexFilter
Definition: v8-object.h:218
KeyConversionMode
Definition: v8-object.h:224
CppHeapPointerTag
Definition: v8-sandbox.h:28
constexpr EmbedderDataTypeTag kEmbedderDataTypeTagDefault
Definition: v8-object.h:36
uint16_t EmbedderDataTypeTag
Definition: v8-object.h:34
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:175
PropertyFilter
Definition: v8-object.h:180
@ ONLY_CONFIGURABLE
Definition: v8-object.h:184
@ SKIP_SYMBOLS
Definition: v8-object.h:186
@ ONLY_WRITABLE
Definition: v8-object.h:182
@ ALL_PROPERTIES
Definition: v8-object.h:181
@ SKIP_STRINGS
Definition: v8-object.h:185
@ ONLY_ENUMERABLE
Definition: v8-object.h:183
Definition: v8-sandbox.h:70
Definition: v8-object.h:580
const int16_t type_id
Definition: v8-object.h:581
#define V8_EXPORT
Definition: v8config.h:855
#define V8_INLINE
Definition: v8config.h:508
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:622
#define V8_DEPRECATED(message)
Definition: v8config.h:614
#define V8_LIKELY(condition)
Definition: v8config.h:669
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:679