@triniwiz/nativescript-masonkit 1.0.0-alpha.4 → 1.0.0-alpha.6

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 (345) hide show
  1. package/common.d.ts +7 -9
  2. package/common.js +277 -552
  3. package/common.js.map +1 -1
  4. package/helpers.d.ts +32 -10
  5. package/helpers.js +772 -286
  6. package/helpers.js.map +1 -1
  7. package/index.android.d.ts +6 -2
  8. package/index.android.js +21 -3
  9. package/index.android.js.map +1 -1
  10. package/index.d.ts +64 -7
  11. package/index.ios.d.ts +9 -6
  12. package/index.ios.js +39 -25
  13. package/index.ios.js.map +1 -1
  14. package/package.json +1 -1
  15. package/platforms/android/include.gradle +18 -1
  16. package/platforms/android/masonkit-release.aar +0 -0
  17. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/Mason-Swift.h +108 -64
  18. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Headers/mason_native.h +47 -20
  19. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Info.plist +0 -0
  20. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Mason +0 -0
  21. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  22. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.abi.json +6692 -794
  23. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.private.swiftinterface +58 -21
  24. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  25. package/platforms/ios/Mason.xcframework/ios-arm64/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios.swiftinterface +58 -21
  26. package/platforms/ios/Mason.xcframework/ios-arm64/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  27. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/Mason-Swift.h +216 -128
  28. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Headers/mason_native.h +47 -20
  29. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Info.plist +0 -0
  30. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Mason +0 -0
  31. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  32. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  33. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.abi.json +6692 -794
  34. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +58 -21
  35. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  36. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/arm64-apple-ios-simulator.swiftinterface +58 -21
  37. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.abi.json +6692 -794
  38. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +58 -21
  39. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  40. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/Modules/Mason.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +58 -21
  41. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/_CodeSignature/CodeResources +43 -43
  42. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/dSYMs/Mason.framework.dSYM/Contents/Resources/DWARF/Mason +0 -0
  43. package/platforms/ios/build.xcconfig +1 -2
  44. package/platforms/ios/src/MasonV8Module.h +583 -0
  45. package/platforms/ios/src/MasonV8Module.mm +1005 -0
  46. package/platforms/ios/src/{include → cpp/include}/mason_native.h +47 -20
  47. package/platforms/ios/src/cpp/include/robin_hood.h +2544 -0
  48. package/platforms/ios/src/module.modulemap +2 -2
  49. package/platforms/new_native_src/cpp/Caches.cpp +36 -0
  50. package/platforms/new_native_src/cpp/Caches.h +42 -0
  51. package/platforms/new_native_src/cpp/Common.h +34 -0
  52. package/platforms/new_native_src/cpp/ConcurrentMap.h +57 -0
  53. package/platforms/new_native_src/cpp/Helpers.cpp +101 -0
  54. package/platforms/new_native_src/cpp/Helpers.h +364 -0
  55. package/platforms/new_native_src/cpp/MasonImpl.cpp +68 -0
  56. package/platforms/new_native_src/cpp/MasonImpl.h +40 -0
  57. package/platforms/new_native_src/cpp/MasonNodeImpl.cpp +89 -0
  58. package/platforms/new_native_src/cpp/MasonNodeImpl.h +47 -0
  59. package/platforms/new_native_src/cpp/MasonStyleImpl.cpp +2181 -0
  60. package/platforms/new_native_src/cpp/MasonStyleImpl.h +420 -0
  61. package/platforms/{ios/Mason.xcframework/ios-arm64/Mason.framework/PrivateHeaders → new_native_src/cpp/include}/mason_native.h +464 -168
  62. package/platforms/new_native_src/cpp/include/robin_hood.h +2544 -0
  63. package/pods/Headers/include/APIDesign.md +72 -0
  64. package/pods/Headers/include/DEPS +10 -0
  65. package/pods/Headers/include/DIR_METADATA +11 -0
  66. package/pods/Headers/include/OWNERS +23 -0
  67. package/pods/Headers/include/cppgc/DEPS +8 -0
  68. package/pods/Headers/include/cppgc/OWNERS +2 -0
  69. package/pods/Headers/include/cppgc/README.md +133 -0
  70. package/pods/Headers/include/cppgc/allocation.h +310 -0
  71. package/pods/Headers/include/cppgc/common.h +29 -0
  72. package/pods/Headers/include/cppgc/cross-thread-persistent.h +465 -0
  73. package/pods/Headers/include/cppgc/custom-space.h +97 -0
  74. package/pods/Headers/include/cppgc/default-platform.h +67 -0
  75. package/pods/Headers/include/cppgc/ephemeron-pair.h +30 -0
  76. package/pods/Headers/include/cppgc/explicit-management.h +100 -0
  77. package/pods/Headers/include/cppgc/garbage-collected.h +106 -0
  78. package/pods/Headers/include/cppgc/heap-consistency.h +266 -0
  79. package/pods/Headers/include/cppgc/heap-state.h +82 -0
  80. package/pods/Headers/include/cppgc/heap-statistics.h +120 -0
  81. package/pods/Headers/include/cppgc/heap.h +206 -0
  82. package/pods/Headers/include/cppgc/internal/api-constants.h +55 -0
  83. package/pods/Headers/include/cppgc/internal/atomic-entry-flag.h +48 -0
  84. package/pods/Headers/include/cppgc/internal/caged-heap-local-data.h +79 -0
  85. package/pods/Headers/include/cppgc/internal/compiler-specific.h +38 -0
  86. package/pods/Headers/include/cppgc/internal/finalizer-trait.h +93 -0
  87. package/pods/Headers/include/cppgc/internal/gc-info.h +156 -0
  88. package/pods/Headers/include/cppgc/internal/logging.h +50 -0
  89. package/pods/Headers/include/cppgc/internal/name-trait.h +122 -0
  90. package/pods/Headers/include/cppgc/internal/persistent-node.h +216 -0
  91. package/pods/Headers/include/cppgc/internal/pointer-policies.h +186 -0
  92. package/pods/Headers/include/cppgc/internal/write-barrier.h +435 -0
  93. package/pods/Headers/include/cppgc/liveness-broker.h +77 -0
  94. package/pods/Headers/include/cppgc/macros.h +26 -0
  95. package/pods/Headers/include/cppgc/member.h +291 -0
  96. package/pods/Headers/include/cppgc/name-provider.h +65 -0
  97. package/pods/Headers/include/cppgc/object-size-trait.h +58 -0
  98. package/pods/Headers/include/cppgc/persistent.h +370 -0
  99. package/pods/Headers/include/cppgc/platform.h +156 -0
  100. package/pods/Headers/include/cppgc/prefinalizer.h +75 -0
  101. package/pods/Headers/include/cppgc/process-heap-statistics.h +36 -0
  102. package/pods/Headers/include/cppgc/sentinel-pointer.h +32 -0
  103. package/pods/Headers/include/cppgc/source-location.h +92 -0
  104. package/pods/Headers/include/cppgc/testing.h +106 -0
  105. package/pods/Headers/include/cppgc/trace-trait.h +116 -0
  106. package/pods/Headers/include/cppgc/type-traits.h +240 -0
  107. package/pods/Headers/include/cppgc/visitor.h +379 -0
  108. package/pods/Headers/include/js_protocol-1.2.json +936 -0
  109. package/pods/Headers/include/js_protocol-1.3.json +1112 -0
  110. package/pods/Headers/include/js_protocol.pdl +1709 -0
  111. package/pods/Headers/include/libffi/arm64/ffi.h +524 -0
  112. package/pods/Headers/include/libffi/arm64/ffitarget.h +92 -0
  113. package/pods/Headers/include/libffi/x86_64/ffi.h +524 -0
  114. package/pods/Headers/include/libffi/x86_64/ffitarget.h +147 -0
  115. package/pods/Headers/include/libffi.h +12 -0
  116. package/pods/Headers/include/libplatform/DEPS +9 -0
  117. package/pods/Headers/include/libplatform/libplatform-export.h +29 -0
  118. package/pods/Headers/include/libplatform/libplatform.h +106 -0
  119. package/pods/Headers/include/libplatform/v8-tracing.h +333 -0
  120. package/pods/Headers/include/v8-array-buffer.h +433 -0
  121. package/pods/Headers/include/v8-callbacks.h +397 -0
  122. package/pods/Headers/include/v8-container.h +129 -0
  123. package/pods/Headers/include/v8-context.h +407 -0
  124. package/pods/Headers/include/v8-cppgc.h +215 -0
  125. package/pods/Headers/include/v8-data.h +80 -0
  126. package/pods/Headers/include/v8-date.h +43 -0
  127. package/pods/Headers/include/v8-debug.h +168 -0
  128. package/pods/Headers/include/v8-embedder-heap.h +218 -0
  129. package/pods/Headers/include/v8-embedder-state-scope.h +51 -0
  130. package/pods/Headers/include/v8-exception.h +217 -0
  131. package/pods/Headers/include/v8-extension.h +62 -0
  132. package/pods/Headers/include/v8-external.h +37 -0
  133. package/pods/Headers/include/v8-fast-api-calls.h +939 -0
  134. package/pods/Headers/include/v8-forward.h +81 -0
  135. package/pods/Headers/include/v8-function-callback.h +475 -0
  136. package/pods/Headers/include/v8-function.h +125 -0
  137. package/pods/Headers/include/v8-initialization.h +315 -0
  138. package/pods/Headers/include/v8-inspector-protocol.h +13 -0
  139. package/pods/Headers/include/v8-inspector.h +376 -0
  140. package/pods/Headers/include/v8-internal.h +661 -0
  141. package/pods/Headers/include/v8-isolate.h +1709 -0
  142. package/pods/Headers/include/v8-json.h +47 -0
  143. package/pods/Headers/include/v8-local-handle.h +455 -0
  144. package/pods/Headers/include/v8-locker.h +149 -0
  145. package/pods/Headers/include/v8-maybe.h +137 -0
  146. package/pods/Headers/include/v8-memory-span.h +43 -0
  147. package/pods/Headers/include/v8-message.h +216 -0
  148. package/pods/Headers/include/v8-metrics.h +255 -0
  149. package/pods/Headers/include/v8-microtask-queue.h +152 -0
  150. package/pods/Headers/include/v8-microtask.h +28 -0
  151. package/pods/Headers/include/v8-object.h +775 -0
  152. package/pods/Headers/include/v8-persistent-handle.h +590 -0
  153. package/pods/Headers/include/v8-platform.h +1092 -0
  154. package/pods/Headers/include/v8-primitive-object.h +118 -0
  155. package/pods/Headers/include/v8-primitive.h +866 -0
  156. package/pods/Headers/include/v8-profiler.h +1198 -0
  157. package/pods/Headers/include/v8-promise.h +174 -0
  158. package/pods/Headers/include/v8-proxy.h +50 -0
  159. package/pods/Headers/include/v8-regexp.h +105 -0
  160. package/pods/Headers/include/v8-script.h +748 -0
  161. package/pods/Headers/include/v8-snapshot.h +196 -0
  162. package/pods/Headers/include/v8-statistics.h +217 -0
  163. package/pods/Headers/include/v8-template.h +1079 -0
  164. package/pods/Headers/include/v8-traced-handle.h +420 -0
  165. package/pods/Headers/include/v8-typed-array.h +282 -0
  166. package/pods/Headers/include/v8-unwinder-state.h +31 -0
  167. package/pods/Headers/include/v8-unwinder.h +132 -0
  168. package/pods/Headers/include/v8-util.h +658 -0
  169. package/pods/Headers/include/v8-value-serializer-version.h +24 -0
  170. package/pods/Headers/include/v8-value-serializer.h +279 -0
  171. package/pods/Headers/include/v8-value.h +526 -0
  172. package/pods/Headers/include/v8-version-string.h +38 -0
  173. package/pods/Headers/include/v8-version.h +20 -0
  174. package/pods/Headers/include/v8-wasm-trap-handler-posix.h +31 -0
  175. package/pods/Headers/include/v8-wasm-trap-handler-win.h +28 -0
  176. package/pods/Headers/include/v8-wasm.h +257 -0
  177. package/pods/Headers/include/v8-weak-callback-info.h +86 -0
  178. package/pods/Headers/include/v8.h +88 -0
  179. package/pods/Headers/include/v8config.h +605 -0
  180. package/pods/Headers/inspector/InspectorServer.h +20 -0
  181. package/pods/Headers/inspector/JsV8InspectorClient.h +66 -0
  182. package/pods/Headers/inspector/base/trace_event/common/trace_event_common.h +1123 -0
  183. package/pods/Headers/inspector/base64.h +9 -0
  184. package/pods/Headers/inspector/src/base/address-region.h +95 -0
  185. package/pods/Headers/inspector/src/base/atomic-utils.h +219 -0
  186. package/pods/Headers/inspector/src/base/atomicops.h +332 -0
  187. package/pods/Headers/inspector/src/base/atomicops_internals_atomicword_compat.h +89 -0
  188. package/pods/Headers/inspector/src/base/base-export.h +31 -0
  189. package/pods/Headers/inspector/src/base/bits.h +343 -0
  190. package/pods/Headers/inspector/src/base/build_config.h +234 -0
  191. package/pods/Headers/inspector/src/base/compiler-specific.h +136 -0
  192. package/pods/Headers/inspector/src/base/export-template.h +163 -0
  193. package/pods/Headers/inspector/src/base/flags.h +130 -0
  194. package/pods/Headers/inspector/src/base/immediate-crash.h +162 -0
  195. package/pods/Headers/inspector/src/base/lazy-instance.h +258 -0
  196. package/pods/Headers/inspector/src/base/logging.h +417 -0
  197. package/pods/Headers/inspector/src/base/macros.h +423 -0
  198. package/pods/Headers/inspector/src/base/memory.h +89 -0
  199. package/pods/Headers/inspector/src/base/once.h +108 -0
  200. package/pods/Headers/inspector/src/base/optional.h +882 -0
  201. package/pods/Headers/inspector/src/base/platform/mutex.h +370 -0
  202. package/pods/Headers/inspector/src/base/platform/platform.h +476 -0
  203. package/pods/Headers/inspector/src/base/platform/semaphore.h +108 -0
  204. package/pods/Headers/inspector/src/base/platform/v8-time.h +513 -0
  205. package/pods/Headers/inspector/src/base/platform/wrappers.h +73 -0
  206. package/pods/Headers/inspector/src/base/safe_conversions.h +389 -0
  207. package/pods/Headers/inspector/src/base/safe_conversions_impl.h +822 -0
  208. package/pods/Headers/inspector/src/base/template-utils.h +113 -0
  209. package/pods/Headers/inspector/src/base/v8-fallthrough.h +21 -0
  210. package/pods/Headers/inspector/src/common/checks.h +38 -0
  211. package/pods/Headers/inspector/src/common/globals.h +1842 -0
  212. package/pods/Headers/inspector/src/debug/debug-interface.h +667 -0
  213. package/pods/Headers/inspector/src/debug/interface-types.h +175 -0
  214. package/pods/Headers/inspector/src/init/v8.h +52 -0
  215. package/pods/Headers/inspector/src/inspector/custom-preview.h +24 -0
  216. package/pods/Headers/inspector/src/inspector/injected-script.h +251 -0
  217. package/pods/Headers/inspector/src/inspector/inspected-context.h +79 -0
  218. package/pods/Headers/inspector/src/inspector/protocol/CSS.h +2148 -0
  219. package/pods/Headers/inspector/src/inspector/protocol/Console.h +211 -0
  220. package/pods/Headers/inspector/src/inspector/protocol/DOM.h +1008 -0
  221. package/pods/Headers/inspector/src/inspector/protocol/Debugger.h +892 -0
  222. package/pods/Headers/inspector/src/inspector/protocol/Forward.h +75 -0
  223. package/pods/Headers/inspector/src/inspector/protocol/HeapProfiler.h +346 -0
  224. package/pods/Headers/inspector/src/inspector/protocol/Log.h +342 -0
  225. package/pods/Headers/inspector/src/inspector/protocol/Network.h +2528 -0
  226. package/pods/Headers/inspector/src/inspector/protocol/Overlay.h +281 -0
  227. package/pods/Headers/inspector/src/inspector/protocol/Page.h +1189 -0
  228. package/pods/Headers/inspector/src/inspector/protocol/Profiler.h +1001 -0
  229. package/pods/Headers/inspector/src/inspector/protocol/Protocol.h +617 -0
  230. package/pods/Headers/inspector/src/inspector/protocol/Runtime.h +1696 -0
  231. package/pods/Headers/inspector/src/inspector/protocol/Schema.h +146 -0
  232. package/pods/Headers/inspector/src/inspector/protocol/Security.h +793 -0
  233. package/pods/Headers/inspector/src/inspector/remote-object-id.h +54 -0
  234. package/pods/Headers/inspector/src/inspector/search-util.h +26 -0
  235. package/pods/Headers/inspector/src/inspector/string-16.h +180 -0
  236. package/pods/Headers/inspector/src/inspector/string-util.h +128 -0
  237. package/pods/Headers/inspector/src/inspector/v8-console-agent-impl.h +48 -0
  238. package/pods/Headers/inspector/src/inspector/v8-console-message.h +147 -0
  239. package/pods/Headers/inspector/src/inspector/v8-console.h +173 -0
  240. package/pods/Headers/inspector/src/inspector/v8-css-agent-impl.h +62 -0
  241. package/pods/Headers/inspector/src/inspector/v8-debugger-agent-impl.h +248 -0
  242. package/pods/Headers/inspector/src/inspector/v8-debugger-id.h +44 -0
  243. package/pods/Headers/inspector/src/inspector/v8-debugger-script.h +123 -0
  244. package/pods/Headers/inspector/src/inspector/v8-debugger.h +257 -0
  245. package/pods/Headers/inspector/src/inspector/v8-dom-agent-impl.h +91 -0
  246. package/pods/Headers/inspector/src/inspector/v8-heap-profiler-agent-impl.h +80 -0
  247. package/pods/Headers/inspector/src/inspector/v8-inspector-impl.h +191 -0
  248. package/pods/Headers/inspector/src/inspector/v8-inspector-session-impl.h +156 -0
  249. package/pods/Headers/inspector/src/inspector/v8-log-agent-impl.h +34 -0
  250. package/pods/Headers/inspector/src/inspector/v8-network-agent-impl.h +71 -0
  251. package/pods/Headers/inspector/src/inspector/v8-ns-debugger-agent-impl.h +24 -0
  252. package/pods/Headers/inspector/src/inspector/v8-overlay-agent-impl.h +70 -0
  253. package/pods/Headers/inspector/src/inspector/v8-page-agent-impl.h +88 -0
  254. package/pods/Headers/inspector/src/inspector/v8-profiler-agent-impl.h +104 -0
  255. package/pods/Headers/inspector/src/inspector/v8-regex.h +38 -0
  256. package/pods/Headers/inspector/src/inspector/v8-runtime-agent-impl.h +157 -0
  257. package/pods/Headers/inspector/src/inspector/v8-schema-agent-impl.h +38 -0
  258. package/pods/Headers/inspector/src/inspector/v8-stack-trace-impl.h +164 -0
  259. package/pods/Headers/inspector/src/inspector/v8-string-conversions.h +17 -0
  260. package/pods/Headers/inspector/src/inspector/v8-value-utils.h +23 -0
  261. package/pods/Headers/inspector/src/inspector/value-mirror.h +87 -0
  262. package/pods/Headers/inspector/src/libplatform/default-platform.h +92 -0
  263. package/pods/Headers/inspector/src/logging/tracing-flags.h +50 -0
  264. package/pods/Headers/inspector/src/numbers/conversions.h +183 -0
  265. package/pods/Headers/inspector/src/tracing/trace-event.h +664 -0
  266. package/pods/Headers/inspector/src/utils/allocation.h +367 -0
  267. package/pods/Headers/inspector/src/utils/vector.h +324 -0
  268. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/cbor.h +305 -0
  269. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/dispatch.h +314 -0
  270. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/error_support.h +62 -0
  271. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/export.h +6 -0
  272. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/find_by_first.h +58 -0
  273. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/frontend_channel.h +47 -0
  274. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/glue.h +80 -0
  275. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/json.h +52 -0
  276. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/json_platform.h +26 -0
  277. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/maybe.h +104 -0
  278. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/parser_handler.h +39 -0
  279. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/protocol_core.h +406 -0
  280. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/serializable.h +32 -0
  281. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/serializer_traits.h +158 -0
  282. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/span.h +99 -0
  283. package/pods/Headers/inspector/third_party/inspector_protocol/crdtp/status.h +139 -0
  284. package/pods/Headers/inspector/utils.h +32 -0
  285. package/pods/Headers/inspector/v8-inspector-platform.h +44 -0
  286. package/pods/Headers/jsi/decorator.h +762 -0
  287. package/pods/Headers/jsi/instrumentation.h +117 -0
  288. package/pods/Headers/jsi/jsi-inl.h +322 -0
  289. package/pods/Headers/jsi/jsi.h +1387 -0
  290. package/pods/Headers/jsi/jsilib.h +59 -0
  291. package/pods/Headers/jsi/threadsafe.h +79 -0
  292. package/pods/Headers/runtime/ArgConverter.h +61 -0
  293. package/pods/Headers/runtime/ArrayAdapter.h +13 -0
  294. package/pods/Headers/runtime/Caches.h +98 -0
  295. package/pods/Headers/runtime/ClassBuilder.h +61 -0
  296. package/pods/Headers/runtime/Common.h +9 -0
  297. package/pods/Headers/runtime/ConcurrentMap.h +55 -0
  298. package/pods/Headers/runtime/ConcurrentQueue.h +28 -0
  299. package/pods/Headers/runtime/Console.h +27 -0
  300. package/pods/Headers/runtime/Constants.h +15 -0
  301. package/pods/Headers/runtime/DataWrapper.h +671 -0
  302. package/pods/Headers/runtime/DictionaryAdapter.h +13 -0
  303. package/pods/Headers/runtime/ExtVector.h +21 -0
  304. package/pods/Headers/runtime/FFICall.h +105 -0
  305. package/pods/Headers/runtime/FastEnumerationAdapter.h +13 -0
  306. package/pods/Headers/runtime/FunctionReference.h +18 -0
  307. package/pods/Headers/runtime/Helpers.h +84 -0
  308. package/pods/Headers/runtime/InlineFunctions.h +16 -0
  309. package/pods/Headers/runtime/Interop.h +202 -0
  310. package/pods/Headers/runtime/KnownUnknownClassPair.h +35 -0
  311. package/pods/Headers/runtime/Metadata.h +981 -0
  312. package/pods/Headers/runtime/MetadataBuilder.h +72 -0
  313. package/pods/Headers/runtime/MetadataInlines.h +157 -0
  314. package/pods/Headers/runtime/ModuleInternal.h +59 -0
  315. package/pods/Headers/runtime/NSDataAdapter.h +13 -0
  316. package/pods/Headers/runtime/NativeScriptException.h +27 -0
  317. package/pods/Headers/runtime/ObjectManager.h +31 -0
  318. package/pods/Headers/runtime/OneByteStringResource.h +21 -0
  319. package/pods/Headers/runtime/Pointer.h +26 -0
  320. package/pods/Headers/runtime/PromiseProxy.h +15 -0
  321. package/pods/Headers/runtime/Reference.h +38 -0
  322. package/pods/Headers/runtime/Runtime.h +67 -0
  323. package/pods/Headers/runtime/RuntimeConfig.h +17 -0
  324. package/pods/Headers/runtime/SetTimeout.h +34 -0
  325. package/pods/Headers/runtime/SimpleAllocator.h +23 -0
  326. package/pods/Headers/runtime/StringHasher.h +315 -0
  327. package/pods/Headers/runtime/SymbolIterator.h +18 -0
  328. package/pods/Headers/runtime/SymbolLoader.h +27 -0
  329. package/pods/Headers/runtime/TNSDerivedClass.h +8 -0
  330. package/pods/Headers/runtime/TSHelpers.h +15 -0
  331. package/pods/Headers/runtime/Tasks.h +19 -0
  332. package/pods/Headers/runtime/UnmanagedType.h +21 -0
  333. package/pods/Headers/runtime/WeakRef.h +15 -0
  334. package/pods/Headers/runtime/Worker.h +26 -0
  335. package/pods/Headers/runtime/robin_hood.h +2184 -0
  336. package/pods/Headers/v8runtime/HostProxy.h +71 -0
  337. package/pods/Headers/v8runtime/JSIV8ValueConverter.h +70 -0
  338. package/pods/Headers/v8runtime/V8PointerValue.h +44 -0
  339. package/pods/Headers/v8runtime/V8Runtime.h +215 -0
  340. package/pods/Headers/v8runtime/V8RuntimeConfig.h +26 -0
  341. package/pods/Headers/v8runtime/V8RuntimeFactory.h +21 -0
  342. package/pods/NativeScript.podspec +68 -0
  343. package/platforms/ios/Mason.xcframework/ios-arm64_x86_64-simulator/Mason.framework/PrivateHeaders/mason_native.h +0 -676
  344. package/platforms/ios/src/JSIModule.h +0 -217
  345. package/platforms/ios/src/JSIModule.mm +0 -2788
@@ -0,0 +1,367 @@
1
+ // Copyright 2012 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 V8_UTILS_ALLOCATION_H_
6
+ #define V8_UTILS_ALLOCATION_H_
7
+
8
+ #include "include/v8-platform.h"
9
+ #include "src/base/address-region.h"
10
+ #include "src/base/compiler-specific.h"
11
+ #include "src/base/platform/platform.h"
12
+ #include "src/common/globals.h"
13
+ #include "src/init/v8.h"
14
+
15
+ namespace v8 {
16
+
17
+ namespace base {
18
+ class BoundedPageAllocator;
19
+ } // namespace base
20
+
21
+ namespace internal {
22
+
23
+ class Isolate;
24
+
25
+ // This file defines memory allocation functions. If a first attempt at an
26
+ // allocation fails, these functions call back into the embedder, then attempt
27
+ // the allocation a second time. The embedder callback must not reenter V8.
28
+
29
+ // Called when allocation routines fail to allocate, even with a possible retry.
30
+ // This function should not return, but should terminate the current processing.
31
+ [[noreturn]] V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(
32
+ Isolate* isolate, const char* message);
33
+
34
+ // Superclass for classes managed with new & delete.
35
+ class V8_EXPORT_PRIVATE Malloced {
36
+ public:
37
+ static void* operator new(size_t size);
38
+ static void operator delete(void* p);
39
+ };
40
+
41
+ template <typename T>
42
+ T* NewArray(size_t size) {
43
+ T* result = new (std::nothrow) T[size];
44
+ if (result == nullptr) {
45
+ V8::GetCurrentPlatform()->OnCriticalMemoryPressure();
46
+ result = new (std::nothrow) T[size];
47
+ if (result == nullptr) FatalProcessOutOfMemory(nullptr, "NewArray");
48
+ }
49
+ return result;
50
+ }
51
+
52
+ template <typename T, typename = typename std::enable_if<
53
+ base::is_trivially_copyable<T>::value>::type>
54
+ T* NewArray(size_t size, T default_val) {
55
+ T* result = reinterpret_cast<T*>(NewArray<uint8_t>(sizeof(T) * size));
56
+ for (size_t i = 0; i < size; ++i) result[i] = default_val;
57
+ return result;
58
+ }
59
+
60
+ template <typename T>
61
+ void DeleteArray(T* array) {
62
+ delete[] array;
63
+ }
64
+
65
+ template <typename T>
66
+ struct ArrayDeleter {
67
+ void operator()(T* array) { DeleteArray(array); }
68
+ };
69
+
70
+ template <typename T>
71
+ using ArrayUniquePtr = std::unique_ptr<T, ArrayDeleter<T>>;
72
+
73
+ // The normal strdup functions use malloc. These versions of StrDup
74
+ // and StrNDup uses new and calls the FatalProcessOutOfMemory handler
75
+ // if allocation fails.
76
+ V8_EXPORT_PRIVATE char* StrDup(const char* str);
77
+ char* StrNDup(const char* str, int n);
78
+
79
+ // Allocation policy for allocating in the C free store using malloc
80
+ // and free. Used as the default policy for lists.
81
+ class FreeStoreAllocationPolicy {
82
+ public:
83
+ template <typename T, typename TypeTag = T[]>
84
+ V8_INLINE T* NewArray(size_t length) {
85
+ return static_cast<T*>(Malloced::operator new(length * sizeof(T)));
86
+ }
87
+ template <typename T, typename TypeTag = T[]>
88
+ V8_INLINE void DeleteArray(T* p, size_t length) {
89
+ Malloced::operator delete(p);
90
+ }
91
+ };
92
+
93
+ // Performs a malloc, with retry logic on failure. Returns nullptr on failure.
94
+ // Call free to release memory allocated with this function.
95
+ void* AllocWithRetry(size_t size);
96
+
97
+ V8_EXPORT_PRIVATE void* AlignedAlloc(size_t size, size_t alignment);
98
+ V8_EXPORT_PRIVATE void AlignedFree(void* ptr);
99
+
100
+ // Returns platfrom page allocator instance. Guaranteed to be a valid pointer.
101
+ V8_EXPORT_PRIVATE v8::PageAllocator* GetPlatformPageAllocator();
102
+
103
+ // Sets the given page allocator as the platform page allocator and returns
104
+ // the current one. This function *must* be used only for testing purposes.
105
+ // It is not thread-safe and the testing infrastructure should ensure that
106
+ // the tests do not modify the value simultaneously.
107
+ V8_EXPORT_PRIVATE v8::PageAllocator* SetPlatformPageAllocatorForTesting(
108
+ v8::PageAllocator* page_allocator);
109
+
110
+ // Gets the page granularity for AllocatePages and FreePages. Addresses returned
111
+ // by AllocatePages are aligned to this size.
112
+ V8_EXPORT_PRIVATE size_t AllocatePageSize();
113
+
114
+ // Gets the granularity at which the permissions and release calls can be made.
115
+ V8_EXPORT_PRIVATE size_t CommitPageSize();
116
+
117
+ // Sets the random seed so that GetRandomMmapAddr() will generate repeatable
118
+ // sequences of random mmap addresses.
119
+ V8_EXPORT_PRIVATE void SetRandomMmapSeed(int64_t seed);
120
+
121
+ // Generate a random address to be used for hinting allocation calls.
122
+ V8_EXPORT_PRIVATE void* GetRandomMmapAddr();
123
+
124
+ // Allocates memory. Permissions are set according to the access argument.
125
+ // |address| is a hint. |size| and |alignment| must be multiples of
126
+ // AllocatePageSize(). Returns the address of the allocated memory, with the
127
+ // specified size and alignment, or nullptr on failure.
128
+ V8_EXPORT_PRIVATE
129
+ V8_WARN_UNUSED_RESULT void* AllocatePages(v8::PageAllocator* page_allocator,
130
+ void* address, size_t size,
131
+ size_t alignment,
132
+ PageAllocator::Permission access);
133
+
134
+ // Frees memory allocated by a call to AllocatePages. |address| and |size| must
135
+ // be multiples of AllocatePageSize(). Returns true on success, otherwise false.
136
+ V8_EXPORT_PRIVATE
137
+ V8_WARN_UNUSED_RESULT bool FreePages(v8::PageAllocator* page_allocator,
138
+ void* address, const size_t size);
139
+
140
+ // Releases memory that is no longer needed. The range specified by |address|
141
+ // and |size| must be an allocated memory region. |size| and |new_size| must be
142
+ // multiples of CommitPageSize(). Memory from |new_size| to |size| is released.
143
+ // Released memory is left in an undefined state, so it should not be accessed.
144
+ // Returns true on success, otherwise false.
145
+ V8_EXPORT_PRIVATE
146
+ V8_WARN_UNUSED_RESULT bool ReleasePages(v8::PageAllocator* page_allocator,
147
+ void* address, size_t size,
148
+ size_t new_size);
149
+
150
+ // Sets permissions according to |access|. |address| and |size| must be
151
+ // multiples of CommitPageSize(). Setting permission to kNoAccess may
152
+ // cause the memory contents to be lost. Returns true on success, otherwise
153
+ // false.
154
+ V8_EXPORT_PRIVATE
155
+ V8_WARN_UNUSED_RESULT bool SetPermissions(v8::PageAllocator* page_allocator,
156
+ void* address, size_t size,
157
+ PageAllocator::Permission access);
158
+ inline bool SetPermissions(v8::PageAllocator* page_allocator, Address address,
159
+ size_t size, PageAllocator::Permission access) {
160
+ return SetPermissions(page_allocator, reinterpret_cast<void*>(address), size,
161
+ access);
162
+ }
163
+
164
+ // Function that may release reserved memory regions to allow failed allocations
165
+ // to succeed. |length| is the amount of memory needed. Returns |true| if memory
166
+ // could be released, false otherwise.
167
+ V8_EXPORT_PRIVATE bool OnCriticalMemoryPressure(size_t length);
168
+
169
+ // Represents and controls an area of reserved memory.
170
+ class VirtualMemory final {
171
+ public:
172
+ enum JitPermission { kNoJit, kMapAsJittable };
173
+
174
+ // Empty VirtualMemory object, controlling no reserved memory.
175
+ V8_EXPORT_PRIVATE VirtualMemory();
176
+
177
+ VirtualMemory(const VirtualMemory&) = delete;
178
+ VirtualMemory& operator=(const VirtualMemory&) = delete;
179
+
180
+ // Reserves virtual memory containing an area of the given size that is
181
+ // aligned per |alignment| rounded up to the |page_allocator|'s allocate page
182
+ // size. The |size| must be aligned with |page_allocator|'s commit page size.
183
+ // This may not be at the position returned by address().
184
+ V8_EXPORT_PRIVATE VirtualMemory(v8::PageAllocator* page_allocator,
185
+ size_t size, void* hint, size_t alignment = 1,
186
+ JitPermission jit = kNoJit);
187
+
188
+ // Construct a virtual memory by assigning it some already mapped address
189
+ // and size.
190
+ VirtualMemory(v8::PageAllocator* page_allocator, Address address, size_t size)
191
+ : page_allocator_(page_allocator), region_(address, size) {
192
+ DCHECK_NOT_NULL(page_allocator);
193
+ DCHECK(IsAligned(address, page_allocator->AllocatePageSize()));
194
+ DCHECK(IsAligned(size, page_allocator->CommitPageSize()));
195
+ }
196
+
197
+ // Releases the reserved memory, if any, controlled by this VirtualMemory
198
+ // object.
199
+ V8_EXPORT_PRIVATE ~VirtualMemory();
200
+
201
+ // Move constructor.
202
+ VirtualMemory(VirtualMemory&& other) V8_NOEXCEPT { *this = std::move(other); }
203
+
204
+ // Move assignment operator.
205
+ VirtualMemory& operator=(VirtualMemory&& other) V8_NOEXCEPT {
206
+ DCHECK(!IsReserved());
207
+ page_allocator_ = other.page_allocator_;
208
+ region_ = other.region_;
209
+ other.Reset();
210
+ return *this;
211
+ }
212
+
213
+ // Returns whether the memory has been reserved.
214
+ bool IsReserved() const { return region_.begin() != kNullAddress; }
215
+
216
+ // Initialize or resets an embedded VirtualMemory object.
217
+ V8_EXPORT_PRIVATE void Reset();
218
+
219
+ v8::PageAllocator* page_allocator() { return page_allocator_; }
220
+
221
+ const base::AddressRegion& region() const { return region_; }
222
+
223
+ // Returns the start address of the reserved memory.
224
+ // If the memory was reserved with an alignment, this address is not
225
+ // necessarily aligned. The user might need to round it up to a multiple of
226
+ // the alignment to get the start of the aligned block.
227
+ Address address() const {
228
+ DCHECK(IsReserved());
229
+ return region_.begin();
230
+ }
231
+
232
+ Address end() const {
233
+ DCHECK(IsReserved());
234
+ return region_.end();
235
+ }
236
+
237
+ // Returns the size of the reserved memory. The returned value is only
238
+ // meaningful when IsReserved() returns true.
239
+ // If the memory was reserved with an alignment, this size may be larger
240
+ // than the requested size.
241
+ size_t size() const { return region_.size(); }
242
+
243
+ // Sets permissions according to the access argument. address and size must be
244
+ // multiples of CommitPageSize(). Returns true on success, otherwise false.
245
+ V8_EXPORT_PRIVATE bool SetPermissions(Address address, size_t size,
246
+ PageAllocator::Permission access);
247
+
248
+ // Releases memory after |free_start|. Returns the number of bytes released.
249
+ V8_EXPORT_PRIVATE size_t Release(Address free_start);
250
+
251
+ // Frees all memory.
252
+ V8_EXPORT_PRIVATE void Free();
253
+
254
+ // As with Free but does not write to the VirtualMemory object itself so it
255
+ // can be called on a VirtualMemory that is itself not writable.
256
+ V8_EXPORT_PRIVATE void FreeReadOnly();
257
+
258
+ bool InVM(Address address, size_t size) const {
259
+ return region_.contains(address, size);
260
+ }
261
+
262
+ private:
263
+ // Page allocator that controls the virtual memory.
264
+ v8::PageAllocator* page_allocator_ = nullptr;
265
+ base::AddressRegion region_;
266
+ };
267
+
268
+ // Represents a VirtualMemory reservation along with a BoundedPageAllocator that
269
+ // can be used to allocate within the reservation.
270
+ //
271
+ // Virtual memory cages are used for both the pointer compression cage and code
272
+ // ranges (on platforms that require code ranges) and are configurable via
273
+ // ReservationParams.
274
+ //
275
+ // +------------+-----------+----------- ~~~ -+
276
+ // | ... | ... | ... |
277
+ // +------------+-----------+------------ ~~~ -+
278
+ // ^ ^ ^
279
+ // start cage base allocatable base
280
+ //
281
+ // <------------> <------------------->
282
+ // base bias size allocatable size
283
+ // <-------------------------------------------->
284
+ // reservation size
285
+ //
286
+ // - The reservation is made using ReservationParams::page_allocator.
287
+ // - start is the start of the virtual memory reservation.
288
+ // - cage base is the base address of the cage.
289
+ // - allocatable base is the cage base rounded up to the nearest
290
+ // ReservationParams::page_size, and is the start of the allocatable area for
291
+ // the BoundedPageAllocator.
292
+ //
293
+ // - The base bias is configured by ReservationParams::base_bias_size.
294
+ // - The reservation size is configured by ReservationParams::reservation_size.
295
+ //
296
+ // Additionally,
297
+ // - The alignment of the cage base is configured by
298
+ // ReservationParams::base_alignment.
299
+ // - The page size of the BoundedPageAllocator is configured by
300
+ // ReservationParams::page_size.
301
+ // - A hint for the value of start can be passed by
302
+ // ReservationParams::requested_start_hint.
303
+ //
304
+ // The configuration is subject to the following alignment requirements.
305
+ // Below, AllocatePageSize is short for
306
+ // ReservationParams::page_allocator->AllocatePageSize().
307
+ //
308
+ // - The reservation size must be AllocatePageSize-aligned.
309
+ // - If the base alignment is not kAnyBaseAlignment, both the base alignment
310
+ // and the base bias size must be AllocatePageSize-aligned.
311
+ // - The base alignment may be kAnyBaseAlignment to denote any alignment is
312
+ // acceptable. In this case the base bias size does not need to be aligned.
313
+ class VirtualMemoryCage {
314
+ public:
315
+ VirtualMemoryCage();
316
+ virtual ~VirtualMemoryCage();
317
+
318
+ VirtualMemoryCage(const VirtualMemoryCage&) = delete;
319
+ VirtualMemoryCage& operator=(VirtualMemoryCage&) = delete;
320
+
321
+ VirtualMemoryCage(VirtualMemoryCage&& other) V8_NOEXCEPT;
322
+ VirtualMemoryCage& operator=(VirtualMemoryCage&& other) V8_NOEXCEPT;
323
+
324
+ Address base() const { return base_; }
325
+
326
+ base::BoundedPageAllocator* page_allocator() const {
327
+ return page_allocator_.get();
328
+ }
329
+
330
+ VirtualMemory* reservation() { return &reservation_; }
331
+ const VirtualMemory* reservation() const { return &reservation_; }
332
+
333
+ bool IsReserved() const {
334
+ DCHECK_EQ(base_ != kNullAddress, reservation_.IsReserved());
335
+ return reservation_.IsReserved();
336
+ }
337
+
338
+ struct ReservationParams {
339
+ // The allocator to use to reserve the virtual memory.
340
+ v8::PageAllocator* page_allocator;
341
+ // See diagram above.
342
+ size_t reservation_size;
343
+ size_t base_alignment;
344
+ size_t base_bias_size;
345
+ size_t page_size;
346
+ Address requested_start_hint;
347
+
348
+ static constexpr size_t kAnyBaseAlignment = 1;
349
+ };
350
+
351
+ // A number of attempts is made to try to reserve a region that satisfies the
352
+ // constraints in params, but this may fail. The base address may be different
353
+ // than the one requested.
354
+ bool InitReservation(const ReservationParams& params);
355
+
356
+ void Free();
357
+
358
+ protected:
359
+ Address base_ = kNullAddress;
360
+ std::unique_ptr<base::BoundedPageAllocator> page_allocator_;
361
+ VirtualMemory reservation_;
362
+ };
363
+
364
+ } // namespace internal
365
+ } // namespace v8
366
+
367
+ #endif // V8_UTILS_ALLOCATION_H_
@@ -0,0 +1,324 @@
1
+ // Copyright 2014 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 V8_UTILS_VECTOR_H_
6
+ #define V8_UTILS_VECTOR_H_
7
+
8
+ #include <algorithm>
9
+ #include <cstring>
10
+ #include <iterator>
11
+ #include <memory>
12
+ #include <type_traits>
13
+
14
+ #include "src/common/checks.h"
15
+ #include "src/common/globals.h"
16
+ #include "src/utils/allocation.h"
17
+
18
+ namespace v8 {
19
+ namespace internal {
20
+
21
+ template <typename T>
22
+ class Vector {
23
+ public:
24
+ using value_type = T;
25
+ using iterator = T*;
26
+ using const_iterator = const T*;
27
+
28
+ constexpr Vector() : start_(nullptr), length_(0) {}
29
+
30
+ constexpr Vector(T* data, size_t length) : start_(data), length_(length) {
31
+ DCHECK(length == 0 || data != nullptr);
32
+ }
33
+
34
+ static Vector<T> New(size_t length) {
35
+ return Vector<T>(NewArray<T>(length), length);
36
+ }
37
+
38
+ // Returns a vector using the same backing storage as this one,
39
+ // spanning from and including 'from', to but not including 'to'.
40
+ Vector<T> SubVector(size_t from, size_t to) const {
41
+ DCHECK_LE(from, to);
42
+ DCHECK_LE(to, length_);
43
+ return Vector<T>(begin() + from, to - from);
44
+ }
45
+
46
+ // Returns the length of the vector. Only use this if you really need an
47
+ // integer return value. Use {size()} otherwise.
48
+ int length() const {
49
+ DCHECK_GE(std::numeric_limits<int>::max(), length_);
50
+ return static_cast<int>(length_);
51
+ }
52
+
53
+ // Returns the length of the vector as a size_t.
54
+ constexpr size_t size() const { return length_; }
55
+
56
+ // Returns whether or not the vector is empty.
57
+ constexpr bool empty() const { return length_ == 0; }
58
+
59
+ // Access individual vector elements - checks bounds in debug mode.
60
+ T& operator[](size_t index) const {
61
+ DCHECK_LT(index, length_);
62
+ return start_[index];
63
+ }
64
+
65
+ const T& at(size_t index) const { return operator[](index); }
66
+
67
+ T& first() { return start_[0]; }
68
+
69
+ T& last() {
70
+ DCHECK_LT(0, length_);
71
+ return start_[length_ - 1];
72
+ }
73
+
74
+ // Returns a pointer to the start of the data in the vector.
75
+ constexpr T* begin() const { return start_; }
76
+
77
+ // For consistency with other containers, do also provide a {data} accessor.
78
+ constexpr T* data() const { return start_; }
79
+
80
+ // Returns a pointer past the end of the data in the vector.
81
+ constexpr T* end() const { return start_ + length_; }
82
+
83
+ // Returns a clone of this vector with a new backing store.
84
+ Vector<T> Clone() const {
85
+ T* result = NewArray<T>(length_);
86
+ for (size_t i = 0; i < length_; i++) result[i] = start_[i];
87
+ return Vector<T>(result, length_);
88
+ }
89
+
90
+ void Truncate(size_t length) {
91
+ DCHECK(length <= length_);
92
+ length_ = length;
93
+ }
94
+
95
+ // Releases the array underlying this vector. Once disposed the
96
+ // vector is empty.
97
+ void Dispose() {
98
+ DeleteArray(start_);
99
+ start_ = nullptr;
100
+ length_ = 0;
101
+ }
102
+
103
+ Vector<T> operator+(size_t offset) {
104
+ DCHECK_LE(offset, length_);
105
+ return Vector<T>(start_ + offset, length_ - offset);
106
+ }
107
+
108
+ Vector<T> operator+=(size_t offset) {
109
+ DCHECK_LE(offset, length_);
110
+ start_ += offset;
111
+ length_ -= offset;
112
+ return *this;
113
+ }
114
+
115
+ // Implicit conversion from Vector<T> to Vector<const T>.
116
+ operator Vector<const T>() const { return {start_, length_}; }
117
+
118
+ template <typename S>
119
+ static Vector<T> cast(Vector<S> input) {
120
+ // Casting is potentially dangerous, so be really restrictive here. This
121
+ // might be lifted once we have use cases for that.
122
+ STATIC_ASSERT(std::is_pod<S>::value);
123
+ STATIC_ASSERT(std::is_pod<T>::value);
124
+ DCHECK_EQ(0, (input.size() * sizeof(S)) % sizeof(T));
125
+ DCHECK_EQ(0, reinterpret_cast<uintptr_t>(input.begin()) % alignof(T));
126
+ return Vector<T>(reinterpret_cast<T*>(input.begin()),
127
+ input.size() * sizeof(S) / sizeof(T));
128
+ }
129
+
130
+ bool operator==(const Vector<const T> other) const {
131
+ return std::equal(begin(), end(), other.begin(), other.end());
132
+ }
133
+
134
+ bool operator!=(const Vector<const T> other) const {
135
+ return !operator==(other);
136
+ }
137
+
138
+ private:
139
+ T* start_;
140
+ size_t length_;
141
+ };
142
+
143
+ template <typename T>
144
+ class V8_NODISCARD ScopedVector : public Vector<T> {
145
+ public:
146
+ explicit ScopedVector(size_t length)
147
+ : Vector<T>(NewArray<T>(length), length) {}
148
+ ~ScopedVector() { DeleteArray(this->begin()); }
149
+
150
+ private:
151
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedVector);
152
+ };
153
+
154
+ template <typename T>
155
+ class OwnedVector {
156
+ public:
157
+ MOVE_ONLY_WITH_DEFAULT_CONSTRUCTORS(OwnedVector);
158
+ OwnedVector(std::unique_ptr<T[]> data, size_t length)
159
+ : data_(std::move(data)), length_(length) {
160
+ DCHECK_IMPLIES(length_ > 0, data_ != nullptr);
161
+ }
162
+
163
+ // Implicit conversion from {OwnedVector<U>} to {OwnedVector<T>}, instantiable
164
+ // if {std::unique_ptr<U>} can be converted to {std::unique_ptr<T>}.
165
+ // Can be used to convert {OwnedVector<T>} to {OwnedVector<const T>}.
166
+ template <typename U,
167
+ typename = typename std::enable_if<std::is_convertible<
168
+ std::unique_ptr<U>, std::unique_ptr<T>>::value>::type>
169
+ OwnedVector(OwnedVector<U>&& other)
170
+ : data_(std::move(other.data_)), length_(other.length_) {
171
+ STATIC_ASSERT(sizeof(U) == sizeof(T));
172
+ other.length_ = 0;
173
+ }
174
+
175
+ // Returns the length of the vector as a size_t.
176
+ constexpr size_t size() const { return length_; }
177
+
178
+ // Returns whether or not the vector is empty.
179
+ constexpr bool empty() const { return length_ == 0; }
180
+
181
+ // Returns the pointer to the start of the data in the vector.
182
+ T* start() const {
183
+ DCHECK_IMPLIES(length_ > 0, data_ != nullptr);
184
+ return data_.get();
185
+ }
186
+
187
+ constexpr T* begin() const { return start(); }
188
+ constexpr T* end() const { return start() + size(); }
189
+
190
+ // Access individual vector elements - checks bounds in debug mode.
191
+ T& operator[](size_t index) const {
192
+ DCHECK_LT(index, length_);
193
+ return data_[index];
194
+ }
195
+
196
+ // Returns a {Vector<T>} view of the data in this vector.
197
+ Vector<T> as_vector() const { return Vector<T>(start(), size()); }
198
+
199
+ // Releases the backing data from this vector and transfers ownership to the
200
+ // caller. This vector will be empty afterwards.
201
+ std::unique_ptr<T[]> ReleaseData() {
202
+ length_ = 0;
203
+ return std::move(data_);
204
+ }
205
+
206
+ // Allocates a new vector of the specified size via the default allocator.
207
+ // Elements in the new vector are value-initialized.
208
+ static OwnedVector<T> New(size_t size) {
209
+ if (size == 0) return {};
210
+ return OwnedVector<T>(std::make_unique<T[]>(size), size);
211
+ }
212
+
213
+ // Allocates a new vector of the specified size via the default allocator.
214
+ // Elements in the new vector are default-initialized.
215
+ static OwnedVector<T> NewForOverwrite(size_t size) {
216
+ if (size == 0) return {};
217
+ // TODO(v8): Use {std::make_unique_for_overwrite} once we allow C++20.
218
+ return OwnedVector<T>(std::unique_ptr<T[]>(new T[size]), size);
219
+ }
220
+
221
+ // Allocates a new vector containing the specified collection of values.
222
+ // {Iterator} is the common type of {std::begin} and {std::end} called on a
223
+ // {const U&}. This function is only instantiable if that type exists.
224
+ template <typename U, typename Iterator = typename std::common_type<
225
+ decltype(std::begin(std::declval<const U&>())),
226
+ decltype(std::end(std::declval<const U&>()))>::type>
227
+ static OwnedVector<T> Of(const U& collection) {
228
+ Iterator begin = std::begin(collection);
229
+ Iterator end = std::end(collection);
230
+ using non_const_t = typename std::remove_const<T>::type;
231
+ auto vec =
232
+ OwnedVector<non_const_t>::NewForOverwrite(std::distance(begin, end));
233
+ std::copy(begin, end, vec.start());
234
+ return vec;
235
+ }
236
+
237
+ bool operator==(std::nullptr_t) const { return data_ == nullptr; }
238
+ bool operator!=(std::nullptr_t) const { return data_ != nullptr; }
239
+
240
+ private:
241
+ template <typename U>
242
+ friend class OwnedVector;
243
+
244
+ std::unique_ptr<T[]> data_;
245
+ size_t length_ = 0;
246
+ };
247
+
248
+ // The vectors returned by {StaticCharVector}, {CStrVector}, or {OneByteVector}
249
+ // do not contain a null-termination byte. If you want the null byte, use
250
+ // {ArrayVector}.
251
+
252
+ // Known length, constexpr.
253
+ template <size_t N>
254
+ constexpr Vector<const char> StaticCharVector(const char (&array)[N]) {
255
+ return {array, N - 1};
256
+ }
257
+
258
+ // Unknown length, not constexpr.
259
+ inline Vector<const char> CStrVector(const char* data) {
260
+ return {data, strlen(data)};
261
+ }
262
+
263
+ // OneByteVector is never constexpr because the data pointer is
264
+ // {reinterpret_cast}ed.
265
+ inline Vector<const uint8_t> OneByteVector(const char* data, size_t length) {
266
+ return {reinterpret_cast<const uint8_t*>(data), length};
267
+ }
268
+
269
+ inline Vector<const uint8_t> OneByteVector(const char* data) {
270
+ return OneByteVector(data, strlen(data));
271
+ }
272
+
273
+ template <size_t N>
274
+ Vector<const uint8_t> StaticOneByteVector(const char (&array)[N]) {
275
+ return OneByteVector(array, N - 1);
276
+ }
277
+
278
+ // For string literals, ArrayVector("foo") returns a vector ['f', 'o', 'o', \0]
279
+ // with length 4 and null-termination.
280
+ // If you want ['f', 'o', 'o'], use CStrVector("foo").
281
+ template <typename T, size_t N>
282
+ inline constexpr Vector<T> ArrayVector(T (&arr)[N]) {
283
+ return {arr, N};
284
+ }
285
+
286
+ // Construct a Vector from a start pointer and a size.
287
+ template <typename T>
288
+ inline constexpr Vector<T> VectorOf(T* start, size_t size) {
289
+ return {start, size};
290
+ }
291
+
292
+ // Construct a Vector from anything providing a {data()} and {size()} accessor.
293
+ template <typename Container>
294
+ inline constexpr auto VectorOf(Container&& c)
295
+ -> decltype(VectorOf(c.data(), c.size())) {
296
+ return VectorOf(c.data(), c.size());
297
+ }
298
+
299
+ // Construct a Vector from an initializer list. The vector can obviously only be
300
+ // used as long as the initializer list is live. Valid uses include direct use
301
+ // in parameter lists: F(VectorOf({1, 2, 3}));
302
+ template <typename T>
303
+ inline constexpr Vector<const T> VectorOf(std::initializer_list<T> list) {
304
+ return VectorOf(list.begin(), list.size());
305
+ }
306
+
307
+ template <typename T, size_t kSize>
308
+ class EmbeddedVector : public Vector<T> {
309
+ public:
310
+ EmbeddedVector() : Vector<T>(buffer_, kSize) {}
311
+ explicit EmbeddedVector(const T& initial_value) : Vector<T>(buffer_, kSize) {
312
+ std::fill_n(buffer_, kSize, initial_value);
313
+ }
314
+ EmbeddedVector(const EmbeddedVector&) = delete;
315
+ EmbeddedVector& operator=(const EmbeddedVector&) = delete;
316
+
317
+ private:
318
+ T buffer_[kSize];
319
+ };
320
+
321
+ } // namespace internal
322
+ } // namespace v8
323
+
324
+ #endif // V8_UTILS_VECTOR_H_