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,
110 void SetNativeDataProperty(
114 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
115 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
118 void SetNativeDataProperty(
122 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
123 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect) {
124 SetNativeDataProperty(
126 attribute, getter_side_effect_type, setter_side_effect_type);
133 void SetLazyDataProperty(
136 SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
137 SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
206 Local<Name> property,
const PropertyCallbackInfo<Value>& info);
235 Intercepted (*)(Local<Name> property, Local<Value> value,
236 const PropertyCallbackInfo<Boolean>& info);
431 uint32_t (*)(
Local<Value> value, uint32_t start_index, uint32_t end_index,
551class V8_EXPORT FunctionTemplate :
public Template {
554 static Local<FunctionTemplate> New(
555 Isolate* isolate, FunctionCallback callback =
nullptr,
556 Local<Value> data = Local<Value>(),
557 Local<Signature> signature = Local<Signature>(),
int length = 0,
558 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
559 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
560 const CFunction* c_function =
nullptr, uint16_t instance_type = 0,
561 uint16_t allowed_receiver_instance_type_range_start = 0,
562 uint16_t allowed_receiver_instance_type_range_end = 0);
565 static Local<FunctionTemplate> NewWithCFunctionOverloads(
566 Isolate* isolate, FunctionCallback callback =
nullptr,
567 Local<Value> data = Local<Value>(),
568 Local<Signature> signature = Local<Signature>(),
int length = 0,
569 ConstructorBehavior behavior = ConstructorBehavior::kAllow,
570 SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
571 const MemorySpan<const CFunction>& c_function_overloads = {});
576 static Local<FunctionTemplate> NewWithCache(
577 Isolate* isolate, FunctionCallback callback,
578 Local<Private> cache_property, Local<Value> data = Local<Value>(),
579 Local<Signature> signature = Local<Signature>(),
int length = 0,
580 SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
584 Local<Context> context);
602 FunctionCallback callback, Local<Data> data = {},
604 const MemorySpan<const CFunction>& c_function_overloads = {});
607 void SetLength(
int length);
610 Local<ObjectTemplate> InstanceTemplate();
617 void Inherit(Local<FunctionTemplate> parent);
623 Local<ObjectTemplate> PrototypeTemplate();
631 void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
638 void SetClassName(Local<String> name);
644 void SetInterfaceName(Local<String> name);
650 void SetExceptionContext(ExceptionContext context);
656 void SetAcceptAnyReceiver(
bool value);
662 void ReadOnlyPrototype();
668 void RemovePrototype();
674 bool HasInstance(Local<Value>
object);
691 void SealAndPrepareForPromotionToReadOnly();
693 V8_INLINE static FunctionTemplate* Cast(Data* data);
698 static void CheckCast(
Data* that);
746 static_cast<int>(
flags) |
778 template <
typename TSetter = std::nullptr_t,
779 typename TDefiner = std::nullptr_t>
780 requires((std::is_same_v<TSetter, std::nullptr_t> ||
781 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
782 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>) &&
783 (std::is_same_v<TDefiner, std::nullptr_t> ||
784 std::is_same_v<TDefiner, NamedPropertyDefinerCallback> ||
785 std::is_same_v<TDefiner, NamedPropertyDefinerCallbackV2>))
808 template <
typename TSetter = std::
nullptr_t>
809 requires(std::is_same_v<TSetter, std::nullptr_t> ||
810 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
811 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>)
832 template <
typename TSetter = std::nullptr_t,
833 typename TDefiner = std::nullptr_t>
834 requires((std::is_same_v<TSetter, std::nullptr_t> ||
835 std::is_same_v<TSetter, NamedPropertySetterCallback> ||
836 std::is_same_v<TSetter, NamedPropertySetterCallbackV2>) &&
837 (std::is_same_v<TDefiner, std::nullptr_t> ||
838 std::is_same_v<TDefiner, NamedPropertyDefinerCallback> ||
839 std::is_same_v<TDefiner, NamedPropertyDefinerCallbackV2>))
875 static_cast<int>(
flags) |
907 template <
typename TSetter = std::nullptr_t,
908 typename TDefiner = std::nullptr_t>
909 requires((std::is_same_v<TSetter, std::nullptr_t> ||
910 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
911 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
912 (std::is_same_v<TDefiner, std::nullptr_t> ||
913 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
914 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
937 template <
typename TSetter = std::
nullptr_t>
938 requires(std::is_same_v<TSetter, std::nullptr_t> ||
939 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
940 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>)
961 template <
typename TSetter = std::nullptr_t,
962 typename TDefiner = std::nullptr_t>
963 requires((std::is_same_v<TSetter, std::nullptr_t> ||
964 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
965 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
966 (std::is_same_v<TDefiner, std::nullptr_t> ||
967 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
968 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
990 template <
typename TSetter = std::nullptr_t,
991 typename TDefiner = std::nullptr_t>
992 requires((std::is_same_v<TSetter, std::nullptr_t> ||
993 std::is_same_v<TSetter, IndexedPropertySetterCallback> ||
994 std::is_same_v<TSetter, IndexedPropertySetterCallbackV2>) &&
995 (std::is_same_v<TDefiner, std::nullptr_t> ||
996 std::is_same_v<TDefiner, IndexedPropertyDefinerCallback> ||
997 std::is_same_v<TDefiner, IndexedPropertyDefinerCallbackV2>))
1094 void MarkAsUndetectable();
1113 void SetAccessCheckCallbackAndHandler(
1123 int InternalFieldCount()
const;
1129 void SetInternalFieldCount(
int value);
1134 bool IsImmutableProto()
const;
1140 void SetImmutableProto();
1152 bool IsCodeLike()
const;
1160 void SealAndPrepareForPromotionToReadOnly();
1201 static void CheckCast(
Data* that);
1214class V8_EXPORT Signature :
public Data {
1225 static void CheckCast(
Data* that);
1238#ifdef V8_ENABLE_CHECKS
1245#ifdef V8_ENABLE_CHECKS
1252#ifdef V8_ENABLE_CHECKS
1259#ifdef V8_ENABLE_CHECKS
1262 return reinterpret_cast<Signature*
>(data);
Definition: v8-context.h:48
Definition: v8-template.h:1173
static DictionaryTemplate * Cast(Data *data)
Definition: v8-template.h:1250
Definition: v8-template.h:550
static FunctionTemplate * Cast(Data *data)
Definition: v8-template.h:1236
Definition: v8-isolate.h:291
Definition: v8-local-handle.h:366
Definition: v8-local-handle.h:734
Definition: v8-memory-span.h:48
Definition: v8-template.h:1037
static ObjectTemplate * Cast(Data *data)
Definition: v8-template.h:1243
Definition: v8-function-callback.h:224
Definition: v8-object.h:106
Definition: v8-container.h:148
Definition: v8-template.h:1213
static Signature * Cast(Data *data)
Definition: v8-template.h:1257
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: 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:239
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) IndexedPropertySetterCallback
Definition: v8-template.h:377
SideEffectType
Definition: v8-object.h:231
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyDescriptorCallback
Definition: v8-template.h:362
Intercepted(*)(uint32_t index, Local< Value > value, const PropertyCallbackInfo< void > &info) IndexedPropertySetterCallbackV2
Definition: v8-template.h:380
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Value > &info) NamedPropertyGetterCallback
Definition: v8-template.h:205
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< void > &info) NamedPropertyDefinerCallback
Definition: v8-template.h:338
IndexedPropertyDescriptorCallback IndexedPropertyDescriptorCallbackV2
Definition: v8-template.h:424
IndexedPropertyGetterCallback IndexedPropertyGetterCallbackV2
Definition: v8-template.h:370
Intercepted(*)(uint32_t index, const PropertyDescriptor &desc, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDefinerCallback
Definition: v8-template.h:412
Intrinsic
Definition: v8-template.h:41
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Boolean > &info) IndexedPropertyDeleterCallback
Definition: v8-template.h:394
void(*)(const PropertyCallbackInfo< Array > &info) NamedPropertyEnumeratorCallback
Definition: v8-template.h:304
IndexedPropertyDeleterCallback IndexedPropertyDeleterCallbackV2
Definition: v8-template.h:396
ConstructorBehavior
Definition: v8-template.h:441
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:416
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyGetterCallback
Definition: v8-template.h:368
Intercepted(*)(Local< Name > property, const PropertyDescriptor &desc, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDefinerCallbackV2
Definition: v8-template.h:334
void(*)(const PropertyCallbackInfo< Array > &info) IndexedPropertyEnumeratorCallback
Definition: v8-template.h:405
IndexedPropertyQueryCallback IndexedPropertyQueryCallbackV2
Definition: v8-template.h:388
void(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) AccessorNameSetterCallbackV2
Definition: v8-object.h:203
Intercepted
Definition: v8-template.h:159
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Integer > &info) NamedPropertyQueryCallback
Definition: v8-template.h:268
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:431
bool(*)(Local< Context > accessing_context, Local< Object > accessed_object, Local< Value > data) AccessCheckCallback
Definition: v8-template.h:439
Intercepted(*)(Local< Name > property, const PropertyCallbackInfo< Boolean > &info) NamedPropertyDeleterCallback
Definition: v8-template.h:295
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Value > &info) IndexedPropertyDescriptorCallback
Definition: v8-template.h:422
Intercepted(*)(Local< Name > property, Local< Value > value, const PropertyCallbackInfo< Boolean > &info) NamedPropertySetterCallbackV2
Definition: v8-template.h:235
PropertyHandlerFlags
Definition: v8-template.h:706
@ kInternalNewCallbacksSignatures
Intercepted(*)(uint32_t index, const PropertyCallbackInfo< Integer > &info) IndexedPropertyQueryCallback
Definition: v8-template.h:386
Definition: v8-template.h:869
IndexedPropertyGetterCallback getter
Definition: v8-template.h:1019
IndexedPropertyDefinerCallback definer
Definition: v8-template.h:1024
PropertyHandlerFlags flags
Definition: v8-template.h:1028
IndexedPropertyDescriptorCallback descriptor
Definition: v8-template.h:1025
IndexedPropertySetterCallback setter
Definition: v8-template.h:1020
IndexedPropertyIndexOfCallback index_of
Definition: v8-template.h:1026
IndexedPropertyEnumeratorCallback enumerator
Definition: v8-template.h:1023
IndexedPropertyQueryCallback query
Definition: v8-template.h:1021
Local< Value > data
Definition: v8-template.h:1027
IndexedPropertyDeleterCallback deleter
Definition: v8-template.h:1022
Definition: v8-template.h:740
NamedPropertyDescriptorCallback descriptor
Definition: v8-template.h:864
Local< Value > data
Definition: v8-template.h:865
NamedPropertyDeleterCallback deleter
Definition: v8-template.h:861
NamedPropertyDefinerCallbackV2 definer
Definition: v8-template.h:863
NamedPropertySetterCallbackV2 setter
Definition: v8-template.h:859
NamedPropertyEnumeratorCallback enumerator
Definition: v8-template.h:862
NamedPropertyQueryCallback query
Definition: v8-template.h:860
NamedPropertyGetterCallback getter
Definition: v8-template.h:858
PropertyHandlerFlags flags
Definition: v8-template.h:866
#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:854
#define V8_INLINE
Definition: v8config.h:508
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:678