5#ifndef INCLUDE_V8_TEMPLATE_H_
6#define INCLUDE_V8_TEMPLATE_H_
22class FunctionTemplate;
28#define V8_INTRINSICS_LIST(F) \
29 F(ArrayProto_entries, array_entries_iterator) \
30 F(ArrayProto_forEach, array_for_each_iterator) \
31 F(ArrayProto_keys, array_keys_iterator) \
32 F(ArrayProto_values, array_values_iterator) \
33 F(ArrayPrototype, initial_array_prototype) \
34 F(AsyncIteratorPrototype, initial_async_iterator_prototype) \
35 F(ErrorPrototype, initial_error_prototype) \
36 F(IteratorPrototype, initial_iterator_prototype) \
37 F(MapIteratorPrototype, initial_map_iterator_prototype) \
38 F(ObjProto_valueOf, object_value_of_function) \
39 F(SetIteratorPrototype, initial_set_iterator_prototype)
42#define V8_DECL_INTRINSIC(name, iname) k##name,
44#undef V8_DECL_INTRINSIC
57 void Set(Local<Name> name, Local<Data> value,
78 void SetAccessorProperty(
104 void SetNativeDataProperty(
108 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
109 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
111 void SetNativeDataProperty(
119 void SetNativeDataProperty(
125 SetNativeDataProperty(
127 attribute, getter_side_effect_type, setter_side_effect_type);
134 void SetLazyDataProperty(
137 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
138 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
207 Local<Name> property,
const PropertyCallbackInfo<Value>& info);
236 Intercepted (*)(Local<Name> property, Local<Value> value,
237 const PropertyCallbackInfo<Boolean>& info);
432 uint32_t (*)(
Local<Value> value, uint32_t start_index, uint32_t end_index,
558class V8_EXPORT FunctionTemplate :
public Template {
561 static Local<FunctionTemplate> New(
562 Isolate* isolate, FunctionCallback callback =
nullptr,
563 Local<Value> data = Local<Value>(),
564 Local<Signature> signature = Local<Signature>(),
int length = 0,
565 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
566 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
567 const CFunction* c_function =
nullptr, uint16_t instance_type = 0,
568 uint16_t allowed_receiver_instance_type_range_start = 0,
569 uint16_t allowed_receiver_instance_type_range_end = 0);
572 static Local<FunctionTemplate> NewWithCFunctionOverloads(
573 Isolate* isolate, FunctionCallback callback =
nullptr,
574 Local<Value> data = Local<Value>(),
575 Local<Signature> signature = Local<Signature>(),
int length = 0,
576 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
577 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
578 const std::span<const CFunction>& c_function_overloads = {});
583 static Local<FunctionTemplate> NewWithCache(
584 Isolate* isolate, FunctionCallback callback,
585 Local<Private> cache_property, Local<Value> data = Local<Value>(),
586 Local<Signature> signature = Local<Signature>(),
int length = 0,
587 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
591 Local<Context> context);
609 FunctionCallback callback, Local<Data> data = {},
611 const std::span<const CFunction>& c_function_overloads = {});
614 void SetLength(
int length);
617 Local<ObjectTemplate> InstanceTemplate();
624 void Inherit(Local<FunctionTemplate> parent);
630 Local<ObjectTemplate> PrototypeTemplate();
638 void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
645 void SetClassName(Local<String> name);
651 void SetInterfaceName(Local<String> name);
657 void SetExceptionContext(ExceptionContext context);
663 void SetAcceptAnyReceiver(
bool value);
669 void ReadOnlyPrototype();
675 void RemovePrototype();
681 bool HasInstance(Local<Value>
object);
698 void SealAndPrepareForPromotionToReadOnly();
700 V8_INLINE static FunctionTemplate* Cast(Data* data);
705 static void CheckCast(
Data* that);
760 static_cast<int>(
flags) |
772 V8_DEPRECATED(
"Use NamedPropertySetterCallbackV2 setter instead")
785 V8_DEPRECATED(
"Use NamedPropertyDefinerCallbackV2 definer instead")
794 template <
typename TSetter = std::nullptr_t,
795 typename TDefiner = std::nullptr_t>
796 requires((std::is_same_v<TSetter, std::nullptr_t> ||
797 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
798 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>) &&
799 (std::is_same_v<TDefiner, std::nullptr_t> ||
800 std::is_same_v<TDefiner, NamedPropertyDefinerCallback> ||
801 std::is_same_v<TDefiner, NamedPropertyDefinerCallbackV2>))
824 template <
typename TSetter = std::
nullptr_t>
825 requires(std::is_same_v<TSetter, std::nullptr_t> ||
826 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
827 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>)
848 template <
typename TSetter = std::nullptr_t,
849 typename TDefiner = std::nullptr_t>
850 requires((std::is_same_v<TSetter, std::nullptr_t> ||
851 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
852 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>) &&
853 (std::is_same_v<TDefiner, std::nullptr_t> ||
854 std::is_same_v<TDefiner, NamedPropertyDefinerCallback> ||
855 std::is_same_v<TDefiner, NamedPropertyDefinerCallbackV2>))
891 static_cast<int>(
flags) |
903 V8_DEPRECATED(
"Use IndexedPropertySetterCallback setter instead")
916 V8_DEPRECATED(
"Use IndexedPropertyDefinerCallback definer instead")
925 template <
typename TSetter = std::nullptr_t,
926 typename TDefiner = std::nullptr_t>
927 requires((std::is_same_v<TSetter, std::nullptr_t> ||
928 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
929 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
930 (std::is_same_v<TDefiner, std::nullptr_t> ||
931 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
932 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
955 template <
typename TSetter = std::
nullptr_t>
956 requires(std::is_same_v<TSetter, std::nullptr_t> ||
957 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
958 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>)
979 template <
typename TSetter = std::nullptr_t,
980 typename TDefiner = std::nullptr_t>
981 requires((std::is_same_v<TSetter, std::nullptr_t> ||
982 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
983 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
984 (std::is_same_v<TDefiner, std::nullptr_t> ||
985 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
986 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
1008 template <
typename TSetter = std::nullptr_t,
1009 typename TDefiner = std::nullptr_t>
1010 requires((std::is_same_v<TSetter, std::nullptr_t> ||
1011 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
1012 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
1013 (std::is_same_v<TDefiner, std::nullptr_t> ||
1014 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
1015 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
1017 "Use IndexedPropertyHandlerConfiguration with iterable_to_list")
1043 template <
typename TSetter = std::nullptr_t,
1044 typename TDefiner = std::nullptr_t>
1045 requires((std::is_same_v<TSetter, std::nullptr_t> ||
1046 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
1047 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
1048 (std::is_same_v<TDefiner, std::nullptr_t> ||
1049 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
1050 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
1150 void MarkAsUndetectable();
1169 void SetAccessCheckCallbackAndHandler(
1179 int InternalFieldCount()
const;
1185 void SetInternalFieldCount(
int value);
1190 bool IsImmutableProto()
const;
1196 void SetImmutableProto();
1208 bool IsCodeLike()
const;
1216 void SealAndPrepareForPromotionToReadOnly();
1240 std::span<const std::string_view> names);
1257 static void CheckCast(
Data* that);
1270class V8_EXPORT Signature :
public Data {
1281 static void CheckCast(
Data* that);
1294#ifdef V8_ENABLE_CHECKS
1301#ifdef V8_ENABLE_CHECKS
1308#ifdef V8_ENABLE_CHECKS
1315#ifdef V8_ENABLE_CHECKS
1318 return reinterpret_cast<Signature*
>(data);
Definition: v8-context.h:48
Definition: v8-template.h:1229
static DictionaryTemplate * Cast(Data *data)
Definition: v8-template.h:1306
Definition: v8-template.h:557
static FunctionTemplate * Cast(Data *data)
Definition: v8-template.h:1292
Definition: v8-isolate.h:292
Definition: v8-local-handle.h:366
Definition: v8-local-handle.h:734
Definition: v8-primitive.h:81
Definition: v8-template.h:1093
static ObjectTemplate * Cast(Data *data)
Definition: v8-template.h:1299
Definition: v8-function-callback.h:224
Definition: v8-object.h:106
Definition: v8-container.h:148
Definition: v8-template.h:1269
static Signature * Cast(Data *data)
Definition: v8-template.h:1313
static MaybeLocal< String > NewFromUtf8(Isolate *isolate, const char *data, NewStringType type=NewStringType::kNormal, int length=-1)
Definition: v8-template.h:49
void Set(Local< Name > name, Local< Data > value, PropertyAttribute attributes=None)
Definition: v8-value.h:32
Definition: libplatform.h:15
PropertyAttribute
Definition: v8-object.h:154
void(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) AccessorNameGetterCallback
Definition: v8-object.h:180
Intercepted(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) NamedPropertySetterCallback
Definition: v8-template.h:240
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) IndexedPropertySetterCallback
Definition: v8-template.h:378
SideEffectType
Definition: v8-object.h:231
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyDescriptorCallback
Definition: v8-template.h:363
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< void > &info) IndexedPropertySetterCallbackV2
Definition: v8-template.h:381
void(*)(const PropertyCallbackInfo< Value > &info) IndexedPropertyIterableToListCallback
Definition: v8-template.h:438
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyGetterCallback
Definition: v8-template.h:206
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) NamedPropertyDefinerCallback
Definition: v8-template.h:339
IndexedPropertyDescriptorCallback IndexedPropertyDescriptorCallbackV2
Definition: v8-template.h:425
IndexedPropertyGetterCallback IndexedPropertyGetterCallbackV2
Definition: v8-template.h:371
Intercepted(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDefinerCallback
Definition: v8-template.h:413
Intrinsic
Definition: v8-template.h:41
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallback
Definition: v8-template.h:395
void(*)(const PropertyCallbackInfo< Array > &info) NamedPropertyEnumeratorCallback
Definition: v8-template.h:305
IndexedPropertyDeleterCallback IndexedPropertyDeleterCallbackV2
Definition: v8-template.h:397
ConstructorBehavior
Definition: v8-template.h:448
void(*)(const FunctionCallbackInfo< Value > &info) FunctionCallback
Definition: v8-function-callback.h:354
Intercepted(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) IndexedPropertyDefinerCallbackV2
Definition: v8-template.h:417
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallback
Definition: v8-template.h:369
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDefinerCallbackV2
Definition: v8-template.h:335
void(*)(const PropertyCallbackInfo< Array > &info) IndexedPropertyEnumeratorCallback
Definition: v8-template.h:406
IndexedPropertyQueryCallback IndexedPropertyQueryCallbackV2
Definition: v8-template.h:389
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:203
Intercepted
Definition: v8-template.h:160
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) NamedPropertyQueryCallback
Definition: v8-template.h:269
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< void > &info) AccessorNameSetterCallback
Definition: v8-object.h:207
uint32_t(*)(Local< Value > value, uint32_t start_index, uint32_t end_index, uint32_t *out_length, const PropertyCallbackInfo< void > &info) IndexedPropertyIndexOfCallback
Definition: v8-template.h:432
bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) AccessCheckCallback
Definition: v8-template.h:446
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDeleterCallback
Definition: v8-template.h:296
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallback
Definition: v8-template.h:423
Intercepted(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) NamedPropertySetterCallbackV2
Definition: v8-template.h:236
PropertyHandlerFlags
Definition: v8-template.h:713
@ kInternalNewCallbacksSignatures
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallback
Definition: v8-template.h:387
Definition: v8-template.h:885
IndexedPropertyGetterCallback getter
Definition: v8-template.h:1074
IndexedPropertyDefinerCallback definer
Definition: v8-template.h:1079
PropertyHandlerFlags flags
Definition: v8-template.h:1084
IndexedPropertyDescriptorCallback descriptor
Definition: v8-template.h:1080
IndexedPropertySetterCallback setter
Definition: v8-template.h:1075
IndexedPropertyIndexOfCallback index_of
Definition: v8-template.h:1081
IndexedPropertyEnumeratorCallback enumerator
Definition: v8-template.h:1078
IndexedPropertyQueryCallback query
Definition: v8-template.h:1076
Local< Value > data
Definition: v8-template.h:1083
IndexedPropertyDeleterCallback deleter
Definition: v8-template.h:1077
IndexedPropertyIterableToListCallback iterable_to_list
Definition: v8-template.h:1082
Definition: v8-template.h:754
NamedPropertyDescriptorCallback descriptor
Definition: v8-template.h:880
Local< Value > data
Definition: v8-template.h:881
NamedPropertyDeleterCallback deleter
Definition: v8-template.h:877
NamedPropertyDefinerCallbackV2 definer
Definition: v8-template.h:879
NamedPropertySetterCallbackV2 setter
Definition: v8-template.h:875
NamedPropertyEnumeratorCallback enumerator
Definition: v8-template.h:878
NamedPropertyQueryCallback query
Definition: v8-template.h:876
NamedPropertyGetterCallback getter
Definition: v8-template.h:874
PropertyHandlerFlags flags
Definition: v8-template.h:882
#define V8_INTRINSICS_LIST(F)
Definition: v8-template.h:28
#define V8_DECL_INTRINSIC(name, iname)
Definition: v8-template.h:42
#define V8_EXPORT
Definition: v8config.h:867
#define V8_INLINE
Definition: v8config.h:511
#define V8_DEPRECATE_SOON(message)
Definition: v8config.h:624
#define V8_DEPRECATED(message)
Definition: v8config.h:616
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:681