v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-template.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_TEMPLATE_H_
6#define INCLUDE_V8_TEMPLATE_H_
7
8#include <cstddef>
9#include <string_view>
10
11#include "v8-data.h" // NOLINT(build/include_directory)
12#include "v8-function-callback.h" // NOLINT(build/include_directory)
13#include "v8-local-handle.h" // NOLINT(build/include_directory)
14#include "v8-memory-span.h" // NOLINT(build/include_directory)
15#include "v8-object.h" // NOLINT(build/include_directory)
16#include "v8config.h" // NOLINT(build/include_directory)
17
18namespace v8 {
19
20class CFunction;
21class FunctionTemplate;
22class ObjectTemplate;
23class Signature;
24
25// --- Templates ---
26
27#define V8_INTRINSICS_LIST(F) \
28 F(ArrayProto_entries, array_entries_iterator) \
29 F(ArrayProto_forEach, array_for_each_iterator) \
30 F(ArrayProto_keys, array_keys_iterator) \
31 F(ArrayProto_values, array_values_iterator) \
32 F(ArrayPrototype, initial_array_prototype) \
33 F(AsyncIteratorPrototype, initial_async_iterator_prototype) \
34 F(ErrorPrototype, initial_error_prototype) \
35 F(IteratorPrototype, initial_iterator_prototype) \
36 F(MapIteratorPrototype, initial_map_iterator_prototype) \
37 F(ObjProto_valueOf, object_value_of_function) \
38 F(SetIteratorPrototype, initial_set_iterator_prototype)
39
41#define V8_DECL_INTRINSIC(name, iname) k##name,
43#undef V8_DECL_INTRINSIC
44};
45
49class V8_EXPORT Template : public Data {
50 public:
56 void Set(Local<Name> name, Local<Data> value,
57 PropertyAttribute attributes = None);
59 PropertyAttribute attributes = None);
60 V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value,
61 PropertyAttribute attributes = None);
62
64 Local<Name> name,
67 PropertyAttribute attribute = None);
68
83 V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead")
84 void SetNativeDataProperty(
87 PropertyAttribute attribute, AccessControl settings,
88 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
89 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
90 V8_DEPRECATE_SOON("Use SetNativeDataProperty without AccessControl instead")
91 void SetNativeDataProperty(
94 PropertyAttribute attribute, AccessControl settings,
95 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
96 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
97 V8_DEPRECATE_SOON("Use SetNativeDataProperty with Local<Name> instead")
98 void SetNativeDataProperty(
100 AccessorSetterCallback setter = nullptr,
101 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
102 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
103 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
104 void SetNativeDataProperty(
106 AccessorNameSetterCallback setter = nullptr,
107 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
108 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
109 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
110
115 void SetLazyDataProperty(
117 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
118 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
119 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
120
125 void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
126 PropertyAttribute attribute = None);
127
128 private:
129 Template();
130
131 friend class ObjectTemplate;
132 friend class FunctionTemplate;
133};
134
139enum class Intercepted : uint8_t { kNo = 0, kYes = 1 };
140
184 Local<Name> property, const PropertyCallbackInfo<Value>& info);
185// This variant will be deprecated soon.
186//
187// Use `info.GetReturnValue().Set()` to set the return value of the
188// intercepted get request. If the property does not exist the callback should
189// not set the result and must not produce side effects.
191 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
192
212 Intercepted (*)(Local<Name> property, Local<Value> value,
213 const PropertyCallbackInfo<void>& info);
214// This variant will be deprecated soon.
215//
216// Use `info.GetReturnValue()` to indicate whether the request was intercepted
217// or not. If the setter successfully intercepts the request, i.e., if the
218// request should not be further executed, call
219// `info.GetReturnValue().Set(value)`. If the setter did not intercept the
220// request, i.e., if the request should be handled as if no interceptor is
221// present, do not not call `Set()` and do not produce side effects.
223 void (*)(Local<Name> property, Local<Value> value,
224 const PropertyCallbackInfo<Value>& info);
225
252 Local<Name> property, const PropertyCallbackInfo<Integer>& info);
253// This variant will be deprecated soon.
254//
255// Use `info.GetReturnValue().Set(value)` to set the property attributes. The
256// value is an integer encoding a `v8::PropertyAttribute`. If the property does
257// not exist the callback should not set the result and must not produce side
258// effects.
260 void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
261
286 Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
287// This variant will be deprecated soon.
288//
289// Use `info.GetReturnValue()` to indicate whether the request was intercepted
290// or not. If the deleter successfully intercepts the request, i.e., if the
291// request should not be further executed, call
292// `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
293// used as the return value of `delete`. If the deleter does not intercept the
294// request then it should not set the result and must not produce side effects.
296 void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
297
305 void (*)(const PropertyCallbackInfo<Array>& info);
306// This variant will be deprecated soon.
307// This is just a renaming of the typedef.
309
329 Intercepted (*)(Local<Name> property, const PropertyDescriptor& desc,
330 const PropertyCallbackInfo<void>& info);
331// This variant will be deprecated soon.
332//
333// Use `info.GetReturnValue()` to indicate whether the request was intercepted
334// or not. If the definer successfully intercepts the request, i.e., if the
335// request should not be further executed, call
336// `info.GetReturnValue().Set(value)`. If the definer did not intercept the
337// request, i.e., if the request should be handled as if no interceptor is
338// present, do not not call `Set()` and do not produce side effects.
340 void (*)(Local<Name> property, const PropertyDescriptor& desc,
341 const PropertyCallbackInfo<Value>& info);
342
367 Local<Name> property, const PropertyCallbackInfo<Value>& info);
368// This variant will be deprecated soon.
369//
370// Use `info.GetReturnValue().Set()` to set the return value of the
371// intercepted request. The return value must be an object that
372// can be converted to a PropertyDescriptor, e.g., a `v8::Value` returned from
373// `v8::Object::getOwnPropertyDescriptor`.
375 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
376
377// TODO(ishell): Rename IndexedPropertyXxxCallbackV2 back to
378// IndexedPropertyXxxCallback once the old IndexedPropertyXxxCallback is
379// removed.
380
385 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
386// This variant will be deprecated soon.
388 void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
389
394 uint32_t index, Local<Value> value, const PropertyCallbackInfo<void>& info);
395// This variant will be deprecated soon.
397 void (*)(uint32_t index, Local<Value> value,
398 const PropertyCallbackInfo<Value>& info);
399
404 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
405// This variant will be deprecated soon.
407 void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
408
413 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
414// This variant will be deprecated soon.
416 void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
417
425 void (*)(const PropertyCallbackInfo<Array>& info);
426
431 Intercepted (*)(uint32_t index, const PropertyDescriptor& desc,
432 const PropertyCallbackInfo<void>& info);
433// This variant will be deprecated soon.
435 void (*)(uint32_t index, const PropertyDescriptor& desc,
436 const PropertyCallbackInfo<Value>& info);
437
442 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
443// This variant will be deprecated soon.
445 void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
446
451using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
452 Local<Object> accessed_object,
453 Local<Value> data);
454
456
565 public:
568 Isolate* isolate, FunctionCallback callback = nullptr,
569 Local<Value> data = Local<Value>(),
570 Local<Signature> signature = Local<Signature>(), int length = 0,
571 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
572 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
573 const CFunction* c_function = nullptr, uint16_t instance_type = 0,
574 uint16_t allowed_receiver_instance_type_range_start = 0,
575 uint16_t allowed_receiver_instance_type_range_end = 0);
576
579 Isolate* isolate, FunctionCallback callback = nullptr,
580 Local<Value> data = Local<Value>(),
581 Local<Signature> signature = Local<Signature>(), int length = 0,
582 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
583 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
584 const MemorySpan<const CFunction>& c_function_overloads = {});
585
590 Isolate* isolate, FunctionCallback callback,
591 Local<Private> cache_property, Local<Value> data = Local<Value>(),
592 Local<Signature> signature = Local<Signature>(), int length = 0,
593 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
594
597 Local<Context> context);
598
607
615 FunctionCallback callback, Local<Value> data = Local<Value>(),
616 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
617 const MemorySpan<const CFunction>& c_function_overloads = {});
618
620 void SetLength(int length);
621
624
631
637
645
652
657 void SetAcceptAnyReceiver(bool value);
658
664
670
676
685
686 V8_INLINE static FunctionTemplate* Cast(Data* data);
687
688 private:
690
691 static void CheckCast(Data* that);
692 friend class Context;
693 friend class ObjectTemplate;
694};
695
704 kNone = 0,
705
711 kNonMasking = 1,
712
717 kOnlyInterceptStrings = 1 << 1,
718
722 kHasNoSideEffect = 1 << 2,
723
732};
733
735 private:
736 static constexpr PropertyHandlerFlags WithNewSignatureFlag(
737 PropertyHandlerFlags flags) {
738 return static_cast<PropertyHandlerFlags>(
739 static_cast<int>(flags) |
740 static_cast<int>(
741 PropertyHandlerFlags::kInternalNewCallbacksSignatures));
742 }
743
744 public:
753 Local<Value> data = Local<Value>(),
754 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
755 : getter(reinterpret_cast<void*>(getter)),
756 setter(reinterpret_cast<void*>(setter)),
757 query(reinterpret_cast<void*>(query)),
758 deleter(reinterpret_cast<void*>(deleter)),
759 enumerator(enumerator),
760 definer(reinterpret_cast<void*>(definer)),
761 descriptor(reinterpret_cast<void*>(descriptor)),
762 data(data),
763 flags(WithNewSignatureFlag(flags)) {}
764
765 // This variant will be deprecated soon.
774 Local<Value> data = Local<Value>(),
775 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
776 : getter(reinterpret_cast<void*>(getter)),
777 setter(reinterpret_cast<void*>(setter)),
778 query(reinterpret_cast<void*>(query)),
779 deleter(reinterpret_cast<void*>(deleter)),
780 enumerator(enumerator),
781 definer(reinterpret_cast<void*>(definer)),
782 descriptor(reinterpret_cast<void*>(descriptor)),
783 data(data),
784 flags(flags) {}
785
788 NamedPropertySetterCallback setter = nullptr,
789 NamedPropertyQueryCallback query = nullptr,
790 NamedPropertyDeleterCallback deleter = nullptr,
791 NamedPropertyEnumeratorCallback enumerator = nullptr,
792 Local<Value> data = Local<Value>(),
793 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
794 : getter(reinterpret_cast<void*>(getter)),
795 setter(reinterpret_cast<void*>(setter)),
796 query(reinterpret_cast<void*>(query)),
797 deleter(reinterpret_cast<void*>(deleter)),
798 enumerator(enumerator),
799 definer(nullptr),
800 descriptor(nullptr),
801 data(data),
802 flags(WithNewSignatureFlag(flags)) {}
803
804 // This variant will be deprecated soon.
807 GenericNamedPropertySetterCallback setter = nullptr,
808 GenericNamedPropertyQueryCallback query = nullptr,
809 GenericNamedPropertyDeleterCallback deleter = nullptr,
810 GenericNamedPropertyEnumeratorCallback enumerator = nullptr,
811 Local<Value> data = Local<Value>(),
812 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
813 : getter(reinterpret_cast<void*>(getter)),
814 setter(reinterpret_cast<void*>(setter)),
815 query(reinterpret_cast<void*>(query)),
816 deleter(reinterpret_cast<void*>(deleter)),
817 enumerator(enumerator),
818 definer(nullptr),
819 descriptor(nullptr),
820 data(data),
821 flags(flags) {}
822
830 Local<Value> data = Local<Value>(),
831 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
832 : getter(reinterpret_cast<void*>(getter)),
833 setter(reinterpret_cast<void*>(setter)),
834 query(nullptr),
835 deleter(reinterpret_cast<void*>(deleter)),
836 enumerator(enumerator),
837 definer(reinterpret_cast<void*>(definer)),
838 descriptor(reinterpret_cast<void*>(descriptor)),
839 data(data),
840 flags(WithNewSignatureFlag(flags)) {}
841
842 // This variant will be deprecated soon.
850 Local<Value> data = Local<Value>(),
851 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
852 : getter(reinterpret_cast<void*>(getter)),
853 setter(reinterpret_cast<void*>(setter)),
854 query(nullptr),
855 deleter(reinterpret_cast<void*>(deleter)),
856 enumerator(enumerator),
857 definer(reinterpret_cast<void*>(definer)),
858 descriptor(reinterpret_cast<void*>(descriptor)),
859 data(data),
860 flags(flags) {}
861
862 void* getter; // [Generic]NamedPropertyGetterCallback
863 void* setter; // [Generic]NamedPropertySetterCallback
864 void* query; // [Generic]NamedPropertyQueryCallback
865 void* deleter; // [Generic]NamedPropertyDeleterCallback
867 void* definer; // [Generic]NamedPropertyDefinerCallback
868 void* descriptor; // [Generic]NamedPropertyDescriptorCallback
871};
872
874 private:
875 static constexpr PropertyHandlerFlags WithNewSignatureFlag(
876 PropertyHandlerFlags flags) {
877 return static_cast<PropertyHandlerFlags>(
878 static_cast<int>(flags) |
879 static_cast<int>(
880 PropertyHandlerFlags::kInternalNewCallbacksSignatures));
881 }
882
883 public:
892 Local<Value> data = Local<Value>(),
893 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
894 : getter(reinterpret_cast<void*>(getter)),
895 setter(reinterpret_cast<void*>(setter)),
896 query(reinterpret_cast<void*>(query)),
897 deleter(reinterpret_cast<void*>(deleter)),
898 enumerator(enumerator),
899 definer(reinterpret_cast<void*>(definer)),
900 descriptor(reinterpret_cast<void*>(descriptor)),
901 data(data),
902 flags(WithNewSignatureFlag(flags)) {}
903
904 // This variant will be deprecated soon.
913 Local<Value> data = Local<Value>(),
914 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
915 : getter(reinterpret_cast<void*>(getter)),
916 setter(reinterpret_cast<void*>(setter)),
917 query(reinterpret_cast<void*>(query)),
918 deleter(reinterpret_cast<void*>(deleter)),
919 enumerator(enumerator),
920 definer(reinterpret_cast<void*>(definer)),
921 descriptor(reinterpret_cast<void*>(descriptor)),
922 data(data),
923 flags(flags) {}
924
926 IndexedPropertyGetterCallbackV2 getter = nullptr,
927 IndexedPropertySetterCallbackV2 setter = nullptr,
928 IndexedPropertyQueryCallbackV2 query = nullptr,
929 IndexedPropertyDeleterCallbackV2 deleter = nullptr,
930 IndexedPropertyEnumeratorCallback enumerator = nullptr,
931 Local<Value> data = Local<Value>(),
932 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
933 : getter(reinterpret_cast<void*>(getter)),
934 setter(reinterpret_cast<void*>(setter)),
935 query(reinterpret_cast<void*>(query)),
936 deleter(reinterpret_cast<void*>(deleter)),
937 enumerator(enumerator),
938 definer(nullptr),
939 descriptor(nullptr),
940 data(data),
941 flags(WithNewSignatureFlag(flags)) {}
942
943 // This variant will be deprecated soon.
946 IndexedPropertySetterCallback setter = nullptr,
947 IndexedPropertyQueryCallback query = nullptr,
948 IndexedPropertyDeleterCallback deleter = nullptr,
949 IndexedPropertyEnumeratorCallback enumerator = nullptr,
950 Local<Value> data = Local<Value>(),
951 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
952 : getter(reinterpret_cast<void*>(getter)),
953 setter(reinterpret_cast<void*>(setter)),
954 query(reinterpret_cast<void*>(query)),
955 deleter(reinterpret_cast<void*>(deleter)),
956 enumerator(enumerator),
957 definer(nullptr),
958 descriptor(nullptr),
959 data(data),
960 flags(flags) {}
961
969 Local<Value> data = Local<Value>(),
970 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
971 : getter(reinterpret_cast<void*>(getter)),
972 setter(reinterpret_cast<void*>(setter)),
973 query(nullptr),
974 deleter(reinterpret_cast<void*>(deleter)),
975 enumerator(enumerator),
976 definer(reinterpret_cast<void*>(definer)),
977 descriptor(reinterpret_cast<void*>(descriptor)),
978 data(data),
979 flags(WithNewSignatureFlag(flags)) {}
980
981 // This variant will be deprecated soon.
989 Local<Value> data = Local<Value>(),
990 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
991 : getter(reinterpret_cast<void*>(getter)),
992 setter(reinterpret_cast<void*>(setter)),
993 query(nullptr),
994 deleter(reinterpret_cast<void*>(deleter)),
995 enumerator(enumerator),
996 definer(reinterpret_cast<void*>(definer)),
997 descriptor(reinterpret_cast<void*>(descriptor)),
998 data(data),
999 flags(flags) {}
1000
1001 void* getter; // IndexedPropertyGetterCallback[V2]
1002 void* setter; // IndexedPropertySetterCallback[V2]
1003 void* query; // IndexedPropertyQueryCallback[V2]
1004 void* deleter; // IndexedPropertyDeleterCallback[V2]
1006 void* definer; // IndexedPropertyDefinerCallback[V2]
1007 void* descriptor; // IndexedPropertyDescriptorCallback[V2]
1010};
1011
1019 public:
1022 Isolate* isolate,
1024
1031
1048 V8_DEPRECATE_SOON("Use SetAccessor with Local<Name> instead")
1049 void SetAccessor(
1050 Local<String> name, AccessorGetterCallback getter,
1051 AccessorSetterCallback setter = nullptr,
1052 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
1053 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
1054 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
1055 void SetAccessor(
1057 AccessorNameSetterCallback setter = nullptr,
1058 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
1059 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
1060 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
1061
1073 void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
1074
1091 V8_DEPRECATE_SOON("Use SetHandler instead")
1092 void SetIndexedPropertyHandler(
1094 IndexedPropertySetterCallback setter = nullptr,
1095 IndexedPropertyQueryCallback query = nullptr,
1096 IndexedPropertyDeleterCallback deleter = nullptr,
1097 IndexedPropertyEnumeratorCallback enumerator = nullptr,
1098 Local<Value> data = Local<Value>()) {
1099 SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
1100 deleter, enumerator, data));
1101 }
1102
1114
1122 Local<Value> data = Local<Value>());
1123
1133
1143 Local<Value> data = Local<Value>());
1144
1152 AccessCheckCallback callback,
1153 const NamedPropertyHandlerConfiguration& named_handler,
1154 const IndexedPropertyHandlerConfiguration& indexed_handler,
1155 Local<Value> data = Local<Value>());
1156
1162
1167 void SetInternalFieldCount(int value);
1168
1172 bool IsImmutableProto() const;
1173
1179
1190 bool IsCodeLike() const;
1191
1192 V8_INLINE static ObjectTemplate* Cast(Data* data);
1193
1194 private:
1196
1197 static void CheckCast(Data* that);
1198 friend class FunctionTemplate;
1199};
1200
1205 public:
1215
1226 Local<Context> context, MemorySpan<MaybeLocal<Value>> property_values);
1227
1228 V8_INLINE static DictionaryTemplate* Cast(Data* data);
1229
1230 private:
1231 static void CheckCast(Data* that);
1232
1234};
1235
1244class V8_EXPORT Signature : public Data {
1245 public:
1247 Isolate* isolate,
1249
1250 V8_INLINE static Signature* Cast(Data* data);
1251
1252 private:
1253 Signature();
1254
1255 static void CheckCast(Data* that);
1256};
1257
1258// --- Implementation ---
1259
1260void Template::Set(Isolate* isolate, const char* name, Local<Data> value,
1261 PropertyAttribute attributes) {
1262 Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
1263 .ToLocalChecked(),
1264 value, attributes);
1265}
1266
1267FunctionTemplate* FunctionTemplate::Cast(Data* data) {
1268#ifdef V8_ENABLE_CHECKS
1269 CheckCast(data);
1270#endif
1271 return reinterpret_cast<FunctionTemplate*>(data);
1272}
1273
1274ObjectTemplate* ObjectTemplate::Cast(Data* data) {
1275#ifdef V8_ENABLE_CHECKS
1276 CheckCast(data);
1277#endif
1278 return reinterpret_cast<ObjectTemplate*>(data);
1279}
1280
1281DictionaryTemplate* DictionaryTemplate::Cast(Data* data) {
1282#ifdef V8_ENABLE_CHECKS
1283 CheckCast(data);
1284#endif
1285 return reinterpret_cast<DictionaryTemplate*>(data);
1286}
1287
1288Signature* Signature::Cast(Data* data) {
1289#ifdef V8_ENABLE_CHECKS
1290 CheckCast(data);
1291#endif
1292 return reinterpret_cast<Signature*>(data);
1293}
1294
1295} // namespace v8
1296
1297#endif // INCLUDE_V8_TEMPLATE_H_
V8_WARN_UNUSED_RESULT Local< Object > NewInstance(Local< Context > context, MemorySpan< MaybeLocal< Value > > property_values)
static Local< DictionaryTemplate > New(Isolate *isolate, MemorySpan< const std::string_view > names)
bool HasInstance(Local< Value > object)
static Local< FunctionTemplate > New(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const CFunction *c_function=nullptr, uint16_t instance_type=0, uint16_t allowed_receiver_instance_type_range_start=0, uint16_t allowed_receiver_instance_type_range_end=0)
static Local< FunctionTemplate > NewWithCache(Isolate *isolate, FunctionCallback callback, Local< Private > cache_property, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, SideEffectType side_effect_type=SideEffectType::kHasSideEffect)
void SetCallHandler(FunctionCallback callback, Local< Value > data=Local< Value >(), SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const MemorySpan< const CFunction > &c_function_overloads={})
static Local< FunctionTemplate > NewWithCFunctionOverloads(Isolate *isolate, FunctionCallback callback=nullptr, Local< Value > data=Local< Value >(), Local< Signature > signature=Local< Signature >(), int length=0, ConstructorBehavior behavior=ConstructorBehavior::kAllow, SideEffectType side_effect_type=SideEffectType::kHasSideEffect, const MemorySpan< const CFunction > &c_function_overloads={})
Local< ObjectTemplate > InstanceTemplate()
void SetLength(int length)
bool IsLeafTemplateForApiObject(v8::Local< v8::Value > value) const
Local< ObjectTemplate > PrototypeTemplate()
void Inherit(Local< FunctionTemplate > parent)
V8_WARN_UNUSED_RESULT MaybeLocal< Function > GetFunction(Local< Context > context)
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewRemoteInstance()
void SetPrototypeProviderTemplate(Local< FunctionTemplate > prototype_provider)
void SetClassName(Local< String > name)
void SetAcceptAnyReceiver(bool value)
void SetInternalFieldCount(int value)
static Local< ObjectTemplate > New(Isolate *isolate, Local< FunctionTemplate > constructor=Local< FunctionTemplate >())
bool IsCodeLike() const
void SetCallAsFunctionHandler(FunctionCallback callback, Local< Value > data=Local< Value >())
void SetAccessCheckCallbackAndHandler(AccessCheckCallback callback, const NamedPropertyHandlerConfiguration &named_handler, const IndexedPropertyHandlerConfiguration &indexed_handler, Local< Value > data=Local< Value >())
void SetAccessCheckCallback(AccessCheckCallback callback, Local< Value > data=Local< Value >())
bool IsImmutableProto() const
void SetHandler(const IndexedPropertyHandlerConfiguration &configuration)
V8_WARN_UNUSED_RESULT MaybeLocal< Object > NewInstance(Local< Context > context)
int InternalFieldCount() const
static Local< Signature > New(Isolate *isolate, Local< FunctionTemplate > receiver=Local< FunctionTemplate >())
void SetPrivate(Local< Private > name, Local< Data > value, PropertyAttribute attributes=None)
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
void SetAccessorProperty(Local< Name > name, Local< FunctionTemplate > getter=Local< FunctionTemplate >(), Local< FunctionTemplate > setter=Local< FunctionTemplate >(), PropertyAttribute attribute=None)
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition v8-object.h:156
Intrinsic
Definition v8-template.h:40
Intercepted(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) IndexedPropertyDefinerCallbackV2
void(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) GenericNamedPropertyDeleterCallback
void(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallback
void(*)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorSetterCallback
Definition v8-object.h:160
void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallback
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) NamedPropertyDefinerCallback
bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) AccessCheckCallback
AccessControl
Definition v8-object.h:173
void(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info) IndexedPropertySetterCallback
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyDescriptorCallback
void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallback
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallbackV2
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallbackV2
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyDescriptorCallback
Intercepted
SideEffectType
Definition v8-object.h:199
Intercepted(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) NamedPropertySetterCallback
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) NamedPropertyQueryCallback
NamedPropertyEnumeratorCallback GenericNamedPropertyEnumeratorCallback
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyGetterCallback
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition v8-object.h:163
void(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) GenericNamedPropertyQueryCallback
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< void > &info) IndexedPropertySetterCallbackV2
PropertyAttribute
Definition v8-object.h:137
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallbackV2
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) GenericNamedPropertySetterCallback
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyGetterCallback
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDeleterCallback
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallbackV2
void(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) IndexedPropertyDefinerCallback
ConstructorBehavior
void(*)(const PropertyCallbackInfo< Array > &info) NamedPropertyEnumeratorCallback
void(*)(const PropertyCallbackInfo< Array > &info) IndexedPropertyEnumeratorCallback
void(*)(Local< String > property, const PropertyCallbackInfo< Value > &info) AccessorGetterCallback
Definition v8-object.h:154
void(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyDefinerCallback
PropertyHandlerFlags
void(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallback
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter=nullptr, IndexedPropertyQueryCallback query=nullptr, IndexedPropertyDeleterCallback deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallbackV2 getter=nullptr, IndexedPropertySetterCallbackV2 setter=nullptr, IndexedPropertyQueryCallbackV2 query=nullptr, IndexedPropertyDeleterCallbackV2 deleter=nullptr, IndexedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallbackV2 getter, IndexedPropertySetterCallbackV2 setter, IndexedPropertyDescriptorCallbackV2 descriptor, IndexedPropertyDeleterCallbackV2 deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallbackV2 definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallbackV2 getter, IndexedPropertySetterCallbackV2 setter, IndexedPropertyQueryCallbackV2 query, IndexedPropertyDeleterCallbackV2 deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallbackV2 definer, IndexedPropertyDescriptorCallbackV2 descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyDescriptorCallback descriptor, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyHandlerConfiguration(IndexedPropertyGetterCallback getter, IndexedPropertySetterCallback setter, IndexedPropertyQueryCallback query, IndexedPropertyDeleterCallback deleter, IndexedPropertyEnumeratorCallback enumerator, IndexedPropertyDefinerCallback definer, IndexedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
IndexedPropertyEnumeratorCallback enumerator
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyDescriptorCallback descriptor, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter=nullptr, GenericNamedPropertyQueryCallback query=nullptr, GenericNamedPropertyDeleterCallback deleter=nullptr, GenericNamedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
NamedPropertyHandlerConfiguration(NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, NamedPropertyDescriptorCallback descriptor, NamedPropertyDeleterCallback deleter, NamedPropertyEnumeratorCallback enumerator, NamedPropertyDefinerCallback definer, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
NamedPropertyEnumeratorCallback enumerator
NamedPropertyHandlerConfiguration(NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, NamedPropertyQueryCallback query, NamedPropertyDeleterCallback deleter, NamedPropertyEnumeratorCallback enumerator, NamedPropertyDefinerCallback definer, NamedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
NamedPropertyHandlerConfiguration(GenericNamedPropertyGetterCallback getter, GenericNamedPropertySetterCallback setter, GenericNamedPropertyQueryCallback query, GenericNamedPropertyDeleterCallback deleter, GenericNamedPropertyEnumeratorCallback enumerator, GenericNamedPropertyDefinerCallback definer, GenericNamedPropertyDescriptorCallback descriptor, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
NamedPropertyHandlerConfiguration(NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter=nullptr, NamedPropertyQueryCallback query=nullptr, NamedPropertyDeleterCallback deleter=nullptr, NamedPropertyEnumeratorCallback enumerator=nullptr, Local< Value > data=Local< Value >(), PropertyHandlerFlags flags=PropertyHandlerFlags::kNone)
#define V8_INTRINSICS_LIST(F)
Definition v8-template.h:27
#define V8_DECL_INTRINSIC(name, iname)
Definition v8-template.h:41
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477
#define V8_DEPRECATE_SOON(message)
Definition v8config.h:571
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:628