@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,1056 @@
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_PRIMITIVE_H_
6
+ #define INCLUDE_V8_PRIMITIVE_H_
7
+
8
+ #include "v8-data.h" // NOLINT(build/include_directory)
9
+ #include "v8-internal.h" // NOLINT(build/include_directory)
10
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
11
+ #include "v8-value.h" // NOLINT(build/include_directory)
12
+ #include "v8config.h" // NOLINT(build/include_directory)
13
+
14
+ namespace v8 {
15
+
16
+ class Context;
17
+ class Isolate;
18
+ class String;
19
+
20
+ namespace internal {
21
+ class ExternalString;
22
+ class ScopedExternalStringLock;
23
+ class StringForwardingTable;
24
+ } // namespace internal
25
+
26
+ /**
27
+ * The superclass of primitive values. See ECMA-262 4.3.2.
28
+ */
29
+ class V8_EXPORT Primitive : public Value {};
30
+
31
+ /**
32
+ * A primitive boolean value (ECMA-262, 4.3.14). Either the true
33
+ * or false value.
34
+ */
35
+ class V8_EXPORT Boolean : public Primitive {
36
+ public:
37
+ bool Value() const;
38
+ V8_INLINE static Boolean* Cast(v8::Data* data) {
39
+ #ifdef V8_ENABLE_CHECKS
40
+ CheckCast(data);
41
+ #endif
42
+ return static_cast<Boolean*>(data);
43
+ }
44
+
45
+ V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value);
46
+
47
+ private:
48
+ static void CheckCast(v8::Data* that);
49
+ };
50
+
51
+ /**
52
+ * An array to hold Primitive values. This is used by the embedder to
53
+ * pass host defined options to the ScriptOptions during compilation.
54
+ *
55
+ * This is passed back to the embedder as part of
56
+ * HostImportModuleDynamicallyCallback for module loading.
57
+ */
58
+ class V8_EXPORT PrimitiveArray : public Data {
59
+ public:
60
+ static Local<PrimitiveArray> New(Isolate* isolate, int length);
61
+ int Length() const;
62
+ void Set(Isolate* isolate, int index, Local<Primitive> item);
63
+ Local<Primitive> Get(Isolate* isolate, int index);
64
+
65
+ V8_INLINE static PrimitiveArray* Cast(Data* data) {
66
+ #ifdef V8_ENABLE_CHECKS
67
+ CheckCast(data);
68
+ #endif
69
+ return reinterpret_cast<PrimitiveArray*>(data);
70
+ }
71
+
72
+ private:
73
+ static void CheckCast(Data* obj);
74
+ };
75
+
76
+ /**
77
+ * A superclass for symbols and strings.
78
+ */
79
+ class V8_EXPORT Name : public Primitive {
80
+ public:
81
+ /**
82
+ * Returns the identity hash for this object. The current implementation
83
+ * uses an inline property on the object to store the identity hash.
84
+ *
85
+ * The return value will never be 0. Also, it is not guaranteed to be
86
+ * unique.
87
+ */
88
+ int GetIdentityHash();
89
+
90
+ V8_INLINE static Name* Cast(Data* data) {
91
+ #ifdef V8_ENABLE_CHECKS
92
+ CheckCast(data);
93
+ #endif
94
+ return static_cast<Name*>(data);
95
+ }
96
+
97
+ private:
98
+ static void CheckCast(Data* that);
99
+ };
100
+
101
+ /**
102
+ * A flag describing different modes of string creation.
103
+ *
104
+ * Aside from performance implications there are no differences between the two
105
+ * creation modes.
106
+ */
107
+ enum class NewStringType {
108
+ /**
109
+ * Create a new string, always allocating new storage memory.
110
+ */
111
+ kNormal,
112
+
113
+ /**
114
+ * Acts as a hint that the string should be created in the
115
+ * old generation heap space and be deduplicated if an identical string
116
+ * already exists.
117
+ */
118
+ kInternalized
119
+ };
120
+
121
+ /**
122
+ * A JavaScript string value (ECMA-262, 4.3.17).
123
+ */
124
+ class V8_EXPORT String : public Name {
125
+ public:
126
+ static constexpr int kMaxLength =
127
+ internal::kApiSystemPointerSize == 4 ? (1 << 28) - 16 : (1 << 29) - 24;
128
+
129
+ enum Encoding {
130
+ UNKNOWN_ENCODING = 0x1,
131
+ TWO_BYTE_ENCODING = 0x0,
132
+ ONE_BYTE_ENCODING = 0x8
133
+ };
134
+ /**
135
+ * Returns the number of characters (UTF-16 code units) in this string.
136
+ */
137
+ int Length() const;
138
+
139
+ /**
140
+ * Returns the number of bytes needed for the Utf8 encoding of this string.
141
+ * TODO(http://crbug.com/373485796): rename back to Utf8Length().
142
+ */
143
+ size_t Utf8LengthV2(Isolate* isolate) const;
144
+
145
+ /**
146
+ * Returns whether this string is known to contain only one byte data,
147
+ * i.e. ISO-8859-1 code points.
148
+ * Does not read the string.
149
+ * False negatives are possible.
150
+ */
151
+ bool IsOneByte() const;
152
+
153
+ /**
154
+ * Returns whether this string contain only one byte data,
155
+ * i.e. ISO-8859-1 code points.
156
+ * Will read the entire string in some cases.
157
+ */
158
+ bool ContainsOnlyOneByte() const;
159
+
160
+ struct WriteFlags {
161
+ enum {
162
+ kNone = 0,
163
+ // Indicates that the output string should be null-terminated. In that
164
+ // case, the output buffer must include sufficient space for the
165
+ // additional null character.
166
+ kNullTerminate = 1,
167
+ // Used by WriteUtf8 to replace orphan surrogate code units with the
168
+ // unicode replacement character. Needs to be set to guarantee valid UTF-8
169
+ // output.
170
+ kReplaceInvalidUtf8 = 2
171
+ };
172
+ };
173
+
174
+ /**
175
+ * Write the contents of the string to an external buffer.
176
+ *
177
+ * Copies length characters into the output buffer starting at offset. The
178
+ * output buffer must have sufficient space for all characters and the null
179
+ * terminator if null termination is requested through the flags.
180
+ *
181
+ * \param offset The position within the string at which copying begins.
182
+ * \param length The number of characters to copy from the string.
183
+ * \param buffer The buffer into which the string will be copied.
184
+ * \param flags Various flags that influence the behavior of this operation.
185
+ * TODO(http://crbug.com/373485796): rename back to Write() and
186
+ * WriteOneByte().
187
+ */
188
+ void WriteV2(Isolate* isolate, uint32_t offset, uint32_t length,
189
+ uint16_t* buffer, int flags = WriteFlags::kNone) const;
190
+ void WriteOneByteV2(Isolate* isolate, uint32_t offset, uint32_t length,
191
+ uint8_t* buffer, int flags = WriteFlags::kNone) const;
192
+
193
+ /**
194
+ * Encode the contents of the string as Utf8 into an external buffer.
195
+ *
196
+ * Encodes the characters of this string as Utf8 and writes them into the
197
+ * output buffer until either all characters were encoded or the buffer is
198
+ * full. Will not write partial UTF-8 sequences, preferring to stop before
199
+ * the end of the buffer. If null termination is requested, the output buffer
200
+ * will always be null terminated even if not all characters fit. In that
201
+ * case, the capacity must be at least one. The required size of the output
202
+ * buffer can be determined using Utf8LengthV2().
203
+ *
204
+ * \param buffer The buffer into which the string will be written.
205
+ * \param capacity The number of bytes available in the output buffer.
206
+ * \param flags Various flags that influence the behavior of this operation.
207
+ * \param processed_characters_return The number of processed characters from
208
+ * the buffer.
209
+ * \return The number of bytes copied to the buffer including the null
210
+ * terminator (if written).
211
+ * TODO(http://crbug.com/373485796): rename back to WriteUtf8().
212
+ */
213
+ size_t WriteUtf8V2(Isolate* isolate, char* buffer, size_t capacity,
214
+ int flags = WriteFlags::kNone,
215
+ size_t* processed_characters_return = nullptr) const;
216
+
217
+ /**
218
+ * A zero length string.
219
+ */
220
+ V8_INLINE static Local<String> Empty(Isolate* isolate);
221
+
222
+ /**
223
+ * Returns true if the string is external.
224
+ */
225
+ bool IsExternal() const;
226
+
227
+ /**
228
+ * Returns true if the string is both external and two-byte.
229
+ */
230
+ bool IsExternalTwoByte() const;
231
+
232
+ /**
233
+ * Returns true if the string is both external and one-byte.
234
+ */
235
+ bool IsExternalOneByte() const;
236
+
237
+ /**
238
+ * Returns the internalized string. See `NewStringType::kInternalized` for
239
+ * details on internalized strings.
240
+ */
241
+ Local<String> InternalizeString(Isolate* isolate);
242
+
243
+ class V8_EXPORT ExternalStringResourceBase {
244
+ public:
245
+ virtual ~ExternalStringResourceBase() = default;
246
+
247
+ /**
248
+ * If a string is cacheable, the value returned by
249
+ * ExternalStringResource::data() may be cached, otherwise it is not
250
+ * expected to be stable beyond the current top-level task.
251
+ */
252
+ virtual bool IsCacheable() const { return true; }
253
+
254
+ /**
255
+ * Internally V8 will call this Unaccount method when the external string
256
+ * resource should be unaccounted for. This method can be overridden in
257
+ * subclasses to control how allocated external bytes are accounted.
258
+ */
259
+ virtual void Unaccount(Isolate* isolate) {}
260
+
261
+ /**
262
+ * Returns an estimate of the memory occupied by this external string, to be
263
+ * used by V8 when producing a heap snapshot. If this function returns
264
+ * kDefaultMemoryEstimate, then V8 will estimate the external size based on
265
+ * the string length. This function should return only memory that is
266
+ * uniquely owned by this resource. If the resource has shared ownership of
267
+ * a secondary allocation, it can report that memory by implementing
268
+ * EstimateSharedMemoryUsage.
269
+ */
270
+ virtual size_t EstimateMemoryUsage() const {
271
+ return kDefaultMemoryEstimate;
272
+ }
273
+ static constexpr size_t kDefaultMemoryEstimate = static_cast<size_t>(-1);
274
+
275
+ class V8_EXPORT SharedMemoryUsageRecorder {
276
+ public:
277
+ /**
278
+ * Record that a shared allocation at the given location has the given
279
+ * size.
280
+ */
281
+ virtual void RecordSharedMemoryUsage(const void* location,
282
+ size_t size) = 0;
283
+ };
284
+
285
+ /**
286
+ * Estimates memory that this string resource may share with other string
287
+ * resources, to be used by V8 when producing a heap snapshot.
288
+ */
289
+ virtual void EstimateSharedMemoryUsage(
290
+ SharedMemoryUsageRecorder* recorder) const {}
291
+
292
+ // Disallow copying and assigning.
293
+ ExternalStringResourceBase(const ExternalStringResourceBase&) = delete;
294
+ void operator=(const ExternalStringResourceBase&) = delete;
295
+
296
+ protected:
297
+ ExternalStringResourceBase() = default;
298
+
299
+ /**
300
+ * Internally V8 will call this Dispose method when the external string
301
+ * resource is no longer needed. The default implementation will use the
302
+ * delete operator. This method can be overridden in subclasses to
303
+ * control how allocated external string resources are disposed.
304
+ */
305
+ virtual void Dispose() { delete this; }
306
+
307
+ /**
308
+ * For a non-cacheable string, the value returned by
309
+ * |ExternalStringResource::data()| has to be stable between |Lock()| and
310
+ * |Unlock()|, that is the string must behave as is |IsCacheable()| returned
311
+ * true.
312
+ *
313
+ * These two functions must be thread-safe, and can be called from anywhere.
314
+ * They also must handle lock depth, in the sense that each can be called
315
+ * several times, from different threads, and unlocking should only happen
316
+ * when the balance of Lock() and Unlock() calls is 0.
317
+ */
318
+ virtual void Lock() const {}
319
+
320
+ /**
321
+ * Unlocks the string.
322
+ */
323
+ virtual void Unlock() const {}
324
+
325
+ private:
326
+ friend class internal::ExternalString;
327
+ friend class v8::String;
328
+ friend class internal::StringForwardingTable;
329
+ friend class internal::ScopedExternalStringLock;
330
+ };
331
+
332
+ /**
333
+ * An ExternalStringResource is a wrapper around a two-byte string
334
+ * buffer that resides outside V8's heap. Implement an
335
+ * ExternalStringResource to manage the life cycle of the underlying
336
+ * buffer. Note that the string data must be immutable.
337
+ */
338
+ class V8_EXPORT ExternalStringResource : public ExternalStringResourceBase {
339
+ public:
340
+ /**
341
+ * Override the destructor to manage the life cycle of the underlying
342
+ * buffer.
343
+ */
344
+ ~ExternalStringResource() override = default;
345
+
346
+ /**
347
+ * The string data from the underlying buffer. If the resource is cacheable
348
+ * then data() must return the same value for all invocations.
349
+ */
350
+ virtual const uint16_t* data() const = 0;
351
+
352
+ /**
353
+ * The length of the string. That is, the number of two-byte characters.
354
+ */
355
+ virtual size_t length() const = 0;
356
+
357
+ /**
358
+ * Returns the cached data from the underlying buffer. This method can be
359
+ * called only for cacheable resources (i.e. IsCacheable() == true) and only
360
+ * after UpdateDataCache() was called.
361
+ */
362
+ const uint16_t* cached_data() const {
363
+ CheckCachedDataInvariants();
364
+ return cached_data_;
365
+ }
366
+
367
+ /**
368
+ * Update {cached_data_} with the data from the underlying buffer. This can
369
+ * be called only for cacheable resources.
370
+ */
371
+ void UpdateDataCache();
372
+
373
+ protected:
374
+ ExternalStringResource() = default;
375
+
376
+ private:
377
+ void CheckCachedDataInvariants() const;
378
+
379
+ const uint16_t* cached_data_ = nullptr;
380
+ };
381
+
382
+ /**
383
+ * An ExternalOneByteStringResource is a wrapper around an one-byte
384
+ * string buffer that resides outside V8's heap. Implement an
385
+ * ExternalOneByteStringResource to manage the life cycle of the
386
+ * underlying buffer. Note that the string data must be immutable
387
+ * and that the data must be Latin-1 and not UTF-8, which would require
388
+ * special treatment internally in the engine and do not allow efficient
389
+ * indexing. Use String::New or convert to 16 bit data for non-Latin1.
390
+ */
391
+
392
+ class V8_EXPORT ExternalOneByteStringResource
393
+ : public ExternalStringResourceBase {
394
+ public:
395
+ /**
396
+ * Override the destructor to manage the life cycle of the underlying
397
+ * buffer.
398
+ */
399
+ ~ExternalOneByteStringResource() override = default;
400
+
401
+ /**
402
+ * The string data from the underlying buffer. If the resource is cacheable
403
+ * then data() must return the same value for all invocations.
404
+ */
405
+ virtual const char* data() const = 0;
406
+
407
+ /** The number of Latin-1 characters in the string.*/
408
+ virtual size_t length() const = 0;
409
+
410
+ /**
411
+ * Returns the cached data from the underlying buffer. If the resource is
412
+ * uncacheable or if UpdateDataCache() was not called before, it has
413
+ * undefined behaviour.
414
+ */
415
+ const char* cached_data() const {
416
+ CheckCachedDataInvariants();
417
+ return cached_data_;
418
+ }
419
+
420
+ /**
421
+ * Update {cached_data_} with the data from the underlying buffer. This can
422
+ * be called only for cacheable resources.
423
+ */
424
+ void UpdateDataCache();
425
+
426
+ protected:
427
+ ExternalOneByteStringResource() = default;
428
+
429
+ private:
430
+ void CheckCachedDataInvariants() const;
431
+
432
+ const char* cached_data_ = nullptr;
433
+ };
434
+
435
+ /**
436
+ * If the string is an external string, return the ExternalStringResourceBase
437
+ * regardless of the encoding, otherwise return NULL. The encoding of the
438
+ * string is returned in encoding_out.
439
+ */
440
+ V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
441
+ v8::Isolate* isolate, Encoding* encoding_out) const;
442
+ V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
443
+ Encoding* encoding_out) const;
444
+
445
+ /**
446
+ * Get the ExternalStringResource for an external string. Returns
447
+ * NULL if IsExternal() doesn't return true.
448
+ */
449
+ V8_INLINE ExternalStringResource* GetExternalStringResource() const;
450
+
451
+ /**
452
+ * Get the ExternalOneByteStringResource for an external one-byte string.
453
+ * Returns NULL if IsExternalOneByte() doesn't return true.
454
+ */
455
+ const ExternalOneByteStringResource* GetExternalOneByteStringResource() const;
456
+
457
+ V8_INLINE static String* Cast(v8::Data* data) {
458
+ #ifdef V8_ENABLE_CHECKS
459
+ CheckCast(data);
460
+ #endif
461
+ return static_cast<String*>(data);
462
+ }
463
+
464
+ /**
465
+ * Allocates a new string from a UTF-8 literal. This is equivalent to calling
466
+ * String::NewFromUtf(isolate, "...").ToLocalChecked(), but without the check
467
+ * overhead.
468
+ *
469
+ * When called on a string literal containing '\0', the inferred length is the
470
+ * length of the input array minus 1 (for the final '\0') and not the value
471
+ * returned by strlen.
472
+ **/
473
+ template <int N>
474
+ static V8_WARN_UNUSED_RESULT Local<String> NewFromUtf8Literal(
475
+ Isolate* isolate, const char (&literal)[N],
476
+ NewStringType type = NewStringType::kNormal) {
477
+ static_assert(N <= kMaxLength, "String is too long");
478
+ return NewFromUtf8Literal(isolate, literal, type, N - 1);
479
+ }
480
+
481
+ /** Allocates a new string from UTF-8 data. Only returns an empty value when
482
+ * length > kMaxLength. **/
483
+ static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8(
484
+ Isolate* isolate, const char* data,
485
+ NewStringType type = NewStringType::kNormal, int length = -1);
486
+
487
+ /** Allocates a new string from Latin-1 data. Only returns an empty value
488
+ * when length > kMaxLength. **/
489
+ static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte(
490
+ Isolate* isolate, const uint8_t* data,
491
+ NewStringType type = NewStringType::kNormal, int length = -1);
492
+
493
+ /** Allocates a new string from UTF-16 data. Only returns an empty value when
494
+ * length > kMaxLength. **/
495
+ static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte(
496
+ Isolate* isolate, const uint16_t* data,
497
+ NewStringType type = NewStringType::kNormal, int length = -1);
498
+
499
+ /**
500
+ * Creates a new string by concatenating the left and the right strings
501
+ * passed in as parameters.
502
+ */
503
+ static Local<String> Concat(Isolate* isolate, Local<String> left,
504
+ Local<String> right);
505
+
506
+ /**
507
+ * Creates a new external string using the data defined in the given
508
+ * resource. When the external string is no longer live on V8's heap the
509
+ * resource will be disposed by calling its Dispose method. The caller of
510
+ * this function should not otherwise delete or modify the resource. Neither
511
+ * should the underlying buffer be deallocated or modified except through the
512
+ * destructor of the external string resource.
513
+ */
514
+ static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte(
515
+ Isolate* isolate, ExternalStringResource* resource);
516
+
517
+ /**
518
+ * Associate an external string resource with this string by transforming it
519
+ * in place so that existing references to this string in the JavaScript heap
520
+ * will use the external string resource. The external string resource's
521
+ * character contents need to be equivalent to this string.
522
+ * Returns true if the string has been changed to be an external string.
523
+ * The string is not modified if the operation fails. See NewExternal for
524
+ * information on the lifetime of the resource.
525
+ */
526
+ V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
527
+ bool MakeExternal(ExternalStringResource* resource);
528
+
529
+ /**
530
+ * Associate an external string resource with this string by transforming it
531
+ * in place so that existing references to this string in the JavaScript heap
532
+ * will use the external string resource. The external string resource's
533
+ * character contents need to be equivalent to this string.
534
+ * Returns true if the string has been changed to be an external string.
535
+ * The string is not modified if the operation fails. See NewExternal for
536
+ * information on the lifetime of the resource.
537
+ */
538
+ bool MakeExternal(Isolate* isolate, ExternalStringResource* resource);
539
+
540
+ /**
541
+ * Creates a new external string using the one-byte data defined in the given
542
+ * resource. When the external string is no longer live on V8's heap the
543
+ * resource will be disposed by calling its Dispose method. The caller of
544
+ * this function should not otherwise delete or modify the resource. Neither
545
+ * should the underlying buffer be deallocated or modified except through the
546
+ * destructor of the external string resource.
547
+ */
548
+ static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte(
549
+ Isolate* isolate, ExternalOneByteStringResource* resource);
550
+
551
+ /**
552
+ * Associate an external string resource with this string by transforming it
553
+ * in place so that existing references to this string in the JavaScript heap
554
+ * will use the external string resource. The external string resource's
555
+ * character contents need to be equivalent to this string.
556
+ * Returns true if the string has been changed to be an external string.
557
+ * The string is not modified if the operation fails. See NewExternal for
558
+ * information on the lifetime of the resource.
559
+ */
560
+ V8_DEPRECATE_SOON("Use the version with the isolate argument instead.")
561
+ bool MakeExternal(ExternalOneByteStringResource* resource);
562
+
563
+ /**
564
+ * Associate an external string resource with this string by transforming it
565
+ * in place so that existing references to this string in the JavaScript heap
566
+ * will use the external string resource. The external string resource's
567
+ * character contents need to be equivalent to this string.
568
+ * Returns true if the string has been changed to be an external string.
569
+ * The string is not modified if the operation fails. See NewExternal for
570
+ * information on the lifetime of the resource.
571
+ */
572
+ bool MakeExternal(Isolate* isolate, ExternalOneByteStringResource* resource);
573
+
574
+ /**
575
+ * Returns true if this string can be made external, given the encoding for
576
+ * the external string resource.
577
+ */
578
+ bool CanMakeExternal(Encoding encoding) const;
579
+
580
+ /**
581
+ * Returns true if the strings values are equal. Same as JS ==/===.
582
+ */
583
+ bool StringEquals(Local<String> str) const;
584
+
585
+ /**
586
+ * Converts an object to a null-terminated UTF-8-encoded character array.
587
+ * Useful if you want to print the object. If conversion to a string fails
588
+ * (e.g. due to an exception in the toString() method of the object) then the
589
+ * length() method returns 0 and the * operator returns NULL.
590
+ *
591
+ * WARNING: This will unconditionally copy the contents of the JavaScript
592
+ * string, and should be avoided in situations where performance is a concern.
593
+ * Consider using WriteUtf8() instead.
594
+ */
595
+ class V8_EXPORT Utf8Value {
596
+ public:
597
+ Utf8Value(Isolate* isolate, Local<v8::Value> obj);
598
+ ~Utf8Value();
599
+ char* operator*() { return str_; }
600
+ const char* operator*() const { return str_; }
601
+ size_t length() const { return length_; }
602
+
603
+ // Disallow copying and assigning.
604
+ Utf8Value(const Utf8Value&) = delete;
605
+ void operator=(const Utf8Value&) = delete;
606
+
607
+ private:
608
+ char* str_;
609
+ size_t length_;
610
+ };
611
+
612
+ /**
613
+ * Converts an object to a two-byte (UTF-16-encoded) string.
614
+ *
615
+ * If conversion to a string fails (eg. due to an exception in the toString()
616
+ * method of the object) then the length() method returns 0 and the * operator
617
+ * returns NULL.
618
+ *
619
+ * WARNING: This will unconditionally copy the contents of the JavaScript
620
+ * string, and should be avoided in situations where performance is a concern.
621
+ */
622
+ class V8_EXPORT Value {
623
+ public:
624
+ V8_DEPRECATE_SOON(
625
+ "Prefer using String::ValueView if you can, or string->Write to a "
626
+ "buffer if you cannot.")
627
+ Value(Isolate* isolate, Local<v8::Value> obj);
628
+ ~Value();
629
+ uint16_t* operator*() { return str_; }
630
+ const uint16_t* operator*() const { return str_; }
631
+ uint32_t length() const { return length_; }
632
+
633
+ // Disallow copying and assigning.
634
+ Value(const Value&) = delete;
635
+ void operator=(const Value&) = delete;
636
+
637
+ private:
638
+ uint16_t* str_;
639
+ uint32_t length_;
640
+ };
641
+
642
+ /**
643
+ * Returns a view onto a string's contents.
644
+ *
645
+ * WARNING: This does not copy the string's contents, and will therefore be
646
+ * invalidated if the GC can move the string while the ValueView is alive. It
647
+ * is therefore required that no GC or allocation can happen while there is an
648
+ * active ValueView. This requirement may be relaxed in the future.
649
+ *
650
+ * V8 strings are either encoded as one-byte or two-bytes per character.
651
+ */
652
+ class V8_EXPORT ValueView {
653
+ public:
654
+ ValueView(Isolate* isolate, Local<v8::String> str);
655
+ ~ValueView();
656
+ const uint8_t* data8() const {
657
+ #if V8_ENABLE_CHECKS
658
+ CheckOneByte(true);
659
+ #endif
660
+ return data8_;
661
+ }
662
+ const uint16_t* data16() const {
663
+ #if V8_ENABLE_CHECKS
664
+ CheckOneByte(false);
665
+ #endif
666
+ return data16_;
667
+ }
668
+ uint32_t length() const { return length_; }
669
+ bool is_one_byte() const { return is_one_byte_; }
670
+
671
+ // Disallow copying and assigning.
672
+ ValueView(const ValueView&) = delete;
673
+ void operator=(const ValueView&) = delete;
674
+
675
+ private:
676
+ void CheckOneByte(bool is_one_byte) const;
677
+
678
+ Local<v8::String> flat_str_;
679
+ union {
680
+ const uint8_t* data8_;
681
+ const uint16_t* data16_;
682
+ };
683
+ uint32_t length_;
684
+ bool is_one_byte_;
685
+ // Avoid exposing the internal DisallowGarbageCollection scope.
686
+ alignas(internal::Internals::
687
+ kDisallowGarbageCollectionAlign) char no_gc_debug_scope_
688
+ [internal::Internals::kDisallowGarbageCollectionSize];
689
+ };
690
+
691
+ private:
692
+ void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
693
+ Encoding encoding) const;
694
+ void VerifyExternalStringResource(ExternalStringResource* val) const;
695
+ ExternalStringResource* GetExternalStringResourceSlow() const;
696
+ ExternalStringResourceBase* GetExternalStringResourceBaseSlow(
697
+ String::Encoding* encoding_out) const;
698
+
699
+ static Local<v8::String> NewFromUtf8Literal(Isolate* isolate,
700
+ const char* literal,
701
+ NewStringType type, int length);
702
+
703
+ static void CheckCast(v8::Data* that);
704
+ };
705
+
706
+ // Zero-length string specialization (templated string size includes
707
+ // terminator).
708
+ template <>
709
+ inline V8_WARN_UNUSED_RESULT Local<String> String::NewFromUtf8Literal(
710
+ Isolate* isolate, const char (&literal)[1], NewStringType type) {
711
+ return String::Empty(isolate);
712
+ }
713
+
714
+ /**
715
+ * Interface for iterating through all external resources in the heap.
716
+ */
717
+ class V8_EXPORT ExternalResourceVisitor {
718
+ public:
719
+ virtual ~ExternalResourceVisitor() = default;
720
+ virtual void VisitExternalString(Local<String> string) {}
721
+ };
722
+
723
+ /**
724
+ * A JavaScript symbol (ECMA-262 edition 6)
725
+ */
726
+ class V8_EXPORT Symbol : public Name {
727
+ public:
728
+ /**
729
+ * Returns the description string of the symbol, or undefined if none.
730
+ */
731
+ Local<Value> Description(Isolate* isolate) const;
732
+
733
+ /**
734
+ * Create a symbol. If description is not empty, it will be used as the
735
+ * description.
736
+ */
737
+ static Local<Symbol> New(Isolate* isolate,
738
+ Local<String> description = Local<String>());
739
+
740
+ /**
741
+ * Access global symbol registry.
742
+ * Note that symbols created this way are never collected, so
743
+ * they should only be used for statically fixed properties.
744
+ * Also, there is only one global name space for the descriptions used as
745
+ * keys.
746
+ * To minimize the potential for clashes, use qualified names as keys.
747
+ */
748
+ static Local<Symbol> For(Isolate* isolate, Local<String> description);
749
+
750
+ /**
751
+ * Retrieve a global symbol. Similar to |For|, but using a separate
752
+ * registry that is not accessible by (and cannot clash with) JavaScript code.
753
+ */
754
+ static Local<Symbol> ForApi(Isolate* isolate, Local<String> description);
755
+
756
+ // Well-known symbols
757
+ static Local<Symbol> GetAsyncIterator(Isolate* isolate);
758
+ static Local<Symbol> GetHasInstance(Isolate* isolate);
759
+ static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
760
+ static Local<Symbol> GetIterator(Isolate* isolate);
761
+ static Local<Symbol> GetMatch(Isolate* isolate);
762
+ static Local<Symbol> GetReplace(Isolate* isolate);
763
+ static Local<Symbol> GetSearch(Isolate* isolate);
764
+ static Local<Symbol> GetSplit(Isolate* isolate);
765
+ static Local<Symbol> GetToPrimitive(Isolate* isolate);
766
+ static Local<Symbol> GetToStringTag(Isolate* isolate);
767
+ static Local<Symbol> GetUnscopables(Isolate* isolate);
768
+ static Local<Symbol> GetDispose(Isolate* isolate);
769
+ static Local<Symbol> GetAsyncDispose(Isolate* isolate);
770
+
771
+ V8_INLINE static Symbol* Cast(Data* data) {
772
+ #ifdef V8_ENABLE_CHECKS
773
+ CheckCast(data);
774
+ #endif
775
+ return static_cast<Symbol*>(data);
776
+ }
777
+
778
+ private:
779
+ Symbol();
780
+ static void CheckCast(Data* that);
781
+ };
782
+
783
+ /**
784
+ * A JavaScript numeric value (either Number or BigInt).
785
+ * https://tc39.es/ecma262/#sec-numeric-types
786
+ */
787
+ class V8_EXPORT Numeric : public Primitive {
788
+ private:
789
+ Numeric();
790
+ static void CheckCast(v8::Data* that);
791
+ };
792
+
793
+ /**
794
+ * A JavaScript number value (ECMA-262, 4.3.20)
795
+ */
796
+ class V8_EXPORT Number : public Numeric {
797
+ public:
798
+ double Value() const;
799
+ static Local<Number> New(Isolate* isolate, double value);
800
+ template <typename Int>
801
+ requires(std::is_integral<Int>::value && !std::is_same<Int, bool>::value &&
802
+ std::is_signed_v<Int> && sizeof(Int) <= sizeof(int32_t))
803
+ V8_INLINE static Local<Number> New(Isolate* isolate, Int value) {
804
+ return NewFromInt32(isolate, value);
805
+ }
806
+ template <typename UInt>
807
+ requires(std::is_integral<UInt>::value &&
808
+ !std::is_same<UInt, bool>::value && std::is_unsigned_v<UInt> &&
809
+ sizeof(UInt) <= sizeof(uint32_t))
810
+ V8_INLINE static Local<Number> New(Isolate* isolate, UInt value) {
811
+ return NewFromUint32(isolate, value);
812
+ }
813
+ V8_INLINE static Number* Cast(v8::Data* data) {
814
+ #ifdef V8_ENABLE_CHECKS
815
+ CheckCast(data);
816
+ #endif
817
+ return static_cast<Number*>(data);
818
+ }
819
+
820
+ private:
821
+ Number();
822
+ static Local<Number> NewFromInt32(Isolate* isolate, int32_t value);
823
+ static Local<Number> NewFromUint32(Isolate* isolate, uint32_t value);
824
+ static void CheckCast(v8::Data* that);
825
+ };
826
+
827
+ /**
828
+ * A JavaScript value representing a signed integer.
829
+ */
830
+ class V8_EXPORT Integer : public Number {
831
+ public:
832
+ static Local<Integer> New(Isolate* isolate, int32_t value);
833
+ static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
834
+ int64_t Value() const;
835
+ V8_INLINE static Integer* Cast(v8::Data* data) {
836
+ #ifdef V8_ENABLE_CHECKS
837
+ CheckCast(data);
838
+ #endif
839
+ return static_cast<Integer*>(data);
840
+ }
841
+
842
+ private:
843
+ Integer();
844
+ static void CheckCast(v8::Data* that);
845
+ };
846
+
847
+ /**
848
+ * A JavaScript value representing a 32-bit signed integer.
849
+ */
850
+ class V8_EXPORT Int32 : public Integer {
851
+ public:
852
+ int32_t Value() const;
853
+ V8_INLINE static Int32* Cast(v8::Data* data) {
854
+ #ifdef V8_ENABLE_CHECKS
855
+ CheckCast(data);
856
+ #endif
857
+ return static_cast<Int32*>(data);
858
+ }
859
+
860
+ private:
861
+ Int32();
862
+ static void CheckCast(v8::Data* that);
863
+ };
864
+
865
+ /**
866
+ * A JavaScript value representing a 32-bit unsigned integer.
867
+ */
868
+ class V8_EXPORT Uint32 : public Integer {
869
+ public:
870
+ uint32_t Value() const;
871
+ V8_INLINE static Uint32* Cast(v8::Data* data) {
872
+ #ifdef V8_ENABLE_CHECKS
873
+ CheckCast(data);
874
+ #endif
875
+ return static_cast<Uint32*>(data);
876
+ }
877
+
878
+ private:
879
+ Uint32();
880
+ static void CheckCast(v8::Data* that);
881
+ };
882
+
883
+ /**
884
+ * A JavaScript BigInt value (https://tc39.github.io/proposal-bigint)
885
+ */
886
+ class V8_EXPORT BigInt : public Numeric {
887
+ public:
888
+ static Local<BigInt> New(Isolate* isolate, int64_t value);
889
+ static Local<BigInt> NewFromUnsigned(Isolate* isolate, uint64_t value);
890
+ /**
891
+ * Creates a new BigInt object using a specified sign bit and a
892
+ * specified list of digits/words.
893
+ * The resulting number is calculated as:
894
+ *
895
+ * (-1)^sign_bit * (words[0] * (2^64)^0 + words[1] * (2^64)^1 + ...)
896
+ */
897
+ static MaybeLocal<BigInt> NewFromWords(Local<Context> context, int sign_bit,
898
+ int word_count, const uint64_t* words);
899
+
900
+ /**
901
+ * Returns the value of this BigInt as an unsigned 64-bit integer.
902
+ * If `lossless` is provided, it will reflect whether the return value was
903
+ * truncated or wrapped around. In particular, it is set to `false` if this
904
+ * BigInt is negative.
905
+ */
906
+ uint64_t Uint64Value(bool* lossless = nullptr) const;
907
+
908
+ /**
909
+ * Returns the value of this BigInt as a signed 64-bit integer.
910
+ * If `lossless` is provided, it will reflect whether this BigInt was
911
+ * truncated or not.
912
+ */
913
+ int64_t Int64Value(bool* lossless = nullptr) const;
914
+
915
+ /**
916
+ * Returns the number of 64-bit words needed to store the result of
917
+ * ToWordsArray().
918
+ */
919
+ int WordCount() const;
920
+
921
+ /**
922
+ * Writes the contents of this BigInt to a specified memory location.
923
+ * `sign_bit` must be provided and will be set to 1 if this BigInt is
924
+ * negative.
925
+ * `*word_count` has to be initialized to the length of the `words` array.
926
+ * Upon return, it will be set to the actual number of words that would
927
+ * be needed to store this BigInt (i.e. the return value of `WordCount()`).
928
+ */
929
+ void ToWordsArray(int* sign_bit, int* word_count, uint64_t* words) const;
930
+
931
+ V8_INLINE static BigInt* Cast(v8::Data* data) {
932
+ #ifdef V8_ENABLE_CHECKS
933
+ CheckCast(data);
934
+ #endif
935
+ return static_cast<BigInt*>(data);
936
+ }
937
+
938
+ private:
939
+ BigInt();
940
+ static void CheckCast(v8::Data* that);
941
+ };
942
+
943
+ Local<String> String::Empty(Isolate* isolate) {
944
+ using S = internal::Address;
945
+ using I = internal::Internals;
946
+ I::CheckInitialized(isolate);
947
+ S* slot = I::GetRootSlot(isolate, I::kEmptyStringRootIndex);
948
+ return Local<String>::FromSlot(slot);
949
+ }
950
+
951
+ String::ExternalStringResource* String::GetExternalStringResource() const {
952
+ using A = internal::Address;
953
+ using I = internal::Internals;
954
+ A obj = internal::ValueHelper::ValueAsAddress(this);
955
+
956
+ ExternalStringResource* result;
957
+ if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
958
+ Isolate* isolate = I::GetCurrentIsolateForSandbox();
959
+ A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
960
+ isolate, obj, I::kStringResourceOffset);
961
+ result = reinterpret_cast<String::ExternalStringResource*>(value);
962
+ } else {
963
+ result = GetExternalStringResourceSlow();
964
+ }
965
+ #ifdef V8_ENABLE_CHECKS
966
+ VerifyExternalStringResource(result);
967
+ #endif
968
+ return result;
969
+ }
970
+
971
+ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
972
+ v8::Isolate* isolate, String::Encoding* encoding_out) const {
973
+ using A = internal::Address;
974
+ using I = internal::Internals;
975
+ A obj = internal::ValueHelper::ValueAsAddress(this);
976
+ int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
977
+ *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
978
+ ExternalStringResourceBase* resource;
979
+ if (type == I::kExternalOneByteRepresentationTag ||
980
+ type == I::kExternalTwoByteRepresentationTag) {
981
+ A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
982
+ isolate, obj, I::kStringResourceOffset);
983
+ resource = reinterpret_cast<ExternalStringResourceBase*>(value);
984
+ } else {
985
+ resource = GetExternalStringResourceBaseSlow(encoding_out);
986
+ }
987
+ #ifdef V8_ENABLE_CHECKS
988
+ VerifyExternalStringResourceBase(resource, *encoding_out);
989
+ #endif
990
+ return resource;
991
+ }
992
+
993
+ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
994
+ String::Encoding* encoding_out) const {
995
+ using A = internal::Address;
996
+ using I = internal::Internals;
997
+ A obj = internal::ValueHelper::ValueAsAddress(this);
998
+ int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
999
+ *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
1000
+ ExternalStringResourceBase* resource;
1001
+ if (type == I::kExternalOneByteRepresentationTag ||
1002
+ type == I::kExternalTwoByteRepresentationTag) {
1003
+ Isolate* isolate = I::GetCurrentIsolateForSandbox();
1004
+ A value = I::ReadExternalPointerField<internal::kExternalStringResourceTag>(
1005
+ isolate, obj, I::kStringResourceOffset);
1006
+ resource = reinterpret_cast<ExternalStringResourceBase*>(value);
1007
+ } else {
1008
+ resource = GetExternalStringResourceBaseSlow(encoding_out);
1009
+ }
1010
+ #ifdef V8_ENABLE_CHECKS
1011
+ VerifyExternalStringResourceBase(resource, *encoding_out);
1012
+ #endif
1013
+ return resource;
1014
+ }
1015
+
1016
+ // --- Statics ---
1017
+
1018
+ V8_INLINE Local<Primitive> Undefined(Isolate* isolate) {
1019
+ using S = internal::Address;
1020
+ using I = internal::Internals;
1021
+ I::CheckInitialized(isolate);
1022
+ S* slot = I::GetRootSlot(isolate, I::kUndefinedValueRootIndex);
1023
+ return Local<Primitive>::FromSlot(slot);
1024
+ }
1025
+
1026
+ V8_INLINE Local<Primitive> Null(Isolate* isolate) {
1027
+ using S = internal::Address;
1028
+ using I = internal::Internals;
1029
+ I::CheckInitialized(isolate);
1030
+ S* slot = I::GetRootSlot(isolate, I::kNullValueRootIndex);
1031
+ return Local<Primitive>::FromSlot(slot);
1032
+ }
1033
+
1034
+ V8_INLINE Local<Boolean> True(Isolate* isolate) {
1035
+ using S = internal::Address;
1036
+ using I = internal::Internals;
1037
+ I::CheckInitialized(isolate);
1038
+ S* slot = I::GetRootSlot(isolate, I::kTrueValueRootIndex);
1039
+ return Local<Boolean>::FromSlot(slot);
1040
+ }
1041
+
1042
+ V8_INLINE Local<Boolean> False(Isolate* isolate) {
1043
+ using S = internal::Address;
1044
+ using I = internal::Internals;
1045
+ I::CheckInitialized(isolate);
1046
+ S* slot = I::GetRootSlot(isolate, I::kFalseValueRootIndex);
1047
+ return Local<Boolean>::FromSlot(slot);
1048
+ }
1049
+
1050
+ Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
1051
+ return value ? True(isolate) : False(isolate);
1052
+ }
1053
+
1054
+ } // namespace v8
1055
+
1056
+ #endif // INCLUDE_V8_PRIMITIVE_H_