libv8-node 21.7.2.0-aarch64-linux-musl → 24.12.0.0-aarch64-linux-musl
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.
- checksums.yaml +4 -4
- data/ext/libv8-node/location.rb +3 -5
- data/ext/libv8-node/paths.rb +2 -0
- data/lib/libv8/node/version.rb +7 -4
- data/lib/libv8/node.rb +2 -0
- data/lib/libv8-node.rb +2 -0
- data/vendor/v8/aarch64-linux-musl/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +11 -13
- data/vendor/v8/include/cppgc/default-platform.h +3 -2
- data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
- data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
- data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
- data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
- data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
- data/vendor/v8/include/cppgc/macros.h +21 -0
- data/vendor/v8/include/cppgc/member.h +70 -36
- data/vendor/v8/include/cppgc/name-provider.h +10 -0
- data/vendor/v8/include/cppgc/platform.h +11 -0
- data/vendor/v8/include/cppgc/type-traits.h +26 -4
- data/vendor/v8/include/cppgc/visitor.h +25 -1
- data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
- data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
- data/vendor/v8/include/v8-array-buffer.h +149 -46
- data/vendor/v8/include/v8-callbacks.h +100 -43
- data/vendor/v8/include/v8-container.h +54 -0
- data/vendor/v8/include/v8-context.h +92 -30
- data/vendor/v8/include/v8-cppgc.h +5 -56
- data/vendor/v8/include/v8-data.h +5 -0
- data/vendor/v8/include/v8-date.h +9 -0
- data/vendor/v8/include/v8-debug.h +11 -0
- data/vendor/v8/include/v8-embedder-heap.h +8 -20
- data/vendor/v8/include/v8-embedder-state-scope.h +2 -1
- data/vendor/v8/include/v8-exception.h +87 -9
- data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
- data/vendor/v8/include/v8-fast-api-calls.h +67 -223
- data/vendor/v8/include/v8-forward.h +1 -0
- data/vendor/v8/include/v8-function-callback.h +296 -75
- data/vendor/v8/include/v8-function.h +11 -3
- data/vendor/v8/include/v8-handle-base.h +52 -82
- data/vendor/v8/include/v8-initialization.h +26 -1
- data/vendor/v8/include/v8-inspector.h +26 -27
- data/vendor/v8/include/v8-internal.h +960 -230
- data/vendor/v8/include/v8-isolate.h +347 -226
- data/vendor/v8/include/v8-local-handle.h +307 -55
- data/vendor/v8/include/v8-maybe.h +2 -1
- data/vendor/v8/include/v8-memory-span.h +284 -4
- data/vendor/v8/include/v8-message.h +11 -5
- data/vendor/v8/include/v8-metrics.h +15 -0
- data/vendor/v8/include/v8-microtask-queue.h +0 -5
- data/vendor/v8/include/v8-object.h +314 -41
- data/vendor/v8/include/v8-persistent-handle.h +29 -39
- data/vendor/v8/include/v8-platform.h +135 -77
- data/vendor/v8/include/v8-primitive.h +223 -5
- data/vendor/v8/include/v8-profiler.h +51 -2
- data/vendor/v8/include/v8-promise.h +2 -2
- data/vendor/v8/include/v8-proxy.h +0 -1
- data/vendor/v8/include/v8-regexp.h +0 -1
- data/vendor/v8/include/v8-sandbox.h +173 -0
- data/vendor/v8/include/v8-script.h +125 -27
- data/vendor/v8/include/v8-snapshot.h +130 -23
- data/vendor/v8/include/v8-source-location.h +6 -1
- data/vendor/v8/include/v8-statistics.h +10 -24
- data/vendor/v8/include/v8-template.h +320 -193
- data/vendor/v8/include/v8-trace-categories.h +23 -0
- data/vendor/v8/include/v8-traced-handle.h +99 -76
- data/vendor/v8/include/v8-typed-array.h +111 -7
- data/vendor/v8/include/v8-unwinder-state.h +2 -3
- data/vendor/v8/include/v8-unwinder.h +2 -1
- data/vendor/v8/include/v8-util.h +10 -125
- data/vendor/v8/include/v8-value-serializer-version.h +3 -3
- data/vendor/v8/include/v8-value.h +113 -6
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +27 -0
- data/vendor/v8/include/v8-weak-callback-info.h +20 -12
- data/vendor/v8/include/v8.h +3 -3
- data/vendor/v8/include/v8config.h +116 -53
- metadata +55 -12
- data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
|
@@ -5,7 +5,11 @@
|
|
|
5
5
|
#ifndef INCLUDE_V8_TEMPLATE_H_
|
|
6
6
|
#define INCLUDE_V8_TEMPLATE_H_
|
|
7
7
|
|
|
8
|
+
#include <cstddef>
|
|
9
|
+
#include <string_view>
|
|
10
|
+
|
|
8
11
|
#include "v8-data.h" // NOLINT(build/include_directory)
|
|
12
|
+
#include "v8-exception.h" // NOLINT(build/include_directory)
|
|
9
13
|
#include "v8-function-callback.h" // NOLINT(build/include_directory)
|
|
10
14
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
|
11
15
|
#include "v8-memory-span.h" // NOLINT(build/include_directory)
|
|
@@ -57,46 +61,50 @@ class V8_EXPORT Template : public Data {
|
|
|
57
61
|
V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value,
|
|
58
62
|
PropertyAttribute attributes = None);
|
|
59
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
|
+
*/
|
|
60
78
|
void SetAccessorProperty(
|
|
61
79
|
Local<Name> name,
|
|
62
80
|
Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
|
|
63
81
|
Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
|
|
64
|
-
PropertyAttribute attribute = None
|
|
82
|
+
PropertyAttribute attribute = None);
|
|
65
83
|
|
|
66
84
|
/**
|
|
85
|
+
* Sets a "data property" on the object template, see
|
|
86
|
+
* https://tc39.es/ecma262/#sec-object-type.
|
|
87
|
+
*
|
|
67
88
|
* Whenever the property with the given name is accessed on objects
|
|
68
89
|
* created from this Template the getter and setter callbacks
|
|
69
90
|
* are called instead of getting and setting the property directly
|
|
70
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.
|
|
71
95
|
*
|
|
72
|
-
* \param name The name of the property for which an accessor is added.
|
|
96
|
+
* \param name The name of the data property for which an accessor is added.
|
|
73
97
|
* \param getter The callback to invoke when getting the property.
|
|
74
98
|
* \param setter The callback to invoke when setting the property.
|
|
75
99
|
* \param data A piece of data that will be passed to the getter and setter
|
|
76
100
|
* callbacks whenever they are invoked.
|
|
77
|
-
* \param settings Access control settings for the accessor. This is a bit
|
|
78
|
-
* field consisting of one of more of
|
|
79
|
-
* DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
|
|
80
|
-
* The default is to not allow cross-context access.
|
|
81
|
-
* ALL_CAN_READ means that all cross-context reads are allowed.
|
|
82
|
-
* ALL_CAN_WRITE means that all cross-context writes are allowed.
|
|
83
|
-
* The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
|
|
84
|
-
* cross-context access.
|
|
85
101
|
* \param attribute The attributes of the property for which an accessor
|
|
86
102
|
* is added.
|
|
87
103
|
*/
|
|
88
|
-
void SetNativeDataProperty(
|
|
89
|
-
Local<String> name, AccessorGetterCallback getter,
|
|
90
|
-
AccessorSetterCallback setter = nullptr,
|
|
91
|
-
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
|
92
|
-
AccessControl settings = DEFAULT,
|
|
93
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
|
94
|
-
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
|
95
104
|
void SetNativeDataProperty(
|
|
96
105
|
Local<Name> name, AccessorNameGetterCallback getter,
|
|
97
106
|
AccessorNameSetterCallback setter = nullptr,
|
|
98
107
|
Local<Value> data = Local<Value>(), PropertyAttribute attribute = None,
|
|
99
|
-
AccessControl settings = DEFAULT,
|
|
100
108
|
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
|
101
109
|
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
|
102
110
|
|
|
@@ -124,27 +132,36 @@ class V8_EXPORT Template : public Data {
|
|
|
124
132
|
friend class FunctionTemplate;
|
|
125
133
|
};
|
|
126
134
|
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Interceptor callbacks use this value to indicate whether the request was
|
|
137
|
+
* intercepted or not.
|
|
138
|
+
*/
|
|
139
|
+
enum class Intercepted : uint8_t { kNo = 0, kYes = 1 };
|
|
129
140
|
|
|
130
141
|
/**
|
|
131
142
|
* Interceptor for get requests on an object.
|
|
132
143
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
144
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
145
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
146
|
+
* should
|
|
147
|
+
* - (optionally) use info.GetReturnValue().Set()` to set the return value
|
|
148
|
+
* (by default the result is set to v8::Undefined),
|
|
149
|
+
* - return `Intercepted::kYes`.
|
|
150
|
+
* If the interceptor does not handle the request it must return
|
|
151
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
136
152
|
*
|
|
137
153
|
* \param property The name of the property for which the request was
|
|
138
154
|
* intercepted.
|
|
139
155
|
* \param info Information about the intercepted request, such as
|
|
140
|
-
* isolate, receiver, return value, or whether running in `'use strict`
|
|
156
|
+
* isolate, receiver, return value, or whether running in `'use strict'` mode.
|
|
141
157
|
* See `PropertyCallbackInfo`.
|
|
142
158
|
*
|
|
143
159
|
* \code
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
160
|
+
* Intercepted GetterCallback(
|
|
161
|
+
* Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
|
|
162
|
+
* if (!IsKnownProperty(info.GetIsolate(), name)) return Intercepted::kNo;
|
|
163
|
+
* info.GetReturnValue().Set(v8_num(42));
|
|
164
|
+
* return Intercepted::kYes;
|
|
148
165
|
* }
|
|
149
166
|
*
|
|
150
167
|
* v8::Local<v8::FunctionTemplate> templ =
|
|
@@ -164,18 +181,24 @@ class V8_EXPORT Template : public Data {
|
|
|
164
181
|
*
|
|
165
182
|
* See also `ObjectTemplate::SetHandler`.
|
|
166
183
|
*/
|
|
184
|
+
using NamedPropertyGetterCallback = Intercepted (*)(
|
|
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.
|
|
167
191
|
using GenericNamedPropertyGetterCallback =
|
|
168
192
|
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
|
169
193
|
|
|
170
194
|
/**
|
|
171
195
|
* Interceptor for set requests on an object.
|
|
172
196
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* present, do not not call `Set()` and do not produce side effects.
|
|
197
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
198
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
199
|
+
* should return `Intercepted::kYes`.
|
|
200
|
+
* If the interceptor does not handle the request it must return
|
|
201
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
179
202
|
*
|
|
180
203
|
* \param property The name of the property for which the request was
|
|
181
204
|
* intercepted.
|
|
@@ -185,9 +208,19 @@ using GenericNamedPropertyGetterCallback =
|
|
|
185
208
|
* isolate, receiver, return value, or whether running in `'use strict'` mode.
|
|
186
209
|
* See `PropertyCallbackInfo`.
|
|
187
210
|
*
|
|
188
|
-
* See also
|
|
189
|
-
* `ObjectTemplate::SetHandler.`
|
|
211
|
+
* See also `ObjectTemplate::SetHandler.`
|
|
190
212
|
*/
|
|
213
|
+
using NamedPropertySetterCallback =
|
|
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.
|
|
191
224
|
using GenericNamedPropertySetterCallback =
|
|
192
225
|
void (*)(Local<Name> property, Local<Value> value,
|
|
193
226
|
const PropertyCallbackInfo<Value>& info);
|
|
@@ -197,10 +230,14 @@ using GenericNamedPropertySetterCallback =
|
|
|
197
230
|
* property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and
|
|
198
231
|
* defineProperty().
|
|
199
232
|
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
233
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
234
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
235
|
+
* should
|
|
236
|
+
* - (optionally) use `info.GetReturnValue().Set()` to set to an Integer
|
|
237
|
+
* value encoding a `v8::PropertyAttribute` bits,
|
|
238
|
+
* - return `Intercepted::kYes`.
|
|
239
|
+
* If the interceptor does not handle the request it must return
|
|
240
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
204
241
|
*
|
|
205
242
|
* \param property The name of the property for which the request was
|
|
206
243
|
* intercepted.
|
|
@@ -212,21 +249,30 @@ using GenericNamedPropertySetterCallback =
|
|
|
212
249
|
* they do not return the attributes. For example, `hasOwnProperty()` can
|
|
213
250
|
* trigger this interceptor depending on the state of the object.
|
|
214
251
|
*
|
|
215
|
-
* See also
|
|
216
|
-
* `ObjectTemplate::SetHandler.`
|
|
252
|
+
* See also `ObjectTemplate::SetHandler.`
|
|
217
253
|
*/
|
|
254
|
+
using NamedPropertyQueryCallback = Intercepted (*)(
|
|
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.
|
|
218
262
|
using GenericNamedPropertyQueryCallback =
|
|
219
263
|
void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
|
|
220
264
|
|
|
221
265
|
/**
|
|
222
266
|
* Interceptor for delete requests on an object.
|
|
223
267
|
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* `info.GetReturnValue().Set(
|
|
228
|
-
*
|
|
229
|
-
*
|
|
268
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
269
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
270
|
+
* should
|
|
271
|
+
* - (optionally) use `info.GetReturnValue().Set()` to set to a Boolean value
|
|
272
|
+
* indicating whether the property deletion was successful or not,
|
|
273
|
+
* - return `Intercepted::kYes`.
|
|
274
|
+
* If the interceptor does not handle the request it must return
|
|
275
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
230
276
|
*
|
|
231
277
|
* \param property The name of the property for which the request was
|
|
232
278
|
* intercepted.
|
|
@@ -240,6 +286,16 @@ using GenericNamedPropertyQueryCallback =
|
|
|
240
286
|
*
|
|
241
287
|
* See also `ObjectTemplate::SetHandler.`
|
|
242
288
|
*/
|
|
289
|
+
using NamedPropertyDeleterCallback = Intercepted (*)(
|
|
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.
|
|
243
299
|
using GenericNamedPropertyDeleterCallback =
|
|
244
300
|
void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
|
|
245
301
|
|
|
@@ -249,18 +305,20 @@ using GenericNamedPropertyDeleterCallback =
|
|
|
249
305
|
*
|
|
250
306
|
* Note: The values in the array must be of type v8::Name.
|
|
251
307
|
*/
|
|
252
|
-
using
|
|
308
|
+
using NamedPropertyEnumeratorCallback =
|
|
253
309
|
void (*)(const PropertyCallbackInfo<Array>& info);
|
|
310
|
+
// This variant will be deprecated soon.
|
|
311
|
+
// This is just a renaming of the typedef.
|
|
312
|
+
using GenericNamedPropertyEnumeratorCallback = NamedPropertyEnumeratorCallback;
|
|
254
313
|
|
|
255
314
|
/**
|
|
256
315
|
* Interceptor for defineProperty requests on an object.
|
|
257
316
|
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
* present, do not not call `Set()` and do not produce side effects.
|
|
317
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
318
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
319
|
+
* should return `Intercepted::kYes`.
|
|
320
|
+
* If the interceptor does not handle the request it must return
|
|
321
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
264
322
|
*
|
|
265
323
|
* \param property The name of the property for which the request was
|
|
266
324
|
* intercepted.
|
|
@@ -272,6 +330,17 @@ using GenericNamedPropertyEnumeratorCallback =
|
|
|
272
330
|
*
|
|
273
331
|
* See also `ObjectTemplate::SetHandler`.
|
|
274
332
|
*/
|
|
333
|
+
using NamedPropertyDefinerCallback =
|
|
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.
|
|
275
344
|
using GenericNamedPropertyDefinerCallback =
|
|
276
345
|
void (*)(Local<Name> property, const PropertyDescriptor& desc,
|
|
277
346
|
const PropertyCallbackInfo<Value>& info);
|
|
@@ -279,10 +348,15 @@ using GenericNamedPropertyDefinerCallback =
|
|
|
279
348
|
/**
|
|
280
349
|
* Interceptor for getOwnPropertyDescriptor requests on an object.
|
|
281
350
|
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
* `
|
|
351
|
+
* If the interceptor handles the request (i.e. the property should not be
|
|
352
|
+
* looked up beyond the interceptor or in case an exception was thrown) it
|
|
353
|
+
* should
|
|
354
|
+
* - (optionally) use `info.GetReturnValue().Set()` to set the return value
|
|
355
|
+
* which must be object that can be converted to a PropertyDescriptor (for
|
|
356
|
+
* example, a value returned by `v8::Object::getOwnPropertyDescriptor`),
|
|
357
|
+
* - return `Intercepted::kYes`.
|
|
358
|
+
* If the interceptor does not handle the request it must return
|
|
359
|
+
* `Intercepted::kNo` and it must not produce side effects.
|
|
286
360
|
*
|
|
287
361
|
* \param property The name of the property for which the request was
|
|
288
362
|
* intercepted.
|
|
@@ -295,31 +369,55 @@ using GenericNamedPropertyDefinerCallback =
|
|
|
295
369
|
*
|
|
296
370
|
* See also `ObjectTemplate::SetHandler`.
|
|
297
371
|
*/
|
|
372
|
+
using NamedPropertyDescriptorCallback = Intercepted (*)(
|
|
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`.
|
|
298
380
|
using GenericNamedPropertyDescriptorCallback =
|
|
299
381
|
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
|
|
300
382
|
|
|
383
|
+
// TODO(ishell): Rename IndexedPropertyXxxCallbackV2 back to
|
|
384
|
+
// IndexedPropertyXxxCallback once the old IndexedPropertyXxxCallback is
|
|
385
|
+
// removed.
|
|
386
|
+
|
|
301
387
|
/**
|
|
302
|
-
* See `v8::
|
|
388
|
+
* See `v8::NamedPropertyGetterCallback`.
|
|
303
389
|
*/
|
|
390
|
+
using IndexedPropertyGetterCallbackV2 =
|
|
391
|
+
Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
|
392
|
+
// This variant will be deprecated soon.
|
|
304
393
|
using IndexedPropertyGetterCallback =
|
|
305
394
|
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
|
306
395
|
|
|
307
396
|
/**
|
|
308
|
-
* See `v8::
|
|
397
|
+
* See `v8::NamedPropertySetterCallback`.
|
|
309
398
|
*/
|
|
399
|
+
using IndexedPropertySetterCallbackV2 = Intercepted (*)(
|
|
400
|
+
uint32_t index, Local<Value> value, const PropertyCallbackInfo<void>& info);
|
|
401
|
+
// This variant will be deprecated soon.
|
|
310
402
|
using IndexedPropertySetterCallback =
|
|
311
403
|
void (*)(uint32_t index, Local<Value> value,
|
|
312
404
|
const PropertyCallbackInfo<Value>& info);
|
|
313
405
|
|
|
314
406
|
/**
|
|
315
|
-
* See `v8::
|
|
407
|
+
* See `v8::NamedPropertyQueryCallback`.
|
|
316
408
|
*/
|
|
409
|
+
using IndexedPropertyQueryCallbackV2 =
|
|
410
|
+
Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
|
|
411
|
+
// This variant will be deprecated soon.
|
|
317
412
|
using IndexedPropertyQueryCallback =
|
|
318
413
|
void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
|
|
319
414
|
|
|
320
415
|
/**
|
|
321
|
-
* See `v8::
|
|
416
|
+
* See `v8::NamedPropertyDeleterCallback`.
|
|
322
417
|
*/
|
|
418
|
+
using IndexedPropertyDeleterCallbackV2 =
|
|
419
|
+
Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
|
|
420
|
+
// This variant will be deprecated soon.
|
|
323
421
|
using IndexedPropertyDeleterCallback =
|
|
324
422
|
void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
|
|
325
423
|
|
|
@@ -333,15 +431,22 @@ using IndexedPropertyEnumeratorCallback =
|
|
|
333
431
|
void (*)(const PropertyCallbackInfo<Array>& info);
|
|
334
432
|
|
|
335
433
|
/**
|
|
336
|
-
* See `v8::
|
|
434
|
+
* See `v8::NamedPropertyDefinerCallback`.
|
|
337
435
|
*/
|
|
436
|
+
using IndexedPropertyDefinerCallbackV2 =
|
|
437
|
+
Intercepted (*)(uint32_t index, const PropertyDescriptor& desc,
|
|
438
|
+
const PropertyCallbackInfo<void>& info);
|
|
439
|
+
// This variant will be deprecated soon.
|
|
338
440
|
using IndexedPropertyDefinerCallback =
|
|
339
441
|
void (*)(uint32_t index, const PropertyDescriptor& desc,
|
|
340
442
|
const PropertyCallbackInfo<Value>& info);
|
|
341
443
|
|
|
342
444
|
/**
|
|
343
|
-
* See `v8::
|
|
445
|
+
* See `v8::NamedPropertyDescriptorCallback`.
|
|
344
446
|
*/
|
|
447
|
+
using IndexedPropertyDescriptorCallbackV2 =
|
|
448
|
+
Intercepted (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
|
449
|
+
// This variant will be deprecated soon.
|
|
345
450
|
using IndexedPropertyDescriptorCallback =
|
|
346
451
|
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
|
|
347
452
|
|
|
@@ -390,8 +495,8 @@ enum class ConstructorBehavior { kThrow, kAllow };
|
|
|
390
495
|
* proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2));
|
|
391
496
|
*
|
|
392
497
|
* v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate();
|
|
393
|
-
* instance_t->
|
|
394
|
-
|
|
498
|
+
* instance_t->SetNativeDataProperty(
|
|
499
|
+
* String::NewFromUtf8Literal(isolate, "instance_accessor"),
|
|
395
500
|
* InstanceAccessorCallback);
|
|
396
501
|
* instance_t->SetHandler(
|
|
397
502
|
* NamedPropertyHandlerConfiguration(PropertyHandlerCallback));
|
|
@@ -551,6 +656,18 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
|
551
656
|
*/
|
|
552
657
|
void SetClassName(Local<String> name);
|
|
553
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Set the interface name of the FunctionTemplate. This is provided as
|
|
661
|
+
* contextual information in an ExceptionPropagationMessage to the embedder.
|
|
662
|
+
*/
|
|
663
|
+
void SetInterfaceName(Local<String> name);
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Provides information on the type of FunctionTemplate for embedder
|
|
667
|
+
* exception handling.
|
|
668
|
+
*/
|
|
669
|
+
void SetExceptionContext(ExceptionContext context);
|
|
670
|
+
|
|
554
671
|
/**
|
|
555
672
|
* When set to true, no access check will be performed on the receiver of a
|
|
556
673
|
* function call. Currently defaults to true, but this is subject to change.
|
|
@@ -584,6 +701,14 @@ class V8_EXPORT FunctionTemplate : public Template {
|
|
|
584
701
|
*/
|
|
585
702
|
bool IsLeafTemplateForApiObject(v8::Local<v8::Value> value) const;
|
|
586
703
|
|
|
704
|
+
/**
|
|
705
|
+
* Checks if the object can be promoted to read only space, seals it and
|
|
706
|
+
* prepares for promotion.
|
|
707
|
+
*
|
|
708
|
+
* This is an experimental feature and may still change significantly.
|
|
709
|
+
*/
|
|
710
|
+
void SealAndPrepareForPromotionToReadOnly();
|
|
711
|
+
|
|
587
712
|
V8_INLINE static FunctionTemplate* Cast(Data* data);
|
|
588
713
|
|
|
589
714
|
private:
|
|
@@ -605,37 +730,52 @@ enum class PropertyHandlerFlags {
|
|
|
605
730
|
kNone = 0,
|
|
606
731
|
|
|
607
732
|
/**
|
|
608
|
-
*
|
|
609
|
-
*/
|
|
610
|
-
kAllCanRead = 1,
|
|
611
|
-
|
|
612
|
-
/** Will not call into interceptor for properties on the receiver or prototype
|
|
733
|
+
* Will not call into interceptor for properties on the receiver or prototype
|
|
613
734
|
* chain, i.e., only call into interceptor for properties that do not exist.
|
|
614
735
|
* Currently only valid for named interceptors.
|
|
615
736
|
*/
|
|
616
|
-
kNonMasking = 1
|
|
737
|
+
kNonMasking = 1,
|
|
617
738
|
|
|
618
739
|
/**
|
|
619
740
|
* Will not call into interceptor for symbol lookup. Only meaningful for
|
|
620
741
|
* named interceptors.
|
|
621
742
|
*/
|
|
622
|
-
kOnlyInterceptStrings = 1 <<
|
|
743
|
+
kOnlyInterceptStrings = 1 << 1,
|
|
623
744
|
|
|
624
745
|
/**
|
|
625
746
|
* The getter, query, enumerator callbacks do not produce side effects.
|
|
626
747
|
*/
|
|
627
|
-
kHasNoSideEffect = 1 <<
|
|
748
|
+
kHasNoSideEffect = 1 << 2,
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* This flag is used to distinguish which callbacks were provided -
|
|
752
|
+
* GenericNamedPropertyXXXCallback (old signature) or
|
|
753
|
+
* NamedPropertyXXXCallback (new signature).
|
|
754
|
+
* DO NOT use this flag, it'll be removed once embedders migrate to new
|
|
755
|
+
* callbacks signatures.
|
|
756
|
+
*/
|
|
757
|
+
kInternalNewCallbacksSignatures = 1 << 10,
|
|
628
758
|
};
|
|
629
759
|
|
|
630
760
|
struct NamedPropertyHandlerConfiguration {
|
|
761
|
+
private:
|
|
762
|
+
static constexpr PropertyHandlerFlags WithNewSignatureFlag(
|
|
763
|
+
PropertyHandlerFlags flags) {
|
|
764
|
+
return static_cast<PropertyHandlerFlags>(
|
|
765
|
+
static_cast<int>(flags) |
|
|
766
|
+
static_cast<int>(
|
|
767
|
+
PropertyHandlerFlags::kInternalNewCallbacksSignatures));
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
public:
|
|
631
771
|
NamedPropertyHandlerConfiguration(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
772
|
+
NamedPropertyGetterCallback getter, //
|
|
773
|
+
NamedPropertySetterCallback setter, //
|
|
774
|
+
NamedPropertyQueryCallback query, //
|
|
775
|
+
NamedPropertyDeleterCallback deleter, //
|
|
776
|
+
NamedPropertyEnumeratorCallback enumerator, //
|
|
777
|
+
NamedPropertyDefinerCallback definer, //
|
|
778
|
+
NamedPropertyDescriptorCallback descriptor, //
|
|
639
779
|
Local<Value> data = Local<Value>(),
|
|
640
780
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
641
781
|
: getter(getter),
|
|
@@ -648,13 +788,12 @@ struct NamedPropertyHandlerConfiguration {
|
|
|
648
788
|
data(data),
|
|
649
789
|
flags(flags) {}
|
|
650
790
|
|
|
651
|
-
NamedPropertyHandlerConfiguration(
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
GenericNamedPropertyEnumeratorCallback enumerator = nullptr,
|
|
791
|
+
explicit NamedPropertyHandlerConfiguration(
|
|
792
|
+
NamedPropertyGetterCallback getter,
|
|
793
|
+
NamedPropertySetterCallback setter = nullptr,
|
|
794
|
+
NamedPropertyQueryCallback query = nullptr,
|
|
795
|
+
NamedPropertyDeleterCallback deleter = nullptr,
|
|
796
|
+
NamedPropertyEnumeratorCallback enumerator = nullptr,
|
|
658
797
|
Local<Value> data = Local<Value>(),
|
|
659
798
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
660
799
|
: getter(getter),
|
|
@@ -668,12 +807,12 @@ struct NamedPropertyHandlerConfiguration {
|
|
|
668
807
|
flags(flags) {}
|
|
669
808
|
|
|
670
809
|
NamedPropertyHandlerConfiguration(
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
810
|
+
NamedPropertyGetterCallback getter, //
|
|
811
|
+
NamedPropertySetterCallback setter, //
|
|
812
|
+
NamedPropertyDescriptorCallback descriptor, //
|
|
813
|
+
NamedPropertyDeleterCallback deleter, //
|
|
814
|
+
NamedPropertyEnumeratorCallback enumerator, //
|
|
815
|
+
NamedPropertyDefinerCallback definer, //
|
|
677
816
|
Local<Value> data = Local<Value>(),
|
|
678
817
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
679
818
|
: getter(getter),
|
|
@@ -686,25 +825,36 @@ struct NamedPropertyHandlerConfiguration {
|
|
|
686
825
|
data(data),
|
|
687
826
|
flags(flags) {}
|
|
688
827
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
828
|
+
NamedPropertyGetterCallback getter;
|
|
829
|
+
NamedPropertySetterCallback setter;
|
|
830
|
+
NamedPropertyQueryCallback query;
|
|
831
|
+
NamedPropertyDeleterCallback deleter;
|
|
832
|
+
NamedPropertyEnumeratorCallback enumerator;
|
|
833
|
+
NamedPropertyDefinerCallback definer;
|
|
834
|
+
NamedPropertyDescriptorCallback descriptor;
|
|
696
835
|
Local<Value> data;
|
|
697
836
|
PropertyHandlerFlags flags;
|
|
698
837
|
};
|
|
699
838
|
|
|
700
839
|
struct IndexedPropertyHandlerConfiguration {
|
|
840
|
+
private:
|
|
841
|
+
static constexpr PropertyHandlerFlags WithNewSignatureFlag(
|
|
842
|
+
PropertyHandlerFlags flags) {
|
|
843
|
+
return static_cast<PropertyHandlerFlags>(
|
|
844
|
+
static_cast<int>(flags) |
|
|
845
|
+
static_cast<int>(
|
|
846
|
+
PropertyHandlerFlags::kInternalNewCallbacksSignatures));
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
public:
|
|
701
850
|
IndexedPropertyHandlerConfiguration(
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
851
|
+
IndexedPropertyGetterCallbackV2 getter, //
|
|
852
|
+
IndexedPropertySetterCallbackV2 setter, //
|
|
853
|
+
IndexedPropertyQueryCallbackV2 query, //
|
|
854
|
+
IndexedPropertyDeleterCallbackV2 deleter, //
|
|
855
|
+
IndexedPropertyEnumeratorCallback enumerator, //
|
|
856
|
+
IndexedPropertyDefinerCallbackV2 definer, //
|
|
857
|
+
IndexedPropertyDescriptorCallbackV2 descriptor, //
|
|
708
858
|
Local<Value> data = Local<Value>(),
|
|
709
859
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
710
860
|
: getter(getter),
|
|
@@ -717,12 +867,11 @@ struct IndexedPropertyHandlerConfiguration {
|
|
|
717
867
|
data(data),
|
|
718
868
|
flags(flags) {}
|
|
719
869
|
|
|
720
|
-
IndexedPropertyHandlerConfiguration(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
IndexedPropertyDeleterCallback deleter = nullptr,
|
|
870
|
+
explicit IndexedPropertyHandlerConfiguration(
|
|
871
|
+
IndexedPropertyGetterCallbackV2 getter = nullptr,
|
|
872
|
+
IndexedPropertySetterCallbackV2 setter = nullptr,
|
|
873
|
+
IndexedPropertyQueryCallbackV2 query = nullptr,
|
|
874
|
+
IndexedPropertyDeleterCallbackV2 deleter = nullptr,
|
|
726
875
|
IndexedPropertyEnumeratorCallback enumerator = nullptr,
|
|
727
876
|
Local<Value> data = Local<Value>(),
|
|
728
877
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
@@ -737,12 +886,12 @@ struct IndexedPropertyHandlerConfiguration {
|
|
|
737
886
|
flags(flags) {}
|
|
738
887
|
|
|
739
888
|
IndexedPropertyHandlerConfiguration(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
889
|
+
IndexedPropertyGetterCallbackV2 getter,
|
|
890
|
+
IndexedPropertySetterCallbackV2 setter,
|
|
891
|
+
IndexedPropertyDescriptorCallbackV2 descriptor,
|
|
892
|
+
IndexedPropertyDeleterCallbackV2 deleter,
|
|
744
893
|
IndexedPropertyEnumeratorCallback enumerator,
|
|
745
|
-
|
|
894
|
+
IndexedPropertyDefinerCallbackV2 definer,
|
|
746
895
|
Local<Value> data = Local<Value>(),
|
|
747
896
|
PropertyHandlerFlags flags = PropertyHandlerFlags::kNone)
|
|
748
897
|
: getter(getter),
|
|
@@ -755,13 +904,13 @@ struct IndexedPropertyHandlerConfiguration {
|
|
|
755
904
|
data(data),
|
|
756
905
|
flags(flags) {}
|
|
757
906
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
907
|
+
IndexedPropertyGetterCallbackV2 getter;
|
|
908
|
+
IndexedPropertySetterCallbackV2 setter;
|
|
909
|
+
IndexedPropertyQueryCallbackV2 query;
|
|
910
|
+
IndexedPropertyDeleterCallbackV2 deleter;
|
|
762
911
|
IndexedPropertyEnumeratorCallback enumerator;
|
|
763
|
-
|
|
764
|
-
|
|
912
|
+
IndexedPropertyDefinerCallbackV2 definer;
|
|
913
|
+
IndexedPropertyDescriptorCallbackV2 descriptor;
|
|
765
914
|
Local<Value> data;
|
|
766
915
|
PropertyHandlerFlags flags;
|
|
767
916
|
};
|
|
@@ -779,47 +928,12 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
|
779
928
|
Isolate* isolate,
|
|
780
929
|
Local<FunctionTemplate> constructor = Local<FunctionTemplate>());
|
|
781
930
|
|
|
782
|
-
/** Creates a new instance of this template.*/
|
|
783
|
-
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
|
|
784
|
-
|
|
785
931
|
/**
|
|
786
|
-
*
|
|
932
|
+
* Creates a new instance of this template.
|
|
787
933
|
*
|
|
788
|
-
*
|
|
789
|
-
* created from this ObjectTemplate the getter and setter callbacks
|
|
790
|
-
* are called instead of getting and setting the property directly
|
|
791
|
-
* on the JavaScript object.
|
|
792
|
-
*
|
|
793
|
-
* \param name The name of the property for which an accessor is added.
|
|
794
|
-
* \param getter The callback to invoke when getting the property.
|
|
795
|
-
* \param setter The callback to invoke when setting the property.
|
|
796
|
-
* \param data A piece of data that will be passed to the getter and setter
|
|
797
|
-
* callbacks whenever they are invoked.
|
|
798
|
-
* \param settings Access control settings for the accessor. This is a bit
|
|
799
|
-
* field consisting of one of more of
|
|
800
|
-
* DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2.
|
|
801
|
-
* The default is to not allow cross-context access.
|
|
802
|
-
* ALL_CAN_READ means that all cross-context reads are allowed.
|
|
803
|
-
* ALL_CAN_WRITE means that all cross-context writes are allowed.
|
|
804
|
-
* The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all
|
|
805
|
-
* cross-context access.
|
|
806
|
-
* \param attribute The attributes of the property for which an accessor
|
|
807
|
-
* is added.
|
|
934
|
+
* \param context The context in which the instance is created.
|
|
808
935
|
*/
|
|
809
|
-
|
|
810
|
-
Local<String> name, AccessorGetterCallback getter,
|
|
811
|
-
AccessorSetterCallback setter = nullptr,
|
|
812
|
-
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
|
|
813
|
-
PropertyAttribute attribute = None,
|
|
814
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
|
815
|
-
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
|
816
|
-
void SetAccessor(
|
|
817
|
-
Local<Name> name, AccessorNameGetterCallback getter,
|
|
818
|
-
AccessorNameSetterCallback setter = nullptr,
|
|
819
|
-
Local<Value> data = Local<Value>(), AccessControl settings = DEFAULT,
|
|
820
|
-
PropertyAttribute attribute = None,
|
|
821
|
-
SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
|
|
822
|
-
SideEffectType setter_side_effect_type = SideEffectType::kHasSideEffect);
|
|
936
|
+
V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context);
|
|
823
937
|
|
|
824
938
|
/**
|
|
825
939
|
* Sets a named property handler on the object template.
|
|
@@ -834,34 +948,6 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
|
834
948
|
*/
|
|
835
949
|
void SetHandler(const NamedPropertyHandlerConfiguration& configuration);
|
|
836
950
|
|
|
837
|
-
/**
|
|
838
|
-
* Sets an indexed property handler on the object template.
|
|
839
|
-
*
|
|
840
|
-
* Whenever an indexed property is accessed on objects created from
|
|
841
|
-
* this object template, the provided callback is invoked instead of
|
|
842
|
-
* accessing the property directly on the JavaScript object.
|
|
843
|
-
*
|
|
844
|
-
* \param getter The callback to invoke when getting a property.
|
|
845
|
-
* \param setter The callback to invoke when setting a property.
|
|
846
|
-
* \param query The callback to invoke to check if an object has a property.
|
|
847
|
-
* \param deleter The callback to invoke when deleting a property.
|
|
848
|
-
* \param enumerator The callback to invoke to enumerate all the indexed
|
|
849
|
-
* properties of an object.
|
|
850
|
-
* \param data A piece of data that will be passed to the callbacks
|
|
851
|
-
* whenever they are invoked.
|
|
852
|
-
*/
|
|
853
|
-
// TODO(dcarney): deprecate
|
|
854
|
-
void SetIndexedPropertyHandler(
|
|
855
|
-
IndexedPropertyGetterCallback getter,
|
|
856
|
-
IndexedPropertySetterCallback setter = nullptr,
|
|
857
|
-
IndexedPropertyQueryCallback query = nullptr,
|
|
858
|
-
IndexedPropertyDeleterCallback deleter = nullptr,
|
|
859
|
-
IndexedPropertyEnumeratorCallback enumerator = nullptr,
|
|
860
|
-
Local<Value> data = Local<Value>()) {
|
|
861
|
-
SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query,
|
|
862
|
-
deleter, enumerator, data));
|
|
863
|
-
}
|
|
864
|
-
|
|
865
951
|
/**
|
|
866
952
|
* Sets an indexed property handler on the object template.
|
|
867
953
|
*
|
|
@@ -955,12 +1041,46 @@ class V8_EXPORT ObjectTemplate : public Template {
|
|
|
955
1041
|
|
|
956
1042
|
private:
|
|
957
1043
|
ObjectTemplate();
|
|
958
|
-
|
|
959
|
-
Local<FunctionTemplate> constructor);
|
|
1044
|
+
|
|
960
1045
|
static void CheckCast(Data* that);
|
|
961
1046
|
friend class FunctionTemplate;
|
|
962
1047
|
};
|
|
963
1048
|
|
|
1049
|
+
/**
|
|
1050
|
+
* A template to create dictionary objects at runtime.
|
|
1051
|
+
*/
|
|
1052
|
+
class V8_EXPORT DictionaryTemplate final {
|
|
1053
|
+
public:
|
|
1054
|
+
/** Creates a new template. Also declares data properties that can be passed
|
|
1055
|
+
* on instantiation of the template. Properties can only be declared on
|
|
1056
|
+
* construction and are then immutable. The values are passed on creating the
|
|
1057
|
+
* object via `NewInstance()`.
|
|
1058
|
+
*
|
|
1059
|
+
* \param names the keys that can be passed on instantiation.
|
|
1060
|
+
*/
|
|
1061
|
+
static Local<DictionaryTemplate> New(
|
|
1062
|
+
Isolate* isolate, MemorySpan<const std::string_view> names);
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Creates a new instance of this template.
|
|
1066
|
+
*
|
|
1067
|
+
* \param context The context used to create the dictionary object.
|
|
1068
|
+
* \param property_values Values of properties that were declared using
|
|
1069
|
+
* `DeclareDataProperties()`. The span only passes values and expectes the
|
|
1070
|
+
* order to match the declaration. Non-existent properties are signaled via
|
|
1071
|
+
* empty `MaybeLocal`s.
|
|
1072
|
+
*/
|
|
1073
|
+
V8_WARN_UNUSED_RESULT Local<Object> NewInstance(
|
|
1074
|
+
Local<Context> context, MemorySpan<MaybeLocal<Value>> property_values);
|
|
1075
|
+
|
|
1076
|
+
V8_INLINE static DictionaryTemplate* Cast(Data* data);
|
|
1077
|
+
|
|
1078
|
+
private:
|
|
1079
|
+
static void CheckCast(Data* that);
|
|
1080
|
+
|
|
1081
|
+
DictionaryTemplate();
|
|
1082
|
+
};
|
|
1083
|
+
|
|
964
1084
|
/**
|
|
965
1085
|
* A Signature specifies which receiver is valid for a function.
|
|
966
1086
|
*
|
|
@@ -1006,6 +1126,13 @@ ObjectTemplate* ObjectTemplate::Cast(Data* data) {
|
|
|
1006
1126
|
return reinterpret_cast<ObjectTemplate*>(data);
|
|
1007
1127
|
}
|
|
1008
1128
|
|
|
1129
|
+
DictionaryTemplate* DictionaryTemplate::Cast(Data* data) {
|
|
1130
|
+
#ifdef V8_ENABLE_CHECKS
|
|
1131
|
+
CheckCast(data);
|
|
1132
|
+
#endif
|
|
1133
|
+
return reinterpret_cast<DictionaryTemplate*>(data);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1009
1136
|
Signature* Signature::Cast(Data* data) {
|
|
1010
1137
|
#ifdef V8_ENABLE_CHECKS
|
|
1011
1138
|
CheckCast(data);
|