@downdraft/native-mobile-android-arm64 0.0.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +7 -0
  2. package/include/node/cppgc/allocation.h +308 -0
  3. package/include/node/cppgc/common.h +28 -0
  4. package/include/node/cppgc/cross-thread-persistent.h +462 -0
  5. package/include/node/cppgc/custom-space.h +97 -0
  6. package/include/node/cppgc/default-platform.h +68 -0
  7. package/include/node/cppgc/explicit-management.h +100 -0
  8. package/include/node/cppgc/garbage-collected.h +114 -0
  9. package/include/node/cppgc/heap-consistency.h +309 -0
  10. package/include/node/cppgc/heap-handle.h +48 -0
  11. package/include/node/cppgc/heap-state.h +82 -0
  12. package/include/node/cppgc/heap-statistics.h +126 -0
  13. package/include/node/cppgc/heap.h +202 -0
  14. package/include/node/cppgc/internal/api-constants.h +75 -0
  15. package/include/node/cppgc/internal/atomic-entry-flag.h +48 -0
  16. package/include/node/cppgc/internal/base-page-handle.h +43 -0
  17. package/include/node/cppgc/internal/caged-heap-local-data.h +117 -0
  18. package/include/node/cppgc/internal/caged-heap.h +64 -0
  19. package/include/node/cppgc/internal/compiler-specific.h +46 -0
  20. package/include/node/cppgc/internal/conditional-stack-allocated.h +41 -0
  21. package/include/node/cppgc/internal/finalizer-trait.h +93 -0
  22. package/include/node/cppgc/internal/gc-info.h +150 -0
  23. package/include/node/cppgc/internal/logging.h +50 -0
  24. package/include/node/cppgc/internal/member-storage.h +305 -0
  25. package/include/node/cppgc/internal/name-trait.h +141 -0
  26. package/include/node/cppgc/internal/persistent-node.h +219 -0
  27. package/include/node/cppgc/internal/pointer-policies.h +280 -0
  28. package/include/node/cppgc/internal/write-barrier.h +487 -0
  29. package/include/node/cppgc/liveness-broker.h +78 -0
  30. package/include/node/cppgc/macros.h +56 -0
  31. package/include/node/cppgc/member.h +669 -0
  32. package/include/node/cppgc/name-provider.h +75 -0
  33. package/include/node/cppgc/object-size-trait.h +58 -0
  34. package/include/node/cppgc/persistent.h +376 -0
  35. package/include/node/cppgc/platform.h +174 -0
  36. package/include/node/cppgc/prefinalizer.h +75 -0
  37. package/include/node/cppgc/process-heap-statistics.h +36 -0
  38. package/include/node/cppgc/sentinel-pointer.h +39 -0
  39. package/include/node/cppgc/source-location.h +16 -0
  40. package/include/node/cppgc/tagged-member.h +114 -0
  41. package/include/node/cppgc/testing.h +106 -0
  42. package/include/node/cppgc/trace-trait.h +127 -0
  43. package/include/node/cppgc/type-traits.h +272 -0
  44. package/include/node/cppgc/visitor.h +534 -0
  45. package/include/node/js_native_api.h +634 -0
  46. package/include/node/js_native_api_types.h +244 -0
  47. package/include/node/libplatform/libplatform-export.h +29 -0
  48. package/include/node/libplatform/libplatform.h +112 -0
  49. package/include/node/libplatform/v8-tracing.h +343 -0
  50. package/include/node/node.h +1744 -0
  51. package/include/node/node_api.h +265 -0
  52. package/include/node/node_api_types.h +58 -0
  53. package/include/node/node_buffer.h +94 -0
  54. package/include/node/node_object_wrap.h +145 -0
  55. package/include/node/node_version.h +116 -0
  56. package/include/node/uv/aix.h +32 -0
  57. package/include/node/uv/bsd.h +34 -0
  58. package/include/node/uv/darwin.h +61 -0
  59. package/include/node/uv/errno.h +483 -0
  60. package/include/node/uv/linux.h +34 -0
  61. package/include/node/uv/os390.h +33 -0
  62. package/include/node/uv/posix.h +31 -0
  63. package/include/node/uv/sunos.h +44 -0
  64. package/include/node/uv/threadpool.h +37 -0
  65. package/include/node/uv/tree.h +521 -0
  66. package/include/node/uv/unix.h +509 -0
  67. package/include/node/uv/version.h +43 -0
  68. package/include/node/uv/win.h +698 -0
  69. package/include/node/uv.h +1994 -0
  70. package/include/node/v8-array-buffer.h +646 -0
  71. package/include/node/v8-callbacks.h +533 -0
  72. package/include/node/v8-container.h +183 -0
  73. package/include/node/v8-context.h +580 -0
  74. package/include/node/v8-cpp-heap-external.h +56 -0
  75. package/include/node/v8-cppgc.h +194 -0
  76. package/include/node/v8-data.h +96 -0
  77. package/include/node/v8-date.h +57 -0
  78. package/include/node/v8-debug.h +210 -0
  79. package/include/node/v8-embedder-heap.h +54 -0
  80. package/include/node/v8-embedder-state-scope.h +52 -0
  81. package/include/node/v8-exception.h +298 -0
  82. package/include/node/v8-extension.h +60 -0
  83. package/include/node/v8-external-memory-accounter.h +60 -0
  84. package/include/node/v8-external.h +73 -0
  85. package/include/node/v8-fast-api-calls.h +784 -0
  86. package/include/node/v8-forward.h +82 -0
  87. package/include/node/v8-function-callback.h +708 -0
  88. package/include/node/v8-function.h +148 -0
  89. package/include/node/v8-handle-base.h +155 -0
  90. package/include/node/v8-initialization.h +343 -0
  91. package/include/node/v8-inspector-protocol.h +13 -0
  92. package/include/node/v8-inspector.h +458 -0
  93. package/include/node/v8-internal.h +1827 -0
  94. package/include/node/v8-isolate.h +1925 -0
  95. package/include/node/v8-json.h +54 -0
  96. package/include/node/v8-local-handle.h +884 -0
  97. package/include/node/v8-locker.h +138 -0
  98. package/include/node/v8-maybe.h +185 -0
  99. package/include/node/v8-memory-span.h +273 -0
  100. package/include/node/v8-message.h +215 -0
  101. package/include/node/v8-metrics.h +273 -0
  102. package/include/node/v8-microtask-queue.h +152 -0
  103. package/include/node/v8-microtask.h +28 -0
  104. package/include/node/v8-object.h +1134 -0
  105. package/include/node/v8-persistent-handle.h +556 -0
  106. package/include/node/v8-platform.h +1552 -0
  107. package/include/node/v8-primitive-object.h +118 -0
  108. package/include/node/v8-primitive.h +1056 -0
  109. package/include/node/v8-profiler.h +1401 -0
  110. package/include/node/v8-promise.h +185 -0
  111. package/include/node/v8-proxy.h +49 -0
  112. package/include/node/v8-regexp.h +105 -0
  113. package/include/node/v8-sandbox.h +170 -0
  114. package/include/node/v8-script.h +996 -0
  115. package/include/node/v8-snapshot.h +302 -0
  116. package/include/node/v8-source-location.h +91 -0
  117. package/include/node/v8-statistics.h +246 -0
  118. package/include/node/v8-template.h +1096 -0
  119. package/include/node/v8-trace-categories.h +28 -0
  120. package/include/node/v8-traced-handle.h +420 -0
  121. package/include/node/v8-typed-array.h +386 -0
  122. package/include/node/v8-unwinder-state.h +30 -0
  123. package/include/node/v8-unwinder.h +146 -0
  124. package/include/node/v8-util.h +549 -0
  125. package/include/node/v8-value-serializer-version.h +24 -0
  126. package/include/node/v8-value-serializer.h +316 -0
  127. package/include/node/v8-value.h +674 -0
  128. package/include/node/v8-version-string.h +38 -0
  129. package/include/node/v8-version.h +20 -0
  130. package/include/node/v8-wasm-trap-handler-posix.h +31 -0
  131. package/include/node/v8-wasm-trap-handler-win.h +28 -0
  132. package/include/node/v8-wasm.h +325 -0
  133. package/include/node/v8-weak-callback-info.h +88 -0
  134. package/include/node/v8.h +88 -0
  135. package/include/node/v8config.h +1077 -0
  136. package/lib/libc++_shared.so +0 -0
  137. package/lib/libnode.so +4 -0
  138. package/package.json +23 -3
@@ -0,0 +1,1096 @@
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-exception.h" // NOLINT(build/include_directory)
13
+ #include "v8-function-callback.h" // NOLINT(build/include_directory)
14
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
15
+ #include "v8-memory-span.h" // NOLINT(build/include_directory)
16
+ #include "v8-object.h" // NOLINT(build/include_directory)
17
+ #include "v8config.h" // NOLINT(build/include_directory)
18
+
19
+ namespace v8 {
20
+
21
+ class CFunction;
22
+ class FunctionTemplate;
23
+ class ObjectTemplate;
24
+ class Signature;
25
+
26
+ // --- Templates ---
27
+
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)
40
+
41
+ enum Intrinsic {
42
+ #define V8_DECL_INTRINSIC(name, iname) k##name,
43
+ V8_INTRINSICS_LIST(V8_DECL_INTRINSIC)
44
+ #undef V8_DECL_INTRINSIC
45
+ };
46
+
47
+ /**
48
+ * The superclass of object and function templates.
49
+ */
50
+ class V8_EXPORT Template : public Data {
51
+ public:
52
+ /**
53
+ * Adds a property to each instance created by this template.
54
+ *
55
+ * The property must be defined either as a primitive value, or a template.
56
+ */
57
+ void Set(Local<Name> name, Local<Data> value,
58
+ PropertyAttribute attributes = None);
59
+ void SetPrivate(Local<Private> name, Local<Data> value,
60
+ PropertyAttribute attributes = None);
61
+ V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value,
62
+ PropertyAttribute attributes = None);
63
+
64
+ /**
65
+ * Sets an "accessor property" on the object template, see
66
+ * https://tc39.es/ecma262/#sec-object-type.
67
+ *
68
+ * Whenever the property with the given name is accessed on objects
69
+ * created from this ObjectTemplate the getter and setter functions
70
+ * are called.
71
+ *
72
+ * \param name The name of the property for which an accessor is added.
73
+ * \param getter The callback to invoke when getting the property.
74
+ * \param setter The callback to invoke when setting the property.
75
+ * \param attribute The attributes of the property for which an accessor
76
+ * is added.
77
+ */
78
+ void SetAccessorProperty(
79
+ Local<Name> name,
80
+ Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
81
+ Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
82
+ PropertyAttribute attribute = None);
83
+
84
+ /**
85
+ * Sets a "data property" on the object template, see
86
+ * https://tc39.es/ecma262/#sec-object-type.
87
+ *
88
+ * Whenever the property with the given name is accessed on objects
89
+ * created from this Template the getter and setter callbacks
90
+ * are called instead of getting and setting the property directly
91
+ * on the JavaScript object.
92
+ * Note that in case a property is written via a "child" object, the setter
93
+ * will not be called according to the JavaScript specification. See
94
+ * https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver.
95
+ *
96
+ * \param name The name of the data property for which an accessor is added.
97
+ * \param getter The callback to invoke when getting the property.
98
+ * \param setter The callback to invoke when setting the property.
99
+ * \param data A piece of data that will be passed to the getter and setter
100
+ * callbacks whenever they are invoked.
101
+ * \param attribute The attributes of the property for which an accessor
102
+ * is added.
103
+ */
104
+ void SetNativeDataProperty(
105
+ Local<Name> name, AccessorNameGetterCallback getter,
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
+
111
+ /**
112
+ * Like SetNativeDataProperty, but V8 will replace the native data property
113
+ * with a real data property on first access.
114
+ */
115
+ void SetLazyDataProperty(
116
+ Local<Name> name, AccessorNameGetterCallback getter,
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
+
121
+ /**
122
+ * During template instantiation, sets the value with the intrinsic property
123
+ * from the correct context.
124
+ */
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
+
135
+ /**
136
+ * Interceptor callbacks use this value to indicate whether the request was
137
+ * intercepted or not.
138
+ *
139
+ * The values for constants and type are chosen this way for better
140
+ * performance.
141
+ */
142
+ enum class Intercepted : uint32_t { kNo = 1, kYes = 0 };
143
+
144
+ /**
145
+ * Interceptor for [[Get]] requests on an object.
146
+ *
147
+ * If the interceptor handles the request (i.e. the property should not be
148
+ * looked up beyond the interceptor or in case an exception was thrown) it
149
+ * should
150
+ * - (optionally) use info.GetReturnValue().Set()` to set the return value
151
+ * (by default the result is set to v8::Undefined),
152
+ * - return `Intercepted::kYes`.
153
+ * If the interceptor does not handle the request it must return
154
+ * `Intercepted::kNo` and it must not produce side effects.
155
+ *
156
+ * \param property The name of the property for which the request was
157
+ * intercepted.
158
+ * \param info Information about the intercepted request, such as
159
+ * isolate, object holding the property, return value. See
160
+ * `PropertyCallbackInfo`.
161
+ *
162
+ * \code
163
+ * Intercepted GetterCallback(
164
+ * Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
165
+ * if (!IsKnownProperty(info.GetIsolate(), name)) return Intercepted::kNo;
166
+ * info.GetReturnValue().Set(v8_num(42));
167
+ * return Intercepted::kYes;
168
+ * }
169
+ *
170
+ * v8::Local<v8::FunctionTemplate> templ =
171
+ * v8::FunctionTemplate::New(isolate);
172
+ * templ->InstanceTemplate()->SetHandler(
173
+ * v8::NamedPropertyHandlerConfiguration(GetterCallback));
174
+ * LocalContext env;
175
+ * env->Global()
176
+ * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
177
+ * .ToLocalChecked()
178
+ * ->NewInstance(env.local())
179
+ * .ToLocalChecked())
180
+ * .FromJust();
181
+ * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a");
182
+ * CHECK(v8_num(42)->Equals(env.local(), result).FromJust());
183
+ * \endcode
184
+ *
185
+ * See also `ObjectTemplate::SetHandler`.
186
+ */
187
+ using NamedPropertyGetterCallback = Intercepted (*)(
188
+ Local<Name> property, const PropertyCallbackInfo<Value>& info);
189
+
190
+ /**
191
+ * Interceptor for [[Set]] requests on an object.
192
+ *
193
+ * If the interceptor handles the request (i.e. the property should not be
194
+ * looked up beyond the interceptor or in case an exception was thrown) it
195
+ * should
196
+ * - use `info.GetReturnValue().Set(false)` to indicate that the operation
197
+ * failed,
198
+ * - (optionally) upon operation failure and info.ShouldThrowOnError()
199
+ * is true (indicating execution in `'use strict'` mode) the callback can
200
+ * throw TypeError if the error message needs to include more details than
201
+ * a TypeError thrown by V8 in this case,
202
+ * - return `Intercepted::kYes`.
203
+ * If the interceptor does not handle the request it must return
204
+ * `Intercepted::kNo` and it must not produce side effects.
205
+ *
206
+ * \param property The name of the property for which the request was
207
+ * intercepted.
208
+ * \param value The value which the property will have if the request
209
+ * is not intercepted.
210
+ * \param info Information about the intercepted request, such as
211
+ * isolate, object holding the property, return value, or whether running in
212
+ * `'use strict'` mode. See `PropertyCallbackInfo`.
213
+ *
214
+ * See also `ObjectTemplate::SetHandler.`
215
+ */
216
+ using NamedPropertySetterCallback =
217
+ Intercepted (*)(Local<Name> property, Local<Value> value,
218
+ const PropertyCallbackInfo<void>& info);
219
+
220
+ /**
221
+ * Intercepts all requests that query the attributes of the property,
222
+ * e.g. [[GetOwnProperty]], [[DefineOwnProperty]], [[Set]] and derived ones
223
+ * like Object.prototype.propertyIsEnumerable() and similar.
224
+ *
225
+ * If the interceptor handles the request (i.e. the property should not be
226
+ * looked up beyond the interceptor or in case an exception was thrown) it
227
+ * should
228
+ * - (optionally) use `info.GetReturnValue().Set()` to set to an Integer
229
+ * value encoding a `v8::PropertyAttribute` bits,
230
+ * - return `Intercepted::kYes`.
231
+ * If the interceptor does not handle the request it must return
232
+ * `Intercepted::kNo` and it must not produce side effects.
233
+ *
234
+ * \param property The name of the property for which the request was
235
+ * intercepted.
236
+ * \param info Information about the intercepted request, such as
237
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
238
+ * See `PropertyCallbackInfo`.
239
+ *
240
+ * \note Some functions query the property attributes internally, even though
241
+ * they do not return the attributes. For example, `hasOwnProperty()` can
242
+ * trigger this interceptor depending on the state of the object.
243
+ *
244
+ * See also `ObjectTemplate::SetHandler.`
245
+ */
246
+ using NamedPropertyQueryCallback = Intercepted (*)(
247
+ Local<Name> property, const PropertyCallbackInfo<Integer>& info);
248
+
249
+ /**
250
+ * Interceptor for [[Delete]] requests on an object.
251
+ *
252
+ * If the interceptor handles the request (i.e. the property should not be
253
+ * looked up beyond the interceptor or in case an exception was thrown) it
254
+ * should
255
+ * - use `info.GetReturnValue().Set(false)` to indicate that the operation
256
+ * failed,
257
+ * - (optionally) upon operation failure and info.ShouldThrowOnError()
258
+ * is true (indicating execution in `'use strict'` mode) the callback can
259
+ * throw TypeError if the error message needs to include more details than
260
+ * a TypeError thrown by V8 in this case,
261
+ * - return `Intercepted::kYes`.
262
+ * If the interceptor does not handle the request it must return
263
+ * `Intercepted::kNo` and it must not produce side effects.
264
+ *
265
+ * \param property The name of the property for which the request was
266
+ * intercepted.
267
+ * \param info Information about the intercepted request, such as
268
+ * isolate, object holding the property, return value, or whether running in
269
+ * `'use strict'` mode. See `PropertyCallbackInfo`.
270
+ *
271
+ * See also `ObjectTemplate::SetHandler.`
272
+ */
273
+ using NamedPropertyDeleterCallback = Intercepted (*)(
274
+ Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
275
+
276
+ /**
277
+ * Returns an array containing the names of the properties the named
278
+ * property getter intercepts.
279
+ *
280
+ * Note: The values in the array must be of type v8::Name.
281
+ */
282
+ using NamedPropertyEnumeratorCallback =
283
+ void (*)(const PropertyCallbackInfo<Array>& info);
284
+
285
+ /**
286
+ * Interceptor for [[DefineOwnProperty]] requests on an object.
287
+ *
288
+ * If the interceptor handles the request (i.e. the property should not be
289
+ * looked up beyond the interceptor or in case an exception was thrown) it
290
+ * should
291
+ * - use `info.GetReturnValue().Set(false)` to indicate that the operation
292
+ * failed,
293
+ * - (optionally) upon operation failure and info.ShouldThrowOnError()
294
+ * is true (indicating execution in `'use strict'` mode) the callback can
295
+ * throw TypeError if the error message needs to include more details than
296
+ * a TypeError thrown by V8 in this case,
297
+ * - return `Intercepted::kYes`.
298
+ * If the interceptor does not handle the request it must return
299
+ * `Intercepted::kNo` and it must not produce side effects.
300
+ *
301
+ * \param property The name of the property for which the request was
302
+ * intercepted.
303
+ * \param desc The property descriptor which is used to define the
304
+ * property if the request is not intercepted.
305
+ * \param info Information about the intercepted request, such as
306
+ * isolate, object holding the property, return value, or whether running in
307
+ * `'use strict'` mode. See `PropertyCallbackInfo`.
308
+ *
309
+ * See also `ObjectTemplate::SetHandler`.
310
+ */
311
+ using NamedPropertyDefinerCallback =
312
+ Intercepted (*)(Local<Name> property, const PropertyDescriptor& desc,
313
+ const PropertyCallbackInfo<void>& info);
314
+
315
+ /**
316
+ * Interceptor for [[GetOwnProperty]] requests on an object.
317
+ *
318
+ * If the interceptor handles the request (i.e. the property should not be
319
+ * looked up beyond the interceptor or in case an exception was thrown) it
320
+ * should
321
+ * - (optionally) use `info.GetReturnValue().Set()` to set the return value
322
+ * which must be object that can be converted to a PropertyDescriptor (for
323
+ * example, a value returned by `v8::Object::getOwnPropertyDescriptor`),
324
+ * - return `Intercepted::kYes`.
325
+ * If the interceptor does not handle the request it must return
326
+ * `Intercepted::kNo` and it must not produce side effects.
327
+ *
328
+ * \param property The name of the property for which the request was
329
+ * intercepted.
330
+ * \info Information about the intercepted request, such as
331
+ * isolate, receiver, return value, or whether running in `'use strict'` mode.
332
+ * See `PropertyCallbackInfo`.
333
+ *
334
+ * See also `ObjectTemplate::SetHandler`.
335
+ */
336
+ using NamedPropertyDescriptorCallback = Intercepted (*)(
337
+ Local<Name> property, const PropertyCallbackInfo<Value>& info);
338
+
339
+ // TODO(ishell): Rename IndexedPropertyXxxCallbackV2 back to
340
+ // IndexedPropertyXxxCallback once the old IndexedPropertyXxxCallback is
341
+ // removed.
342
+
343
+ /**
344
+ * See `v8::NamedPropertyGetterCallback`.
345
+ */
346
+ using IndexedPropertyGetterCallbackV2 =
347
+ Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
348
+
349
+ /**
350
+ * See `v8::NamedPropertySetterCallback`.
351
+ */
352
+ using IndexedPropertySetterCallbackV2 = Intercepted (*)(
353
+ uint32_t index, Local<Value> value, const PropertyCallbackInfo<void>& info);
354
+
355
+ /**
356
+ * See `v8::NamedPropertyQueryCallback`.
357
+ */
358
+ using IndexedPropertyQueryCallbackV2 =
359
+ Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
360
+
361
+ /**
362
+ * See `v8::NamedPropertyDeleterCallback`.
363
+ */
364
+ using IndexedPropertyDeleterCallbackV2 =
365
+ Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
366
+
367
+ /**
368
+ * Returns an array containing the indices of the properties the indexed
369
+ * property getter intercepts.
370
+ *
371
+ * Note: The values in the array must be uint32_t.
372
+ */
373
+ using IndexedPropertyEnumeratorCallback =
374
+ void (*)(const PropertyCallbackInfo<Array>& info);
375
+
376
+ /**
377
+ * See `v8::NamedPropertyDefinerCallback`.
378
+ */
379
+ using IndexedPropertyDefinerCallbackV2 =
380
+ Intercepted (*)(uint32_t index, const PropertyDescriptor& desc,
381
+ const PropertyCallbackInfo<void>& info);
382
+
383
+ /**
384
+ * See `v8::NamedPropertyDescriptorCallback`.
385
+ */
386
+ using IndexedPropertyDescriptorCallbackV2 =
387
+ Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
388
+
389
+ /**
390
+ * Returns true if the given context should be allowed to access the given
391
+ * object.
392
+ */
393
+ using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
394
+ Local<Object> accessed_object,
395
+ Local<Value> data);
396
+
397
+ enum class ConstructorBehavior { kThrow, kAllow };
398
+
399
+ /**
400
+ * A FunctionTemplate is used to create functions at runtime. There
401
+ * can only be one function created from a FunctionTemplate in a
402
+ * context. The lifetime of the created function is equal to the
403
+ * lifetime of the context. So in case the embedder needs to create
404
+ * temporary functions that can be collected using Scripts is
405
+ * preferred.
406
+ *
407
+ * Any modification of a FunctionTemplate after first instantiation will trigger
408
+ * a crash.
409
+ *
410
+ * A FunctionTemplate can have properties, these properties are added to the
411
+ * function object when it is created.
412
+ *
413
+ * A FunctionTemplate has a corresponding instance template which is
414
+ * used to create object instances when the function is used as a
415
+ * constructor. Properties added to the instance template are added to
416
+ * each object instance.
417
+ *
418
+ * A FunctionTemplate can have a prototype template. The prototype template
419
+ * is used to create the prototype object of the function.
420
+ *
421
+ * The following example shows how to use a FunctionTemplate:
422
+ *
423
+ * \code
424
+ * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
425
+ * t->Set(isolate, "func_property", v8::Number::New(isolate, 1));
426
+ *
427
+ * v8::Local<v8::Template> proto_t = t->PrototypeTemplate();
428
+ * proto_t->Set(isolate,
429
+ * "proto_method",
430
+ * v8::FunctionTemplate::New(isolate, InvokeCallback));
431
+ * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
432
+ *
433
+ * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
434
+ * instance_t->SetNativeDataProperty(
435
+ * String::NewFromUtf8Literal(isolate, "instance_accessor"),
436
+ * InstanceAccessorCallback);
437
+ * instance_t->SetHandler(
438
+ * NamedPropertyHandlerConfiguration(PropertyHandlerCallback));
439
+ * instance_t->Set(String::NewFromUtf8Literal(isolate, "instance_property"),
440
+ * Number::New(isolate, 3));
441
+ *
442
+ * v8::Local<v8::Function> function = t->GetFunction();
443
+ * v8::Local<v8::Object> instance = function->NewInstance();
444
+ * \endcode
445
+ *
446
+ * Let's use "function" as the JS variable name of the function object
447
+ * and "instance" for the instance object created above. The function
448
+ * and the instance will have the following properties:
449
+ *
450
+ * \code
451
+ * func_property in function == true;
452
+ * function.func_property == 1;
453
+ *
454
+ * function.prototype.proto_method() invokes 'InvokeCallback'
455
+ * function.prototype.proto_const == 2;
456
+ *
457
+ * instance instanceof function == true;
458
+ * instance.instance_accessor calls 'InstanceAccessorCallback'
459
+ * instance.instance_property == 3;
460
+ * \endcode
461
+ *
462
+ * A FunctionTemplate can inherit from another one by calling the
463
+ * FunctionTemplate::Inherit method. The following graph illustrates
464
+ * the semantics of inheritance:
465
+ *
466
+ * \code
467
+ * FunctionTemplate Parent -> Parent() . prototype -> { }
468
+ * ^ ^
469
+ * | Inherit(Parent) | .__proto__
470
+ * | |
471
+ * FunctionTemplate Child -> Child() . prototype -> { }
472
+ * \endcode
473
+ *
474
+ * A FunctionTemplate 'Child' inherits from 'Parent', the prototype
475
+ * object of the Child() function has __proto__ pointing to the
476
+ * Parent() function's prototype object. An instance of the Child
477
+ * function has all properties on Parent's instance templates.
478
+ *
479
+ * Let Parent be the FunctionTemplate initialized in the previous
480
+ * section and create a Child FunctionTemplate by:
481
+ *
482
+ * \code
483
+ * Local<FunctionTemplate> parent = t;
484
+ * Local<FunctionTemplate> child = FunctionTemplate::New();
485
+ * child->Inherit(parent);
486
+ *
487
+ * Local<Function> child_function = child->GetFunction();
488
+ * Local<Object> child_instance = child_function->NewInstance();
489
+ * \endcode
490
+ *
491
+ * The Child function and Child instance will have the following
492
+ * properties:
493
+ *
494
+ * \code
495
+ * child_func.prototype.__proto__ == function.prototype;
496
+ * child_instance.instance_accessor calls 'InstanceAccessorCallback'
497
+ * child_instance.instance_property == 3;
498
+ * \endcode
499
+ *
500
+ * The additional 'c_function' parameter refers to a fast API call, which
501
+ * must not trigger GC or JavaScript execution, or call into V8 in other
502
+ * ways. For more information how to define them, see
503
+ * include/v8-fast-api-calls.h. Please note that this feature is still
504
+ * experimental.
505
+ */
506
+ class V8_EXPORT FunctionTemplate : public Template {
507
+ public:
508
+ /** Creates a function template.*/
509
+ static Local<FunctionTemplate> New(
510
+ Isolate* isolate, FunctionCallback callback = nullptr,
511
+ Local<Value> data = Local<Value>(),
512
+ Local<Signature> signature = Local<Signature>(), int length = 0,
513
+ ConstructorBehavior behavior = ConstructorBehavior::kAllow,
514
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
515
+ const CFunction* c_function = nullptr, uint16_t instance_type = 0,
516
+ uint16_t allowed_receiver_instance_type_range_start = 0,
517
+ uint16_t allowed_receiver_instance_type_range_end = 0);
518
+
519
+ /** Creates a function template for multiple overloaded fast API calls.*/
520
+ static Local<FunctionTemplate> NewWithCFunctionOverloads(
521
+ Isolate* isolate, FunctionCallback callback = nullptr,
522
+ Local<Value> data = Local<Value>(),
523
+ Local<Signature> signature = Local<Signature>(), int length = 0,
524
+ ConstructorBehavior behavior = ConstructorBehavior::kAllow,
525
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
526
+ const MemorySpan<const CFunction>& c_function_overloads = {});
527
+
528
+ /**
529
+ * Creates a function template backed/cached by a private property.
530
+ */
531
+ static Local<FunctionTemplate> NewWithCache(
532
+ Isolate* isolate, FunctionCallback callback,
533
+ Local<Private> cache_property, Local<Value> data = Local<Value>(),
534
+ Local<Signature> signature = Local<Signature>(), int length = 0,
535
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
536
+
537
+ /** Returns the unique function instance in the current execution context.*/
538
+ V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
539
+ Local<Context> context);
540
+
541
+ /**
542
+ * Similar to Context::NewRemoteContext, this creates an instance that
543
+ * isn't backed by an actual object.
544
+ *
545
+ * The InstanceTemplate of this FunctionTemplate must have access checks with
546
+ * handlers installed.
547
+ */
548
+ V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewRemoteInstance();
549
+
550
+ /**
551
+ * Set the call-handler callback for a FunctionTemplate. This
552
+ * callback is called whenever the function created from this
553
+ * FunctionTemplate is called. The 'c_function' represents a fast
554
+ * API call, see the comment above the class declaration.
555
+ */
556
+ void SetCallHandler(
557
+ FunctionCallback callback, Local<Data> data = {},
558
+ SideEffectType side_effect_type = SideEffectType::kHasSideEffect,
559
+ const MemorySpan<const CFunction>& c_function_overloads = {});
560
+
561
+ /** Set the predefined length property for the FunctionTemplate. */
562
+ void SetLength(int length);
563
+
564
+ /** Get the InstanceTemplate. */
565
+ Local<ObjectTemplate> InstanceTemplate();
566
+
567
+ /**
568
+ * Causes the function template to inherit from a parent function template.
569
+ * This means the function's prototype.__proto__ is set to the parent
570
+ * function's prototype.
571
+ **/
572
+ void Inherit(Local<FunctionTemplate> parent);
573
+
574
+ /**
575
+ * A PrototypeTemplate is the template used to create the prototype object
576
+ * of the function created by this template.
577
+ */
578
+ Local<ObjectTemplate> PrototypeTemplate();
579
+
580
+ /**
581
+ * A PrototypeProviderTemplate is another function template whose prototype
582
+ * property is used for this template. This is mutually exclusive with setting
583
+ * a prototype template indirectly by calling PrototypeTemplate() or using
584
+ * Inherit().
585
+ **/
586
+ void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider);
587
+
588
+ /**
589
+ * Set the class name of the FunctionTemplate. This is used for
590
+ * printing objects created with the function created from the
591
+ * FunctionTemplate as its constructor.
592
+ */
593
+ void SetClassName(Local<String> name);
594
+
595
+ /**
596
+ * Set the interface name of the FunctionTemplate. This is provided as
597
+ * contextual information in an ExceptionPropagationMessage to the embedder.
598
+ */
599
+ void SetInterfaceName(Local<String> name);
600
+
601
+ /**
602
+ * Provides information on the type of FunctionTemplate for embedder
603
+ * exception handling.
604
+ */
605
+ void SetExceptionContext(ExceptionContext context);
606
+
607
+ /**
608
+ * When set to true, no access check will be performed on the receiver of a
609
+ * function call. Currently defaults to true, but this is subject to change.
610
+ */
611
+ void SetAcceptAnyReceiver(bool value);
612
+
613
+ /**
614
+ * Sets the ReadOnly flag in the attributes of the 'prototype' property
615
+ * of functions created from this FunctionTemplate to true.
616
+ */
617
+ void ReadOnlyPrototype();
618
+
619
+ /**
620
+ * Removes the prototype property from functions created from this
621
+ * FunctionTemplate.
622
+ */
623
+ void RemovePrototype();
624
+
625
+ /**
626
+ * Returns true if the given object is an instance of this function
627
+ * template.
628
+ */
629
+ bool HasInstance(Local<Value> object);
630
+
631
+ /**
632
+ * Returns true if the given value is an API object that was constructed by an
633
+ * instance of this function template (without checking for inheriting
634
+ * function templates).
635
+ *
636
+ * This is an experimental feature and may still change significantly.
637
+ */
638
+ bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
639
+
640
+ /**
641
+ * Seal the object and mark it for promotion to read only space during
642
+ * context snapshot creation.
643
+ *
644
+ * This is an experimental feature and may still change significantly.
645
+ */
646
+ void SealAndPrepareForPromotionToReadOnly();
647
+
648
+ V8_INLINE static FunctionTemplate* Cast(Data* data);
649
+
650
+ private:
651
+ FunctionTemplate();
652
+
653
+ static void CheckCast(Data* that);
654
+ friend class Context;
655
+ friend class ObjectTemplate;
656
+ };
657
+
658
+ /**
659
+ * Configuration flags for v8::NamedPropertyHandlerConfiguration or
660
+ * v8::IndexedPropertyHandlerConfiguration.
661
+ */
662
+ enum class PropertyHandlerFlags {
663
+ /**
664
+ * None.
665
+ */
666
+ kNone = 0,
667
+
668
+ /**
669
+ * Will not call into interceptor for properties on the receiver or prototype
670
+ * chain, i.e., only call into interceptor for properties that do not exist.
671
+ * Currently only valid for named interceptors.
672
+ */
673
+ kNonMasking = 1,
674
+
675
+ /**
676
+ * Will not call into interceptor for symbol lookup. Only meaningful for
677
+ * named interceptors.
678
+ */
679
+ kOnlyInterceptStrings = 1 << 1,
680
+
681
+ /**
682
+ * The getter, query, enumerator callbacks do not produce side effects.
683
+ */
684
+ kHasNoSideEffect = 1 << 2,
685
+
686
+ /**
687
+ * The interceptor may return non-configurable (PropertyAttribute::DontDelete)
688
+ * properties. When set on a global object's interceptor, it will be consulted
689
+ * during HasRestrictedGlobalProperty checks for lexical declarations.
690
+ */
691
+ kHasDontDeleteProperty = 1 << 3,
692
+
693
+ /**
694
+ * This flag is used to distinguish which callbacks were provided -
695
+ * GenericNamedPropertyXXXCallback (old signature) or
696
+ * NamedPropertyXXXCallback (new signature).
697
+ * DO NOT use this flag, it'll be removed once embedders migrate to new
698
+ * callbacks signatures.
699
+ */
700
+ kInternalNewCallbacksSignatures = 1 << 10,
701
+ };
702
+
703
+ struct NamedPropertyHandlerConfiguration {
704
+ private:
705
+ static constexpr PropertyHandlerFlags WithNewSignatureFlag(
706
+ PropertyHandlerFlags flags) {
707
+ return static_cast<PropertyHandlerFlags>(
708
+ static_cast<int>(flags) |
709
+ static_cast<int>(
710
+ PropertyHandlerFlags::kInternalNewCallbacksSignatures));
711
+ }
712
+
713
+ public:
714
+ NamedPropertyHandlerConfiguration(
715
+ NamedPropertyGetterCallback getter, //
716
+ NamedPropertySetterCallback setter, //
717
+ NamedPropertyQueryCallback query, //
718
+ NamedPropertyDeleterCallback deleter, //
719
+ NamedPropertyEnumeratorCallback enumerator, //
720
+ NamedPropertyDefinerCallback definer, //
721
+ NamedPropertyDescriptorCallback descriptor, //
722
+ Local<Value> data = Local<Value>(),
723
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
724
+ : getter(getter),
725
+ setter(setter),
726
+ query(query),
727
+ deleter(deleter),
728
+ enumerator(enumerator),
729
+ definer(definer),
730
+ descriptor(descriptor),
731
+ data(data),
732
+ flags(flags) {}
733
+
734
+ explicit NamedPropertyHandlerConfiguration(
735
+ NamedPropertyGetterCallback getter,
736
+ NamedPropertySetterCallback setter = nullptr,
737
+ NamedPropertyQueryCallback query = nullptr,
738
+ NamedPropertyDeleterCallback deleter = nullptr,
739
+ NamedPropertyEnumeratorCallback enumerator = nullptr,
740
+ Local<Value> data = Local<Value>(),
741
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
742
+ : getter(getter),
743
+ setter(setter),
744
+ query(query),
745
+ deleter(deleter),
746
+ enumerator(enumerator),
747
+ definer(nullptr),
748
+ descriptor(nullptr),
749
+ data(data),
750
+ flags(flags) {}
751
+
752
+ NamedPropertyHandlerConfiguration(
753
+ NamedPropertyGetterCallback getter, //
754
+ NamedPropertySetterCallback setter, //
755
+ NamedPropertyDescriptorCallback descriptor, //
756
+ NamedPropertyDeleterCallback deleter, //
757
+ NamedPropertyEnumeratorCallback enumerator, //
758
+ NamedPropertyDefinerCallback definer, //
759
+ Local<Value> data = Local<Value>(),
760
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
761
+ : getter(getter),
762
+ setter(setter),
763
+ query(nullptr),
764
+ deleter(deleter),
765
+ enumerator(enumerator),
766
+ definer(definer),
767
+ descriptor(descriptor),
768
+ data(data),
769
+ flags(flags) {}
770
+
771
+ NamedPropertyGetterCallback getter;
772
+ NamedPropertySetterCallback setter;
773
+ NamedPropertyQueryCallback query;
774
+ NamedPropertyDeleterCallback deleter;
775
+ NamedPropertyEnumeratorCallback enumerator;
776
+ NamedPropertyDefinerCallback definer;
777
+ NamedPropertyDescriptorCallback descriptor;
778
+ Local<Value> data;
779
+ PropertyHandlerFlags flags;
780
+ };
781
+
782
+ struct IndexedPropertyHandlerConfiguration {
783
+ private:
784
+ static constexpr PropertyHandlerFlags WithNewSignatureFlag(
785
+ PropertyHandlerFlags flags) {
786
+ return static_cast<PropertyHandlerFlags>(
787
+ static_cast<int>(flags) |
788
+ static_cast<int>(
789
+ PropertyHandlerFlags::kInternalNewCallbacksSignatures));
790
+ }
791
+
792
+ public:
793
+ IndexedPropertyHandlerConfiguration(
794
+ IndexedPropertyGetterCallbackV2 getter, //
795
+ IndexedPropertySetterCallbackV2 setter, //
796
+ IndexedPropertyQueryCallbackV2 query, //
797
+ IndexedPropertyDeleterCallbackV2 deleter, //
798
+ IndexedPropertyEnumeratorCallback enumerator, //
799
+ IndexedPropertyDefinerCallbackV2 definer, //
800
+ IndexedPropertyDescriptorCallbackV2 descriptor, //
801
+ Local<Value> data = Local<Value>(),
802
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
803
+ : getter(getter),
804
+ setter(setter),
805
+ query(query),
806
+ deleter(deleter),
807
+ enumerator(enumerator),
808
+ definer(definer),
809
+ descriptor(descriptor),
810
+ data(data),
811
+ flags(flags) {}
812
+
813
+ explicit IndexedPropertyHandlerConfiguration(
814
+ IndexedPropertyGetterCallbackV2 getter = nullptr,
815
+ IndexedPropertySetterCallbackV2 setter = nullptr,
816
+ IndexedPropertyQueryCallbackV2 query = nullptr,
817
+ IndexedPropertyDeleterCallbackV2 deleter = nullptr,
818
+ IndexedPropertyEnumeratorCallback enumerator = nullptr,
819
+ Local<Value> data = Local<Value>(),
820
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
821
+ : getter(getter),
822
+ setter(setter),
823
+ query(query),
824
+ deleter(deleter),
825
+ enumerator(enumerator),
826
+ definer(nullptr),
827
+ descriptor(nullptr),
828
+ data(data),
829
+ flags(flags) {}
830
+
831
+ IndexedPropertyHandlerConfiguration(
832
+ IndexedPropertyGetterCallbackV2 getter,
833
+ IndexedPropertySetterCallbackV2 setter,
834
+ IndexedPropertyDescriptorCallbackV2 descriptor,
835
+ IndexedPropertyDeleterCallbackV2 deleter,
836
+ IndexedPropertyEnumeratorCallback enumerator,
837
+ IndexedPropertyDefinerCallbackV2 definer,
838
+ Local<Value> data = Local<Value>(),
839
+ PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
840
+ : getter(getter),
841
+ setter(setter),
842
+ query(nullptr),
843
+ deleter(deleter),
844
+ enumerator(enumerator),
845
+ definer(definer),
846
+ descriptor(descriptor),
847
+ data(data),
848
+ flags(flags) {}
849
+
850
+ IndexedPropertyGetterCallbackV2 getter;
851
+ IndexedPropertySetterCallbackV2 setter;
852
+ IndexedPropertyQueryCallbackV2 query;
853
+ IndexedPropertyDeleterCallbackV2 deleter;
854
+ IndexedPropertyEnumeratorCallback enumerator;
855
+ IndexedPropertyDefinerCallbackV2 definer;
856
+ IndexedPropertyDescriptorCallbackV2 descriptor;
857
+ Local<Value> data;
858
+ PropertyHandlerFlags flags;
859
+ };
860
+
861
+ /**
862
+ * An ObjectTemplate is used to create objects at runtime.
863
+ *
864
+ * Properties added to an ObjectTemplate are added to each object
865
+ * created from the ObjectTemplate.
866
+ */
867
+ class V8_EXPORT ObjectTemplate : public Template {
868
+ public:
869
+ /** Creates an ObjectTemplate. */
870
+ static Local<ObjectTemplate> New(
871
+ Isolate* isolate,
872
+ Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
873
+
874
+ /**
875
+ * Creates a new instance of this template.
876
+ *
877
+ * \param context The context in which the instance is created.
878
+ */
879
+ V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
880
+
881
+ /**
882
+ * Sets a named property handler on the object template.
883
+ *
884
+ * Whenever a property whose name is a string or a symbol is accessed on
885
+ * objects created from this object template, the provided callback is
886
+ * invoked instead of accessing the property directly on the JavaScript
887
+ * object.
888
+ *
889
+ * @param configuration The NamedPropertyHandlerConfiguration that defines the
890
+ * callbacks to invoke when accessing a property.
891
+ */
892
+ void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
893
+
894
+ /**
895
+ * Sets an indexed property handler on the object template.
896
+ *
897
+ * Whenever an indexed property is accessed on objects created from
898
+ * this object template, the provided callback is invoked instead of
899
+ * accessing the property directly on the JavaScript object.
900
+ *
901
+ * @param configuration The IndexedPropertyHandlerConfiguration that defines
902
+ * the callbacks to invoke when accessing a property.
903
+ */
904
+ void SetHandler(const IndexedPropertyHandlerConfiguration& configuration);
905
+
906
+ /**
907
+ * Sets the callback to be used when calling instances created from
908
+ * this template as a function. If no callback is set, instances
909
+ * behave like normal JavaScript objects that cannot be called as a
910
+ * function.
911
+ */
912
+ void SetCallAsFunctionHandler(FunctionCallback callback,
913
+ Local<Value> data = Local<Value>());
914
+
915
+ /**
916
+ * Mark object instances of the template as undetectable.
917
+ *
918
+ * In many ways, undetectable objects behave as though they are not
919
+ * there. They behave like 'undefined' in conditionals and when
920
+ * printed. However, properties can be accessed and called as on
921
+ * normal objects.
922
+ */
923
+ void MarkAsUndetectable();
924
+
925
+ /**
926
+ * Sets access check callback on the object template and enables access
927
+ * checks.
928
+ *
929
+ * When accessing properties on instances of this object template,
930
+ * the access check callback will be called to determine whether or
931
+ * not to allow cross-context access to the properties.
932
+ */
933
+ void SetAccessCheckCallback(AccessCheckCallback callback,
934
+ Local<Value> data = Local<Value>());
935
+
936
+ /**
937
+ * Like SetAccessCheckCallback but invokes an interceptor on failed access
938
+ * checks instead of looking up all-can-read properties. You can only use
939
+ * either this method or SetAccessCheckCallback, but not both at the same
940
+ * time.
941
+ */
942
+ void SetAccessCheckCallbackAndHandler(
943
+ AccessCheckCallback callback,
944
+ const NamedPropertyHandlerConfiguration& named_handler,
945
+ const IndexedPropertyHandlerConfiguration& indexed_handler,
946
+ Local<Value> data = Local<Value>());
947
+
948
+ /**
949
+ * Gets the number of internal fields for objects generated from
950
+ * this template.
951
+ */
952
+ int InternalFieldCount() const;
953
+
954
+ /**
955
+ * Sets the number of internal fields for objects generated from
956
+ * this template.
957
+ */
958
+ void SetInternalFieldCount(int value);
959
+
960
+ /**
961
+ * Returns true if the object will be an immutable prototype exotic object.
962
+ */
963
+ bool IsImmutableProto() const;
964
+
965
+ /**
966
+ * Makes the ObjectTemplate for an immutable prototype exotic object, with an
967
+ * immutable __proto__.
968
+ */
969
+ void SetImmutableProto();
970
+
971
+ /**
972
+ * Support for TC39 "dynamic code brand checks" proposal.
973
+ *
974
+ * This API allows to mark (& query) objects as "code like", which causes
975
+ * them to be treated like Strings in the context of eval and function
976
+ * constructor.
977
+ *
978
+ * Reference: https://github.com/tc39/proposal-dynamic-code-brand-checks
979
+ */
980
+ void SetCodeLike();
981
+ bool IsCodeLike() const;
982
+
983
+ /**
984
+ * Seal the object and mark it for promotion to read only space during
985
+ * context snapshot creation.
986
+ *
987
+ * This is an experimental feature and may still change significantly.
988
+ */
989
+ void SealAndPrepareForPromotionToReadOnly();
990
+
991
+ V8_INLINE static ObjectTemplate* Cast(Data* data);
992
+
993
+ private:
994
+ ObjectTemplate();
995
+
996
+ static void CheckCast(Data* that);
997
+ friend class FunctionTemplate;
998
+ };
999
+
1000
+ /**
1001
+ * A template to create dictionary objects at runtime.
1002
+ */
1003
+ class V8_EXPORT DictionaryTemplate final : public Data {
1004
+ public:
1005
+ /** Creates a new template. Also declares data properties that can be passed
1006
+ * on instantiation of the template. Properties can only be declared on
1007
+ * construction and are then immutable. The values are passed on creating the
1008
+ * object via `NewInstance()`.
1009
+ *
1010
+ * \param names the keys that can be passed on instantiation.
1011
+ */
1012
+ static Local<DictionaryTemplate> New(
1013
+ Isolate* isolate, MemorySpan<const std::string_view> names);
1014
+
1015
+ /**
1016
+ * Creates a new instance of this template.
1017
+ *
1018
+ * \param context The context used to create the dictionary object.
1019
+ * \param property_values Values of properties that were declared using
1020
+ * `DeclareDataProperties()`. The span only passes values and expectes the
1021
+ * order to match the declaration. Non-existent properties are signaled via
1022
+ * empty `MaybeLocal`s.
1023
+ */
1024
+ V8_WARN_UNUSED_RESULT Local<Object> NewInstance(
1025
+ Local<Context> context, MemorySpan<MaybeLocal<Value>> property_values);
1026
+
1027
+ V8_INLINE static DictionaryTemplate* Cast(Data* data);
1028
+
1029
+ private:
1030
+ static void CheckCast(Data* that);
1031
+
1032
+ DictionaryTemplate();
1033
+ };
1034
+
1035
+ /**
1036
+ * A Signature specifies which receiver is valid for a function.
1037
+ *
1038
+ * A receiver matches a given signature if the receiver (or any of its
1039
+ * hidden prototypes) was created from the signature's FunctionTemplate, or
1040
+ * from a FunctionTemplate that inherits directly or indirectly from the
1041
+ * signature's FunctionTemplate.
1042
+ */
1043
+ class V8_EXPORT Signature : public Data {
1044
+ public:
1045
+ static Local<Signature> New(
1046
+ Isolate* isolate,
1047
+ Local<FunctionTemplate> receiver = Local<FunctionTemplate>());
1048
+
1049
+ V8_INLINE static Signature* Cast(Data* data);
1050
+
1051
+ private:
1052
+ Signature();
1053
+
1054
+ static void CheckCast(Data* that);
1055
+ };
1056
+
1057
+ // --- Implementation ---
1058
+
1059
+ void Template::Set(Isolate* isolate, const char* name, Local<Data> value,
1060
+ PropertyAttribute attributes) {
1061
+ Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized)
1062
+ .ToLocalChecked(),
1063
+ value, attributes);
1064
+ }
1065
+
1066
+ FunctionTemplate* FunctionTemplate::Cast(Data* data) {
1067
+ #ifdef V8_ENABLE_CHECKS
1068
+ CheckCast(data);
1069
+ #endif
1070
+ return reinterpret_cast<FunctionTemplate*>(data);
1071
+ }
1072
+
1073
+ ObjectTemplate* ObjectTemplate::Cast(Data* data) {
1074
+ #ifdef V8_ENABLE_CHECKS
1075
+ CheckCast(data);
1076
+ #endif
1077
+ return reinterpret_cast<ObjectTemplate*>(data);
1078
+ }
1079
+
1080
+ DictionaryTemplate* DictionaryTemplate::Cast(Data* data) {
1081
+ #ifdef V8_ENABLE_CHECKS
1082
+ CheckCast(data);
1083
+ #endif
1084
+ return reinterpret_cast<DictionaryTemplate*>(data);
1085
+ }
1086
+
1087
+ Signature* Signature::Cast(Data* data) {
1088
+ #ifdef V8_ENABLE_CHECKS
1089
+ CheckCast(data);
1090
+ #endif
1091
+ return reinterpret_cast<Signature*>(data);
1092
+ }
1093
+
1094
+ } // namespace v8
1095
+
1096
+ #endif // INCLUDE_V8_TEMPLATE_H_