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);
58 void SetPrivate(Local<Private> name, Local<Data> value,
59 PropertyAttribute attributes = None);
60 V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value,
61 PropertyAttribute attributes = None);
63 void SetAccessorProperty(
64 Local<Name> name,
67 PropertyAttribute attribute = None);
68
83 V8_DEPRECATED("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_DEPRECATED("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_DEPRECATED("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();
131 friend class ObjectTemplate;
132 friend class FunctionTemplate;
133};
134
139enum class Intercepted : uint8_t { kNo = 0, kYes = 1 };
140
185 Local<Name> property, const PropertyCallbackInfo<Value>& info);
186// This variant will be deprecated soon.
187//
188// Use `info.GetReturnValue().Set()` to set the return value of the
189// intercepted get request. If the property does not exist the callback should
190// not set the result and must not produce side effects.
192 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
193
214 Intercepted (*)(Local<Name> property, Local<Value> value,
215 const PropertyCallbackInfo<void>& info);
216// This variant will be deprecated soon.
217//
218// Use `info.GetReturnValue()` to indicate whether the request was intercepted
219// or not. If the setter successfully intercepts the request, i.e., if the
220// request should not be further executed, call
221// `info.GetReturnValue().Set(value)`. If the setter did not intercept the
222// request, i.e., if the request should be handled as if no interceptor is
223// present, do not not call `Set()` and do not produce side effects.
225 void (*)(Local<Name> property, Local<Value> value,
226 const PropertyCallbackInfo<Value>& info);
227
255 Local<Name> property, const PropertyCallbackInfo<Integer>& info);
256// This variant will be deprecated soon.
257//
258// Use `info.GetReturnValue().Set(value)` to set the property attributes. The
259// value is an integer encoding a `v8::PropertyAttribute`. If the property does
260// not exist the callback should not set the result and must not produce side
261// effects.
263 void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
264
290 Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
291// This variant will be deprecated soon.
292//
293// Use `info.GetReturnValue()` to indicate whether the request was intercepted
294// or not. If the deleter successfully intercepts the request, i.e., if the
295// request should not be further executed, call
296// `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is
297// used as the return value of `delete`. If the deleter does not intercept the
298// request then it should not set the result and must not produce side effects.
300 void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
301
309 void (*)(const PropertyCallbackInfo<Array>& info);
310// This variant will be deprecated soon.
311// This is just a renaming of the typedef.
313
334 Intercepted (*)(Local<Name> property, const PropertyDescriptor& desc,
335 const PropertyCallbackInfo<void>& info);
336// This variant will be deprecated soon.
337//
338// Use `info.GetReturnValue()` to indicate whether the request was intercepted
339// or not. If the definer successfully intercepts the request, i.e., if the
340// request should not be further executed, call
341// `info.GetReturnValue().Set(value)`. If the definer did not intercept the
342// request, i.e., if the request should be handled as if no interceptor is
343// present, do not not call `Set()` and do not produce side effects.
345 void (*)(Local<Name> property, const PropertyDescriptor& desc,
346 const PropertyCallbackInfo<Value>& info);
347
373 Local<Name> property, const PropertyCallbackInfo<Value>& info);
374// This variant will be deprecated soon.
375//
376// Use `info.GetReturnValue().Set()` to set the return value of the
377// intercepted request. The return value must be an object that
378// can be converted to a PropertyDescriptor, e.g., a `v8::Value` returned from
379// `v8::Object::getOwnPropertyDescriptor`.
381 void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
382
383// TODO(ishell): Rename IndexedPropertyXxxCallbackV2 back to
384// IndexedPropertyXxxCallback once the old IndexedPropertyXxxCallback is
385// removed.
386
391 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
392// This variant will be deprecated soon.
394 void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
395
400 uint32_t index, Local<Value> value, const PropertyCallbackInfo<void>& info);
401// This variant will be deprecated soon.
403 void (*)(uint32_t index, Local<Value> value,
404 const PropertyCallbackInfo<Value>& info);
405
410 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
411// This variant will be deprecated soon.
413 void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
414
419 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
420// This variant will be deprecated soon.
422 void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
423
431 void (*)(const PropertyCallbackInfo<Array>& info);
432
437 Intercepted (*)(uint32_t index, const PropertyDescriptor& desc,
438 const PropertyCallbackInfo<void>& info);
439// This variant will be deprecated soon.
441 void (*)(uint32_t index, const PropertyDescriptor& desc,
442 const PropertyCallbackInfo<Value>& info);
443
448 Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
449// This variant will be deprecated soon.
451 void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
452
457using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
458 Local<Object> accessed_object,
459 Local<Value> data);
461enum class ConstructorBehavior { kThrow, kAllow };
462
570class V8_EXPORT FunctionTemplate : public Template {
571 public:
573 static Local<FunctionTemplate> New(
574 Isolate* isolate, FunctionCallback callback = nullptr,
575 Local<Value> data = Local<Value>(),
576 Local<Signature> signature = Local<Signature>(), int length = 0,
577 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
578 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
579 const CFunction* c_function = nullptr, uint16_t instance_type = 0,
580 uint16_t allowed_receiver_instance_type_range_start = 0,
581 uint16_t allowed_receiver_instance_type_range_end = 0);
582
584 static Local<FunctionTemplate> NewWithCFunctionOverloads(
585 Isolate* isolate, FunctionCallback callback = nullptr,
586 Local<Value> data = Local<Value>(),
587 Local<Signature> signature = Local<Signature>(), int length = 0,
588 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
589 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
590 const MemorySpan<const CFunction>& c_function_overloads = {});
591
595 static Local<FunctionTemplate> NewWithCache(
596 Isolate* isolate, FunctionCallback callback,
597 Local<Private> cache_property, Local<Value> data = Local<Value>(),
598 Local<Signature> signature = Local<Signature>(), int length = 0,
599 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
600
602 V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
603 Local<Context> context);
604
612 V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewRemoteInstance();
613
620 void SetCallHandler(
621 FunctionCallback callback, Local<Value> data = Local<Value>(),
622 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
623 const MemorySpan<const CFunction>& c_function_overloads = {});
624
626 void SetLength(int length);
627
629 Local<ObjectTemplate> InstanceTemplate();
630
636 void Inherit(Local<FunctionTemplate> parent);
637
642 Local<ObjectTemplate> PrototypeTemplate();
643
650 void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
651
657 void SetClassName(Local<String> name);
658
663 void SetAcceptAnyReceiver(bool value);
664
669 void ReadOnlyPrototype();
670
675 void RemovePrototype();
676
681 bool HasInstance(Local<Value> object);
682
690 bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
691
692 V8_INLINE static FunctionTemplate* Cast(Data* data);
693
694 private:
695 FunctionTemplate();
696
697 static void CheckCast(Data* that);
698 friend class Context;
699 friend class ObjectTemplate;
700};
701
706enum class PropertyHandlerFlags {
710 kNone = 0,
711
717 kNonMasking = 1,
718
723 kOnlyInterceptStrings = 1 << 1,
724
728 kHasNoSideEffect = 1 << 2,
729
738};
741 private:
742 static constexpr PropertyHandlerFlags WithNewSignatureFlag(
743 PropertyHandlerFlags flags) {
744 return static_cast<PropertyHandlerFlags>(
745 static_cast<int>(flags) |
746 static_cast<int>(
747 PropertyHandlerFlags::kInternalNewCallbacksSignatures));
748 }
749
750 public:
759 Local<Value> data = Local<Value>(),
760 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
761 : getter(reinterpret_cast<void*>(getter)),
762 setter(reinterpret_cast<void*>(setter)),
763 query(reinterpret_cast<void*>(query)),
764 deleter(reinterpret_cast<void*>(deleter)),
765 enumerator(enumerator),
766 definer(reinterpret_cast<void*>(definer)),
767 descriptor(reinterpret_cast<void*>(descriptor)),
768 data(data),
769 flags(WithNewSignatureFlag(flags)) {}
770
772 "Provide interceptor callbacks with new signatures instead "
773 "(NamedPropertyXxxCallback)")
782 Local<Value> data = Local<Value>(),
784 : getter(reinterpret_cast<void*>(getter)),
785 setter(reinterpret_cast<void*>(setter)),
786 query(reinterpret_cast<void*>(query)),
787 deleter(reinterpret_cast<void*>(deleter)),
788 enumerator(enumerator),
789 definer(reinterpret_cast<void*>(definer)),
790 descriptor(reinterpret_cast<void*>(descriptor)),
791 data(data),
792 flags(flags) {}
796 NamedPropertySetterCallback setter = nullptr,
797 NamedPropertyQueryCallback query = nullptr,
798 NamedPropertyDeleterCallback deleter = nullptr,
799 NamedPropertyEnumeratorCallback enumerator = nullptr,
800 Local<Value> data = Local<Value>(),
801 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
802 : getter(reinterpret_cast<void*>(getter)),
803 setter(reinterpret_cast<void*>(setter)),
804 query(reinterpret_cast<void*>(query)),
805 deleter(reinterpret_cast<void*>(deleter)),
806 enumerator(enumerator),
807 definer(nullptr),
808 descriptor(nullptr),
809 data(data),
810 flags(WithNewSignatureFlag(flags)) {}
811
813 "Provide interceptor callbacks with new signatures instead "
814 "(NamedPropertyXxxCallback)")
817 GenericNamedPropertySetterCallback setter = nullptr,
818 GenericNamedPropertyQueryCallback query = nullptr,
819 GenericNamedPropertyDeleterCallback deleter = nullptr,
820 GenericNamedPropertyEnumeratorCallback enumerator = nullptr,
821 Local<Value> data = Local<Value>(),
823 : getter(reinterpret_cast<void*>(getter)),
824 setter(reinterpret_cast<void*>(setter)),
825 query(reinterpret_cast<void*>(query)),
826 deleter(reinterpret_cast<void*>(deleter)),
827 enumerator(enumerator),
828 definer(nullptr),
829 descriptor(nullptr),
830 data(data),
831 flags(flags) {}
840 Local<Value> data = Local<Value>(),
841 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
842 : getter(reinterpret_cast<void*>(getter)),
843 setter(reinterpret_cast<void*>(setter)),
844 query(nullptr),
845 deleter(reinterpret_cast<void*>(deleter)),
846 enumerator(enumerator),
847 definer(reinterpret_cast<void*>(definer)),
848 descriptor(reinterpret_cast<void*>(descriptor)),
849 data(data),
850 flags(WithNewSignatureFlag(flags)) {}
851
853 "Provide interceptor callbacks with new signatures instead "
854 "(NamedPropertyXxxCallback)")
862 Local<Value> data = Local<Value>(),
864 : getter(reinterpret_cast<void*>(getter)),
865 setter(reinterpret_cast<void*>(setter)),
866 query(nullptr),
867 deleter(reinterpret_cast<void*>(deleter)),
868 enumerator(enumerator),
869 definer(reinterpret_cast<void*>(definer)),
870 descriptor(reinterpret_cast<void*>(descriptor)),
871 data(data),
872 flags(flags) {}
874 void* getter; // [Generic]NamedPropertyGetterCallback
875 void* setter; // [Generic]NamedPropertySetterCallback
876 void* query; // [Generic]NamedPropertyQueryCallback
877 void* deleter; // [Generic]NamedPropertyDeleterCallback
879 void* definer; // [Generic]NamedPropertyDefinerCallback
880 void* descriptor; // [Generic]NamedPropertyDescriptorCallback
883};
886 private:
887 static constexpr PropertyHandlerFlags WithNewSignatureFlag(
888 PropertyHandlerFlags flags) {
889 return static_cast<PropertyHandlerFlags>(
890 static_cast<int>(flags) |
891 static_cast<int>(
892 PropertyHandlerFlags::kInternalNewCallbacksSignatures));
893 }
894
895 public:
904 Local<Value> data = Local<Value>(),
905 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
906 : getter(reinterpret_cast<void*>(getter)),
907 setter(reinterpret_cast<void*>(setter)),
908 query(reinterpret_cast<void*>(query)),
909 deleter(reinterpret_cast<void*>(deleter)),
910 enumerator(enumerator),
911 definer(reinterpret_cast<void*>(definer)),
912 descriptor(reinterpret_cast<void*>(descriptor)),
913 data(data),
914 flags(WithNewSignatureFlag(flags)) {}
915
917 "Provide interceptor callbacks with new signatures instead "
918 "(IndexedPropertyXxxCallbackV2)")
927 Local<Value> data = Local<Value>(),
929 : getter(reinterpret_cast<void*>(getter)),
930 setter(reinterpret_cast<void*>(setter)),
931 query(reinterpret_cast<void*>(query)),
932 deleter(reinterpret_cast<void*>(deleter)),
933 enumerator(enumerator),
934 definer(reinterpret_cast<void*>(definer)),
935 descriptor(reinterpret_cast<void*>(descriptor)),
936 data(data),
937 flags(flags) {}
940 IndexedPropertyGetterCallbackV2 getter = nullptr,
941 IndexedPropertySetterCallbackV2 setter = nullptr,
942 IndexedPropertyQueryCallbackV2 query = nullptr,
943 IndexedPropertyDeleterCallbackV2 deleter = nullptr,
944 IndexedPropertyEnumeratorCallback enumerator = nullptr,
945 Local<Value> data = Local<Value>(),
946 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
947 : getter(reinterpret_cast<void*>(getter)),
948 setter(reinterpret_cast<void*>(setter)),
949 query(reinterpret_cast<void*>(query)),
950 deleter(reinterpret_cast<void*>(deleter)),
951 enumerator(enumerator),
952 definer(nullptr),
953 descriptor(nullptr),
954 data(data),
955 flags(WithNewSignatureFlag(flags)) {}
956
958 "Provide interceptor callbacks with new signatures instead "
959 "(IndexedPropertyXxxCallbackV2)")
962 IndexedPropertySetterCallback setter = nullptr,
963 IndexedPropertyQueryCallback query = nullptr,
964 IndexedPropertyDeleterCallback deleter = nullptr,
965 IndexedPropertyEnumeratorCallback enumerator = nullptr,
966 Local<Value> data = Local<Value>(),
968 : getter(reinterpret_cast<void*>(getter)),
969 setter(reinterpret_cast<void*>(setter)),
970 query(reinterpret_cast<void*>(query)),
971 deleter(reinterpret_cast<void*>(deleter)),
972 enumerator(enumerator),
973 definer(nullptr),
974 descriptor(nullptr),
975 data(data),
976 flags(flags) {}
985 Local<Value> data = Local<Value>(),
986 PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
987 : getter(reinterpret_cast<void*>(getter)),
988 setter(reinterpret_cast<void*>(setter)),
989 query(nullptr),
990 deleter(reinterpret_cast<void*>(deleter)),
991 enumerator(enumerator),
992 definer(reinterpret_cast<void*>(definer)),
993 descriptor(reinterpret_cast<void*>(descriptor)),
994 data(data),
995 flags(WithNewSignatureFlag(flags)) {}
996
998 "Provide interceptor callbacks with new signatures instead "
999 "(IndexedPropertyXxxCallbackV2)")
1007 Local<Value> data = Local<Value>(),
1009 : getter(reinterpret_cast<void*>(getter)),
1010 setter(reinterpret_cast<void*>(setter)),
1011 query(nullptr),
1012 deleter(reinterpret_cast<void*>(deleter)),
1013 enumerator(enumerator),
1014 definer(reinterpret_cast<void*>(definer)),
1015 descriptor(reinterpret_cast<void*>(descriptor)),
1016 data(data),
1017 flags(flags) {}
1019 void* getter; // IndexedPropertyGetterCallback[V2]
1020 void* setter; // IndexedPropertySetterCallback[V2]
1021 void* query; // IndexedPropertyQueryCallback[V2]
1022 void* deleter; // IndexedPropertyDeleterCallback[V2]
1024 void* definer; // IndexedPropertyDefinerCallback[V2]
1025 void* descriptor; // IndexedPropertyDescriptorCallback[V2]
1028};
1029
1036class V8_EXPORT ObjectTemplate : public Template {
1037 public:
1039 static Local<ObjectTemplate> New(
1040 Isolate* isolate,
1042
1049
1066 V8_DEPRECATED("Use SetAccessor with Local<Name> instead")
1067 void SetAccessor(
1068 Local<String> name, AccessorGetterCallback getter,
1069 AccessorSetterCallback setter = nullptr,
1070 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
1071 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
1072 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
1073 void SetAccessor(
1075 AccessorNameSetterCallback setter = nullptr,
1076 Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
1077 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
1078 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
1079
1091 void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
1092
1109 V8_DEPRECATED("Use SetHandler instead")
1110 void SetIndexedPropertyHandler(
1112 IndexedPropertySetterCallback setter = nullptr,
1113 IndexedPropertyQueryCallback query = nullptr,
1114 IndexedPropertyDeleterCallback deleter = nullptr,
1115 IndexedPropertyEnumeratorCallback enumerator = nullptr,
1116 Local<Value> data = Local<Value>()) {
1117 SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
1118 deleter, enumerator, data));
1119 }
1120
1131 void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
1132
1139 void SetCallAsFunctionHandler(FunctionCallback callback,
1140 Local<Value> data = Local<Value>());
1141
1150 void MarkAsUndetectable();
1151
1160 void SetAccessCheckCallback(AccessCheckCallback callback,
1161 Local<Value> data = Local<Value>());
1162
1169 void SetAccessCheckCallbackAndHandler(
1170 AccessCheckCallback callback,
1171 const NamedPropertyHandlerConfiguration& named_handler,
1172 const IndexedPropertyHandlerConfiguration& indexed_handler,
1173 Local<Value> data = Local<Value>());
1174
1179 int InternalFieldCount() const;
1180
1185 void SetInternalFieldCount(int value);
1186
1190 bool IsImmutableProto() const;
1191
1196 void SetImmutableProto();
1197
1207 void SetCodeLike();
1208 bool IsCodeLike() const;
1209
1210 V8_INLINE static ObjectTemplate* Cast(Data* data);
1211
1212 private:
1214
1215 static void CheckCast(Data* that);
1216 friend class FunctionTemplate;
1217};
1218
1222class V8_EXPORT DictionaryTemplate final {
1223 public:
1231 static Local<DictionaryTemplate> New(
1233
1244 Local<Context> context, MemorySpan<MaybeLocal<Value>> property_values);
1245
1246 V8_INLINE static DictionaryTemplate* Cast(Data* data);
1247
1248 private:
1249 static void CheckCast(Data* that);
1250
1252};
1253
1262class V8_EXPORT Signature : public Data {
1263 public:
1264 static Local<Signature> New(
1265 Isolate* isolate,
1267
1268 V8_INLINE static Signature* Cast(Data* data);
1269
1270 private:
1271 Signature();
1272
1273 static void CheckCast(Data* that);
1274};
1275
1276// --- Implementation ---
1278void Template::Set(Isolate* isolate, const char* name, Local<Data> value,
1279 PropertyAttribute attributes) {
1280 Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
1281 .ToLocalChecked(),
1282 value, attributes);
1283}
1285FunctionTemplate* FunctionTemplate::Cast(Data* data) {
1286#ifdef V8_ENABLE_CHECKS
1287 CheckCast(data);
1288#endif
1289 return reinterpret_cast<FunctionTemplate*>(data);
1290}
1292ObjectTemplate* ObjectTemplate::Cast(Data* data) {
1293#ifdef V8_ENABLE_CHECKS
1294 CheckCast(data);
1295#endif
1296 return reinterpret_cast<ObjectTemplate*>(data);
1297}
1299DictionaryTemplate* DictionaryTemplate::Cast(Data* data) {
1300#ifdef V8_ENABLE_CHECKS
1301 CheckCast(data);
1302#endif
1303 return reinterpret_cast<DictionaryTemplate*>(data);
1304}
1306Signature* Signature::Cast(Data* data) {
1307#ifdef V8_ENABLE_CHECKS
1308 CheckCast(data);
1309#endif
1310 return reinterpret_cast<Signature*>(data);
1311}
1312
1313} // namespace v8
1314
1315#endif // INCLUDE_V8_TEMPLATE_H_
Definition: v8-context.h:48
Definition: v8-data.h:18
Definition: v8-template.h:1221
Definition: v8-template.h:569
Definition: v8-isolate.h:210
Definition: v8-local-handle.h:258
Definition: v8-local-handle.h:619
Definition: v8-memory-span.h:29
Definition: v8-primitive.h:79
Definition: v8-template.h:1035
Definition: v8-function-callback.h:192
Definition: v8-object.h:91
Definition: v8-container.h:148
Definition: v8-template.h:1261
Definition: v8-primitive.h:124
Definition: v8-template.h:48
Definition: v8-value.h:32
Definition: libplatform.h:15
void(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallback
Definition: v8-template.h:412
PropertyAttribute
Definition: v8-object.h:139
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:159
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyGetterCallback
Definition: v8-template.h:191
Intercepted(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) NamedPropertySetterCallback
Definition: v8-template.h:214
void(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyDefinerCallback
Definition: v8-template.h:345
void(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Value > &info) IndexedPropertyDefinerCallback
Definition: v8-template.h:441
void(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Value > &info) IndexedPropertySetterCallback
Definition: v8-template.h:403
SideEffectType
Definition: v8-object.h:203
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyDescriptorCallback
Definition: v8-template.h:372
void(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallback
Definition: v8-template.h:421
AccessControl
Definition: v8-object.h:177
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< void > &info) IndexedPropertySetterCallbackV2
Definition: v8-template.h:399
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyGetterCallback
Definition: v8-template.h:184
NamedPropertyEnumeratorCallback GenericNamedPropertyEnumeratorCallback
Definition: v8-template.h:311
void(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) GenericNamedPropertyQueryCallback
Definition: v8-template.h:262
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) NamedPropertyDefinerCallback
Definition: v8-template.h:334
void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallback
Definition: v8-template.h:450
Intrinsic
Definition: v8-template.h:40
void(*)(const PropertyCallbackInfo< Array > &info) NamedPropertyEnumeratorCallback
Definition: v8-template.h:308
ConstructorBehavior
Definition: v8-template.h:460
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
Definition: v8-function-callback.h:308
Intercepted(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) IndexedPropertyDefinerCallbackV2
Definition: v8-template.h:437
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallbackV2
Definition: v8-template.h:418
void(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallback
Definition: v8-template.h:393
void(*)(const PropertyCallbackInfo< Array > &info) IndexedPropertyEnumeratorCallback
Definition: v8-template.h:430
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallbackV2
Definition: v8-template.h:447
void(*)(Local< String > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorSetterCallback
Definition: v8-object.h:164
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) NamedPropertyQueryCallback
Definition: v8-template.h:254
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:167
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Value > &info) GenericNamedPropertySetterCallback
Definition: v8-template.h:225
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallbackV2
Definition: v8-template.h:390
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) GenericNamedPropertyDescriptorCallback
Definition: v8-template.h:380
bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) AccessCheckCallback
Definition: v8-template.h:458
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDeleterCallback
Definition: v8-template.h:289
void(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) GenericNamedPropertyDeleterCallback
Definition: v8-template.h:299
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallbackV2
Definition: v8-template.h:409
void(*)(Local< String > property, const PropertyCallbackInfo< Value > &info) AccessorGetterCallback
Definition: v8-object.h:157
PropertyHandlerFlags
Definition: v8-template.h:705
Intercepted
Definition: v8-template.h:138
Definition: v8-template.h:884
Definition: v8-template.h:739
#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:762
#define V8_INLINE
Definition: v8config.h:477
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:580
#define V8_DEPRECATED(message)
Definition: v8config.h:572
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:637