@triniwiz/nativescript-masonkit 1.0.0-alpha.5 → 1.0.0-alpha.7

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 +7002 -1194
  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 +7002 -1194
  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 +7002 -1194
  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,822 @@
1
+ // Copyright 2014 The Chromium 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
+ // Slightly adapted for inclusion in V8.
6
+ // Copyright 2014 the V8 project authors. All rights reserved.
7
+ // List of adaptations:
8
+ // - include guard names
9
+ // - wrap in v8 namespace
10
+ // - formatting (git cl format)
11
+
12
+ #ifndef V8_BASE_SAFE_CONVERSIONS_IMPL_H_
13
+ #define V8_BASE_SAFE_CONVERSIONS_IMPL_H_
14
+
15
+ #include <stdint.h>
16
+
17
+ #include <limits>
18
+ #include <type_traits>
19
+
20
+ #if defined(__GNUC__) || defined(__clang__)
21
+ #define BASE_NUMERICS_LIKELY(x) __builtin_expect(!!(x), 1)
22
+ #define BASE_NUMERICS_UNLIKELY(x) __builtin_expect(!!(x), 0)
23
+ #else
24
+ #define BASE_NUMERICS_LIKELY(x) (x)
25
+ #define BASE_NUMERICS_UNLIKELY(x) (x)
26
+ #endif
27
+
28
+ namespace v8 {
29
+ namespace base {
30
+ namespace internal {
31
+
32
+ // The std library doesn't provide a binary max_exponent for integers, however
33
+ // we can compute an analog using std::numeric_limits<>::digits.
34
+ template <typename NumericType>
35
+ struct MaxExponent {
36
+ static const int value = std::is_floating_point<NumericType>::value
37
+ ? std::numeric_limits<NumericType>::max_exponent
38
+ : std::numeric_limits<NumericType>::digits + 1;
39
+ };
40
+
41
+ // The number of bits (including the sign) in an integer. Eliminates sizeof
42
+ // hacks.
43
+ template <typename NumericType>
44
+ struct IntegerBitsPlusSign {
45
+ static const int value = std::numeric_limits<NumericType>::digits +
46
+ std::is_signed<NumericType>::value;
47
+ };
48
+
49
+ // Helper templates for integer manipulations.
50
+
51
+ template <typename Integer>
52
+ struct PositionOfSignBit {
53
+ static const size_t value = IntegerBitsPlusSign<Integer>::value - 1;
54
+ };
55
+
56
+ // Determines if a numeric value is negative without throwing compiler
57
+ // warnings on: unsigned(value) < 0.
58
+ template <typename T,
59
+ typename std::enable_if<std::is_signed<T>::value>::type* = nullptr>
60
+ constexpr bool IsValueNegative(T value) {
61
+ static_assert(std::is_arithmetic<T>::value, "Argument must be numeric.");
62
+ return value < 0;
63
+ }
64
+
65
+ template <typename T,
66
+ typename std::enable_if<!std::is_signed<T>::value>::type* = nullptr>
67
+ constexpr bool IsValueNegative(T) {
68
+ static_assert(std::is_arithmetic<T>::value, "Argument must be numeric.");
69
+ return false;
70
+ }
71
+
72
+ // This performs a fast negation, returning a signed value. It works on unsigned
73
+ // arguments, but probably doesn't do what you want for any unsigned value
74
+ // larger than max / 2 + 1 (i.e. signed min cast to unsigned).
75
+ template <typename T>
76
+ constexpr typename std::make_signed<T>::type ConditionalNegate(
77
+ T x, bool is_negative) {
78
+ static_assert(std::is_integral<T>::value, "Type must be integral");
79
+ using SignedT = typename std::make_signed<T>::type;
80
+ using UnsignedT = typename std::make_unsigned<T>::type;
81
+ return static_cast<SignedT>(
82
+ (static_cast<UnsignedT>(x) ^ -SignedT(is_negative)) + is_negative);
83
+ }
84
+
85
+ // This performs a safe, absolute value via unsigned overflow.
86
+ template <typename T>
87
+ constexpr typename std::make_unsigned<T>::type SafeUnsignedAbs(T value) {
88
+ static_assert(std::is_integral<T>::value, "Type must be integral");
89
+ using UnsignedT = typename std::make_unsigned<T>::type;
90
+ return IsValueNegative(value)
91
+ ? static_cast<UnsignedT>(0u - static_cast<UnsignedT>(value))
92
+ : static_cast<UnsignedT>(value);
93
+ }
94
+
95
+ // This allows us to switch paths on known compile-time constants.
96
+ #if defined(__clang__) || defined(__GNUC__)
97
+ constexpr bool CanDetectCompileTimeConstant() { return true; }
98
+ template <typename T>
99
+ constexpr bool IsCompileTimeConstant(const T v) {
100
+ return __builtin_constant_p(v);
101
+ }
102
+ #else
103
+ constexpr bool CanDetectCompileTimeConstant() { return false; }
104
+ template <typename T>
105
+ constexpr bool IsCompileTimeConstant(const T) {
106
+ return false;
107
+ }
108
+ #endif
109
+ template <typename T>
110
+ constexpr bool MustTreatAsConstexpr(const T v) {
111
+ // Either we can't detect a compile-time constant, and must always use the
112
+ // constexpr path, or we know we have a compile-time constant.
113
+ return !CanDetectCompileTimeConstant() || IsCompileTimeConstant(v);
114
+ }
115
+
116
+ // Forces a crash, like a CHECK(false). Used for numeric boundary errors.
117
+ // Also used in a constexpr template to trigger a compilation failure on
118
+ // an error condition.
119
+ struct CheckOnFailure {
120
+ template <typename T>
121
+ static T HandleFailure() {
122
+ #if defined(_MSC_VER)
123
+ __debugbreak();
124
+ #elif defined(__GNUC__) || defined(__clang__)
125
+ __builtin_trap();
126
+ #else
127
+ ((void)(*(volatile char*)0 = 0));
128
+ #endif
129
+ return T();
130
+ }
131
+ };
132
+
133
+ enum IntegerRepresentation {
134
+ INTEGER_REPRESENTATION_UNSIGNED,
135
+ INTEGER_REPRESENTATION_SIGNED
136
+ };
137
+
138
+ // A range for a given nunmeric Src type is contained for a given numeric Dst
139
+ // type if both numeric_limits<Src>::max() <= numeric_limits<Dst>::max() and
140
+ // numeric_limits<Src>::lowest() >= numeric_limits<Dst>::lowest() are true.
141
+ // We implement this as template specializations rather than simple static
142
+ // comparisons to ensure type correctness in our comparisons.
143
+ enum NumericRangeRepresentation {
144
+ NUMERIC_RANGE_NOT_CONTAINED,
145
+ NUMERIC_RANGE_CONTAINED
146
+ };
147
+
148
+ // Helper templates to statically determine if our destination type can contain
149
+ // maximum and minimum values represented by the source type.
150
+
151
+ template <typename Dst, typename Src,
152
+ IntegerRepresentation DstSign = std::is_signed<Dst>::value
153
+ ? INTEGER_REPRESENTATION_SIGNED
154
+ : INTEGER_REPRESENTATION_UNSIGNED,
155
+ IntegerRepresentation SrcSign = std::is_signed<Src>::value
156
+ ? INTEGER_REPRESENTATION_SIGNED
157
+ : INTEGER_REPRESENTATION_UNSIGNED>
158
+ struct StaticDstRangeRelationToSrcRange;
159
+
160
+ // Same sign: Dst is guaranteed to contain Src only if its range is equal or
161
+ // larger.
162
+ template <typename Dst, typename Src, IntegerRepresentation Sign>
163
+ struct StaticDstRangeRelationToSrcRange<Dst, Src, Sign, Sign> {
164
+ static const NumericRangeRepresentation value =
165
+ MaxExponent<Dst>::value >= MaxExponent<Src>::value
166
+ ? NUMERIC_RANGE_CONTAINED
167
+ : NUMERIC_RANGE_NOT_CONTAINED;
168
+ };
169
+
170
+ // Unsigned to signed: Dst is guaranteed to contain source only if its range is
171
+ // larger.
172
+ template <typename Dst, typename Src>
173
+ struct StaticDstRangeRelationToSrcRange<Dst,
174
+ Src,
175
+ INTEGER_REPRESENTATION_SIGNED,
176
+ INTEGER_REPRESENTATION_UNSIGNED> {
177
+ static const NumericRangeRepresentation value =
178
+ MaxExponent<Dst>::value > MaxExponent<Src>::value
179
+ ? NUMERIC_RANGE_CONTAINED
180
+ : NUMERIC_RANGE_NOT_CONTAINED;
181
+ };
182
+
183
+ // Signed to unsigned: Dst cannot be statically determined to contain Src.
184
+ template <typename Dst, typename Src>
185
+ struct StaticDstRangeRelationToSrcRange<Dst,
186
+ Src,
187
+ INTEGER_REPRESENTATION_UNSIGNED,
188
+ INTEGER_REPRESENTATION_SIGNED> {
189
+ static const NumericRangeRepresentation value = NUMERIC_RANGE_NOT_CONTAINED;
190
+ };
191
+
192
+ // This class wraps the range constraints as separate booleans so the compiler
193
+ // can identify constants and eliminate unused code paths.
194
+ class RangeCheck {
195
+ public:
196
+ constexpr RangeCheck(bool is_in_lower_bound, bool is_in_upper_bound)
197
+ : is_underflow_(!is_in_lower_bound), is_overflow_(!is_in_upper_bound) {}
198
+ constexpr RangeCheck() : is_underflow_(0), is_overflow_(0) {}
199
+ constexpr bool IsValid() const { return !is_overflow_ && !is_underflow_; }
200
+ constexpr bool IsInvalid() const { return is_overflow_ && is_underflow_; }
201
+ constexpr bool IsOverflow() const { return is_overflow_ && !is_underflow_; }
202
+ constexpr bool IsUnderflow() const { return !is_overflow_ && is_underflow_; }
203
+ constexpr bool IsOverflowFlagSet() const { return is_overflow_; }
204
+ constexpr bool IsUnderflowFlagSet() const { return is_underflow_; }
205
+ constexpr bool operator==(const RangeCheck rhs) const {
206
+ return is_underflow_ == rhs.is_underflow_ &&
207
+ is_overflow_ == rhs.is_overflow_;
208
+ }
209
+ constexpr bool operator!=(const RangeCheck rhs) const {
210
+ return !(*this == rhs);
211
+ }
212
+
213
+ private:
214
+ // Do not change the order of these member variables. The integral conversion
215
+ // optimization depends on this exact order.
216
+ const bool is_underflow_;
217
+ const bool is_overflow_;
218
+ };
219
+
220
+ // The following helper template addresses a corner case in range checks for
221
+ // conversion from a floating-point type to an integral type of smaller range
222
+ // but larger precision (e.g. float -> unsigned). The problem is as follows:
223
+ // 1. Integral maximum is always one less than a power of two, so it must be
224
+ // truncated to fit the mantissa of the floating point. The direction of
225
+ // rounding is implementation defined, but by default it's always IEEE
226
+ // floats, which round to nearest and thus result in a value of larger
227
+ // magnitude than the integral value.
228
+ // Example: float f = UINT_MAX; // f is 4294967296f but UINT_MAX
229
+ // // is 4294967295u.
230
+ // 2. If the floating point value is equal to the promoted integral maximum
231
+ // value, a range check will erroneously pass.
232
+ // Example: (4294967296f <= 4294967295u) // This is true due to a precision
233
+ // // loss in rounding up to float.
234
+ // 3. When the floating point value is then converted to an integral, the
235
+ // resulting value is out of range for the target integral type and
236
+ // thus is implementation defined.
237
+ // Example: unsigned u = (float)INT_MAX; // u will typically overflow to 0.
238
+ // To fix this bug we manually truncate the maximum value when the destination
239
+ // type is an integral of larger precision than the source floating-point type,
240
+ // such that the resulting maximum is represented exactly as a floating point.
241
+ template <typename Dst, typename Src, template <typename> class Bounds>
242
+ struct NarrowingRange {
243
+ using SrcLimits = std::numeric_limits<Src>;
244
+ using DstLimits = typename std::numeric_limits<Dst>;
245
+
246
+ // Computes the mask required to make an accurate comparison between types.
247
+ static const int kShift =
248
+ (MaxExponent<Src>::value > MaxExponent<Dst>::value &&
249
+ SrcLimits::digits < DstLimits::digits)
250
+ ? (DstLimits::digits - SrcLimits::digits)
251
+ : 0;
252
+ template <typename T, typename std::enable_if<
253
+ std::is_integral<T>::value>::type* = nullptr>
254
+
255
+ // Masks out the integer bits that are beyond the precision of the
256
+ // intermediate type used for comparison.
257
+ static constexpr T Adjust(T value) {
258
+ static_assert(std::is_same<T, Dst>::value, "");
259
+ static_assert(kShift < DstLimits::digits, "");
260
+ return static_cast<T>(
261
+ ConditionalNegate(SafeUnsignedAbs(value) & ~((T(1) << kShift) - T(1)),
262
+ IsValueNegative(value)));
263
+ }
264
+
265
+ template <typename T, typename std::enable_if<
266
+ std::is_floating_point<T>::value>::type* = nullptr>
267
+ static constexpr T Adjust(T value) {
268
+ static_assert(std::is_same<T, Dst>::value, "");
269
+ static_assert(kShift == 0, "");
270
+ return value;
271
+ }
272
+
273
+ static constexpr Dst max() { return Adjust(Bounds<Dst>::max()); }
274
+ static constexpr Dst lowest() { return Adjust(Bounds<Dst>::lowest()); }
275
+ };
276
+
277
+ template <typename Dst, typename Src, template <typename> class Bounds,
278
+ IntegerRepresentation DstSign = std::is_signed<Dst>::value
279
+ ? INTEGER_REPRESENTATION_SIGNED
280
+ : INTEGER_REPRESENTATION_UNSIGNED,
281
+ IntegerRepresentation SrcSign = std::is_signed<Src>::value
282
+ ? INTEGER_REPRESENTATION_SIGNED
283
+ : INTEGER_REPRESENTATION_UNSIGNED,
284
+ NumericRangeRepresentation DstRange =
285
+ StaticDstRangeRelationToSrcRange<Dst, Src>::value>
286
+ struct DstRangeRelationToSrcRangeImpl;
287
+
288
+ // The following templates are for ranges that must be verified at runtime. We
289
+ // split it into checks based on signedness to avoid confusing casts and
290
+ // compiler warnings on signed an unsigned comparisons.
291
+
292
+ // Same sign narrowing: The range is contained for normal limits.
293
+ template <typename Dst, typename Src, template <typename> class Bounds,
294
+ IntegerRepresentation DstSign, IntegerRepresentation SrcSign>
295
+ struct DstRangeRelationToSrcRangeImpl<Dst, Src, Bounds, DstSign, SrcSign,
296
+ NUMERIC_RANGE_CONTAINED> {
297
+ static constexpr RangeCheck Check(Src value) {
298
+ using SrcLimits = std::numeric_limits<Src>;
299
+ using DstLimits = NarrowingRange<Dst, Src, Bounds>;
300
+ return RangeCheck(
301
+ static_cast<Dst>(SrcLimits::lowest()) >= DstLimits::lowest() ||
302
+ static_cast<Dst>(value) >= DstLimits::lowest(),
303
+ static_cast<Dst>(SrcLimits::max()) <= DstLimits::max() ||
304
+ static_cast<Dst>(value) <= DstLimits::max());
305
+ }
306
+ };
307
+
308
+ // Signed to signed narrowing: Both the upper and lower boundaries may be
309
+ // exceeded for standard limits.
310
+ template <typename Dst, typename Src, template <typename> class Bounds>
311
+ struct DstRangeRelationToSrcRangeImpl<
312
+ Dst, Src, Bounds, INTEGER_REPRESENTATION_SIGNED,
313
+ INTEGER_REPRESENTATION_SIGNED, NUMERIC_RANGE_NOT_CONTAINED> {
314
+ static constexpr RangeCheck Check(Src value) {
315
+ using DstLimits = NarrowingRange<Dst, Src, Bounds>;
316
+ return RangeCheck(value >= DstLimits::lowest(), value <= DstLimits::max());
317
+ }
318
+ };
319
+
320
+ // Unsigned to unsigned narrowing: Only the upper bound can be exceeded for
321
+ // standard limits.
322
+ template <typename Dst, typename Src, template <typename> class Bounds>
323
+ struct DstRangeRelationToSrcRangeImpl<
324
+ Dst, Src, Bounds, INTEGER_REPRESENTATION_UNSIGNED,
325
+ INTEGER_REPRESENTATION_UNSIGNED, NUMERIC_RANGE_NOT_CONTAINED> {
326
+ static constexpr RangeCheck Check(Src value) {
327
+ using DstLimits = NarrowingRange<Dst, Src, Bounds>;
328
+ return RangeCheck(
329
+ DstLimits::lowest() == Dst(0) || value >= DstLimits::lowest(),
330
+ value <= DstLimits::max());
331
+ }
332
+ };
333
+
334
+ // Unsigned to signed: Only the upper bound can be exceeded for standard limits.
335
+ template <typename Dst, typename Src, template <typename> class Bounds>
336
+ struct DstRangeRelationToSrcRangeImpl<
337
+ Dst, Src, Bounds, INTEGER_REPRESENTATION_SIGNED,
338
+ INTEGER_REPRESENTATION_UNSIGNED, NUMERIC_RANGE_NOT_CONTAINED> {
339
+ static constexpr RangeCheck Check(Src value) {
340
+ using DstLimits = NarrowingRange<Dst, Src, Bounds>;
341
+ using Promotion = decltype(Src() + Dst());
342
+ return RangeCheck(DstLimits::lowest() <= Dst(0) ||
343
+ static_cast<Promotion>(value) >=
344
+ static_cast<Promotion>(DstLimits::lowest()),
345
+ static_cast<Promotion>(value) <=
346
+ static_cast<Promotion>(DstLimits::max()));
347
+ }
348
+ };
349
+
350
+ // Signed to unsigned: The upper boundary may be exceeded for a narrower Dst,
351
+ // and any negative value exceeds the lower boundary for standard limits.
352
+ template <typename Dst, typename Src, template <typename> class Bounds>
353
+ struct DstRangeRelationToSrcRangeImpl<
354
+ Dst, Src, Bounds, INTEGER_REPRESENTATION_UNSIGNED,
355
+ INTEGER_REPRESENTATION_SIGNED, NUMERIC_RANGE_NOT_CONTAINED> {
356
+ static constexpr RangeCheck Check(Src value) {
357
+ using SrcLimits = std::numeric_limits<Src>;
358
+ using DstLimits = NarrowingRange<Dst, Src, Bounds>;
359
+ using Promotion = decltype(Src() + Dst());
360
+ bool ge_zero = false;
361
+ // Converting floating-point to integer will discard fractional part, so
362
+ // values in (-1.0, -0.0) will truncate to 0 and fit in Dst.
363
+ if (std::is_floating_point<Src>::value) {
364
+ ge_zero = value > Src(-1);
365
+ } else {
366
+ ge_zero = value >= Src(0);
367
+ }
368
+ return RangeCheck(
369
+ ge_zero && (DstLimits::lowest() == 0 ||
370
+ static_cast<Dst>(value) >= DstLimits::lowest()),
371
+ static_cast<Promotion>(SrcLimits::max()) <=
372
+ static_cast<Promotion>(DstLimits::max()) ||
373
+ static_cast<Promotion>(value) <=
374
+ static_cast<Promotion>(DstLimits::max()));
375
+ }
376
+ };
377
+
378
+ // Simple wrapper for statically checking if a type's range is contained.
379
+ template <typename Dst, typename Src>
380
+ struct IsTypeInRangeForNumericType {
381
+ static const bool value = StaticDstRangeRelationToSrcRange<Dst, Src>::value ==
382
+ NUMERIC_RANGE_CONTAINED;
383
+ };
384
+
385
+ template <typename Dst, template <typename> class Bounds = std::numeric_limits,
386
+ typename Src>
387
+ constexpr RangeCheck DstRangeRelationToSrcRange(Src value) {
388
+ static_assert(std::is_arithmetic<Src>::value, "Argument must be numeric.");
389
+ static_assert(std::is_arithmetic<Dst>::value, "Result must be numeric.");
390
+ static_assert(Bounds<Dst>::lowest() < Bounds<Dst>::max(), "");
391
+ return DstRangeRelationToSrcRangeImpl<Dst, Src, Bounds>::Check(value);
392
+ }
393
+
394
+ // Integer promotion templates used by the portable checked integer arithmetic.
395
+ template <size_t Size, bool IsSigned>
396
+ struct IntegerForDigitsAndSign;
397
+
398
+ #define INTEGER_FOR_DIGITS_AND_SIGN(I) \
399
+ template <> \
400
+ struct IntegerForDigitsAndSign<IntegerBitsPlusSign<I>::value, \
401
+ std::is_signed<I>::value> { \
402
+ using type = I; \
403
+ }
404
+
405
+ INTEGER_FOR_DIGITS_AND_SIGN(int8_t);
406
+ INTEGER_FOR_DIGITS_AND_SIGN(uint8_t);
407
+ INTEGER_FOR_DIGITS_AND_SIGN(int16_t);
408
+ INTEGER_FOR_DIGITS_AND_SIGN(uint16_t);
409
+ INTEGER_FOR_DIGITS_AND_SIGN(int32_t);
410
+ INTEGER_FOR_DIGITS_AND_SIGN(uint32_t);
411
+ INTEGER_FOR_DIGITS_AND_SIGN(int64_t);
412
+ INTEGER_FOR_DIGITS_AND_SIGN(uint64_t);
413
+ #undef INTEGER_FOR_DIGITS_AND_SIGN
414
+
415
+ // WARNING: We have no IntegerForSizeAndSign<16, *>. If we ever add one to
416
+ // support 128-bit math, then the ArithmeticPromotion template below will need
417
+ // to be updated (or more likely replaced with a decltype expression).
418
+ static_assert(IntegerBitsPlusSign<intmax_t>::value == 64,
419
+ "Max integer size not supported for this toolchain.");
420
+
421
+ template <typename Integer, bool IsSigned = std::is_signed<Integer>::value>
422
+ struct TwiceWiderInteger {
423
+ using type =
424
+ typename IntegerForDigitsAndSign<IntegerBitsPlusSign<Integer>::value * 2,
425
+ IsSigned>::type;
426
+ };
427
+
428
+ enum ArithmeticPromotionCategory {
429
+ LEFT_PROMOTION, // Use the type of the left-hand argument.
430
+ RIGHT_PROMOTION // Use the type of the right-hand argument.
431
+ };
432
+
433
+ // Determines the type that can represent the largest positive value.
434
+ template <typename Lhs, typename Rhs,
435
+ ArithmeticPromotionCategory Promotion =
436
+ (MaxExponent<Lhs>::value > MaxExponent<Rhs>::value)
437
+ ? LEFT_PROMOTION
438
+ : RIGHT_PROMOTION>
439
+ struct MaxExponentPromotion;
440
+
441
+ template <typename Lhs, typename Rhs>
442
+ struct MaxExponentPromotion<Lhs, Rhs, LEFT_PROMOTION> {
443
+ using type = Lhs;
444
+ };
445
+
446
+ template <typename Lhs, typename Rhs>
447
+ struct MaxExponentPromotion<Lhs, Rhs, RIGHT_PROMOTION> {
448
+ using type = Rhs;
449
+ };
450
+
451
+ // Determines the type that can represent the lowest arithmetic value.
452
+ template <typename Lhs, typename Rhs,
453
+ ArithmeticPromotionCategory Promotion =
454
+ std::is_signed<Lhs>::value
455
+ ? (std::is_signed<Rhs>::value
456
+ ? (MaxExponent<Lhs>::value > MaxExponent<Rhs>::value
457
+ ? LEFT_PROMOTION
458
+ : RIGHT_PROMOTION)
459
+ : LEFT_PROMOTION)
460
+ : (std::is_signed<Rhs>::value
461
+ ? RIGHT_PROMOTION
462
+ : (MaxExponent<Lhs>::value < MaxExponent<Rhs>::value
463
+ ? LEFT_PROMOTION
464
+ : RIGHT_PROMOTION))>
465
+ struct LowestValuePromotion;
466
+
467
+ template <typename Lhs, typename Rhs>
468
+ struct LowestValuePromotion<Lhs, Rhs, LEFT_PROMOTION> {
469
+ using type = Lhs;
470
+ };
471
+
472
+ template <typename Lhs, typename Rhs>
473
+ struct LowestValuePromotion<Lhs, Rhs, RIGHT_PROMOTION> {
474
+ using type = Rhs;
475
+ };
476
+
477
+ // Determines the type that is best able to represent an arithmetic result.
478
+ template <
479
+ typename Lhs, typename Rhs = Lhs,
480
+ bool is_intmax_type =
481
+ std::is_integral<typename MaxExponentPromotion<Lhs, Rhs>::type>::value&&
482
+ IntegerBitsPlusSign<typename MaxExponentPromotion<Lhs, Rhs>::type>::
483
+ value == IntegerBitsPlusSign<intmax_t>::value,
484
+ bool is_max_exponent =
485
+ StaticDstRangeRelationToSrcRange<
486
+ typename MaxExponentPromotion<Lhs, Rhs>::type, Lhs>::value ==
487
+ NUMERIC_RANGE_CONTAINED&& StaticDstRangeRelationToSrcRange<
488
+ typename MaxExponentPromotion<Lhs, Rhs>::type, Rhs>::value ==
489
+ NUMERIC_RANGE_CONTAINED>
490
+ struct BigEnoughPromotion;
491
+
492
+ // The side with the max exponent is big enough.
493
+ template <typename Lhs, typename Rhs, bool is_intmax_type>
494
+ struct BigEnoughPromotion<Lhs, Rhs, is_intmax_type, true> {
495
+ using type = typename MaxExponentPromotion<Lhs, Rhs>::type;
496
+ static const bool is_contained = true;
497
+ };
498
+
499
+ // We can use a twice wider type to fit.
500
+ template <typename Lhs, typename Rhs>
501
+ struct BigEnoughPromotion<Lhs, Rhs, false, false> {
502
+ using type =
503
+ typename TwiceWiderInteger<typename MaxExponentPromotion<Lhs, Rhs>::type,
504
+ std::is_signed<Lhs>::value ||
505
+ std::is_signed<Rhs>::value>::type;
506
+ static const bool is_contained = true;
507
+ };
508
+
509
+ // No type is large enough.
510
+ template <typename Lhs, typename Rhs>
511
+ struct BigEnoughPromotion<Lhs, Rhs, true, false> {
512
+ using type = typename MaxExponentPromotion<Lhs, Rhs>::type;
513
+ static const bool is_contained = false;
514
+ };
515
+
516
+ // We can statically check if operations on the provided types can wrap, so we
517
+ // can skip the checked operations if they're not needed. So, for an integer we
518
+ // care if the destination type preserves the sign and is twice the width of
519
+ // the source.
520
+ template <typename T, typename Lhs, typename Rhs = Lhs>
521
+ struct IsIntegerArithmeticSafe {
522
+ static const bool value =
523
+ !std::is_floating_point<T>::value &&
524
+ !std::is_floating_point<Lhs>::value &&
525
+ !std::is_floating_point<Rhs>::value &&
526
+ std::is_signed<T>::value >= std::is_signed<Lhs>::value &&
527
+ IntegerBitsPlusSign<T>::value >= (2 * IntegerBitsPlusSign<Lhs>::value) &&
528
+ std::is_signed<T>::value >= std::is_signed<Rhs>::value &&
529
+ IntegerBitsPlusSign<T>::value >= (2 * IntegerBitsPlusSign<Rhs>::value);
530
+ };
531
+
532
+ // Promotes to a type that can represent any possible result of a binary
533
+ // arithmetic operation with the source types.
534
+ template <typename Lhs, typename Rhs,
535
+ bool is_promotion_possible = IsIntegerArithmeticSafe<
536
+ typename std::conditional<std::is_signed<Lhs>::value ||
537
+ std::is_signed<Rhs>::value,
538
+ intmax_t, uintmax_t>::type,
539
+ typename MaxExponentPromotion<Lhs, Rhs>::type>::value>
540
+ struct FastIntegerArithmeticPromotion;
541
+
542
+ template <typename Lhs, typename Rhs>
543
+ struct FastIntegerArithmeticPromotion<Lhs, Rhs, true> {
544
+ using type =
545
+ typename TwiceWiderInteger<typename MaxExponentPromotion<Lhs, Rhs>::type,
546
+ std::is_signed<Lhs>::value ||
547
+ std::is_signed<Rhs>::value>::type;
548
+ static_assert(IsIntegerArithmeticSafe<type, Lhs, Rhs>::value, "");
549
+ static const bool is_contained = true;
550
+ };
551
+
552
+ template <typename Lhs, typename Rhs>
553
+ struct FastIntegerArithmeticPromotion<Lhs, Rhs, false> {
554
+ using type = typename BigEnoughPromotion<Lhs, Rhs>::type;
555
+ static const bool is_contained = false;
556
+ };
557
+
558
+ // Extracts the underlying type from an enum.
559
+ template <typename T, bool is_enum = std::is_enum<T>::value>
560
+ struct ArithmeticOrUnderlyingEnum;
561
+
562
+ template <typename T>
563
+ struct ArithmeticOrUnderlyingEnum<T, true> {
564
+ using type = typename std::underlying_type<T>::type;
565
+ static const bool value = std::is_arithmetic<type>::value;
566
+ };
567
+
568
+ template <typename T>
569
+ struct ArithmeticOrUnderlyingEnum<T, false> {
570
+ using type = T;
571
+ static const bool value = std::is_arithmetic<type>::value;
572
+ };
573
+
574
+ // The following are helper templates used in the CheckedNumeric class.
575
+ template <typename T>
576
+ class CheckedNumeric;
577
+
578
+ template <typename T>
579
+ class ClampedNumeric;
580
+
581
+ template <typename T>
582
+ class StrictNumeric;
583
+
584
+ // Used to treat CheckedNumeric and arithmetic underlying types the same.
585
+ template <typename T>
586
+ struct UnderlyingType {
587
+ using type = typename ArithmeticOrUnderlyingEnum<T>::type;
588
+ static const bool is_numeric = std::is_arithmetic<type>::value;
589
+ static const bool is_checked = false;
590
+ static const bool is_clamped = false;
591
+ static const bool is_strict = false;
592
+ };
593
+
594
+ template <typename T>
595
+ struct UnderlyingType<CheckedNumeric<T>> {
596
+ using type = T;
597
+ static const bool is_numeric = true;
598
+ static const bool is_checked = true;
599
+ static const bool is_clamped = false;
600
+ static const bool is_strict = false;
601
+ };
602
+
603
+ template <typename T>
604
+ struct UnderlyingType<ClampedNumeric<T>> {
605
+ using type = T;
606
+ static const bool is_numeric = true;
607
+ static const bool is_checked = false;
608
+ static const bool is_clamped = true;
609
+ static const bool is_strict = false;
610
+ };
611
+
612
+ template <typename T>
613
+ struct UnderlyingType<StrictNumeric<T>> {
614
+ using type = T;
615
+ static const bool is_numeric = true;
616
+ static const bool is_checked = false;
617
+ static const bool is_clamped = false;
618
+ static const bool is_strict = true;
619
+ };
620
+
621
+ template <typename L, typename R>
622
+ struct IsCheckedOp {
623
+ static const bool value =
624
+ UnderlyingType<L>::is_numeric && UnderlyingType<R>::is_numeric &&
625
+ (UnderlyingType<L>::is_checked || UnderlyingType<R>::is_checked);
626
+ };
627
+
628
+ template <typename L, typename R>
629
+ struct IsClampedOp {
630
+ static const bool value =
631
+ UnderlyingType<L>::is_numeric && UnderlyingType<R>::is_numeric &&
632
+ (UnderlyingType<L>::is_clamped || UnderlyingType<R>::is_clamped) &&
633
+ !(UnderlyingType<L>::is_checked || UnderlyingType<R>::is_checked);
634
+ };
635
+
636
+ template <typename L, typename R>
637
+ struct IsStrictOp {
638
+ static const bool value =
639
+ UnderlyingType<L>::is_numeric && UnderlyingType<R>::is_numeric &&
640
+ (UnderlyingType<L>::is_strict || UnderlyingType<R>::is_strict) &&
641
+ !(UnderlyingType<L>::is_checked || UnderlyingType<R>::is_checked) &&
642
+ !(UnderlyingType<L>::is_clamped || UnderlyingType<R>::is_clamped);
643
+ };
644
+
645
+ // as_signed<> returns the supplied integral value (or integral castable
646
+ // Numeric template) cast as a signed integral of equivalent precision.
647
+ // I.e. it's mostly an alias for: static_cast<std::make_signed<T>::type>(t)
648
+ template <typename Src>
649
+ constexpr typename std::make_signed<
650
+ typename base::internal::UnderlyingType<Src>::type>::type
651
+ as_signed(const Src value) {
652
+ static_assert(std::is_integral<decltype(as_signed(value))>::value,
653
+ "Argument must be a signed or unsigned integer type.");
654
+ return static_cast<decltype(as_signed(value))>(value);
655
+ }
656
+
657
+ // as_unsigned<> returns the supplied integral value (or integral castable
658
+ // Numeric template) cast as an unsigned integral of equivalent precision.
659
+ // I.e. it's mostly an alias for: static_cast<std::make_unsigned<T>::type>(t)
660
+ template <typename Src>
661
+ constexpr typename std::make_unsigned<
662
+ typename base::internal::UnderlyingType<Src>::type>::type
663
+ as_unsigned(const Src value) {
664
+ static_assert(std::is_integral<decltype(as_unsigned(value))>::value,
665
+ "Argument must be a signed or unsigned integer type.");
666
+ return static_cast<decltype(as_unsigned(value))>(value);
667
+ }
668
+
669
+ template <typename L, typename R>
670
+ constexpr bool IsLessImpl(const L lhs, const R rhs, const RangeCheck l_range,
671
+ const RangeCheck r_range) {
672
+ return l_range.IsUnderflow() || r_range.IsOverflow() ||
673
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) <
674
+ static_cast<decltype(lhs + rhs)>(rhs));
675
+ }
676
+
677
+ template <typename L, typename R>
678
+ struct IsLess {
679
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
680
+ "Types must be numeric.");
681
+ static constexpr bool Test(const L lhs, const R rhs) {
682
+ return IsLessImpl(lhs, rhs, DstRangeRelationToSrcRange<R>(lhs),
683
+ DstRangeRelationToSrcRange<L>(rhs));
684
+ }
685
+ };
686
+
687
+ template <typename L, typename R>
688
+ constexpr bool IsLessOrEqualImpl(const L lhs, const R rhs,
689
+ const RangeCheck l_range,
690
+ const RangeCheck r_range) {
691
+ return l_range.IsUnderflow() || r_range.IsOverflow() ||
692
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) <=
693
+ static_cast<decltype(lhs + rhs)>(rhs));
694
+ }
695
+
696
+ template <typename L, typename R>
697
+ struct IsLessOrEqual {
698
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
699
+ "Types must be numeric.");
700
+ static constexpr bool Test(const L lhs, const R rhs) {
701
+ return IsLessOrEqualImpl(lhs, rhs, DstRangeRelationToSrcRange<R>(lhs),
702
+ DstRangeRelationToSrcRange<L>(rhs));
703
+ }
704
+ };
705
+
706
+ template <typename L, typename R>
707
+ constexpr bool IsGreaterImpl(const L lhs, const R rhs, const RangeCheck l_range,
708
+ const RangeCheck r_range) {
709
+ return l_range.IsOverflow() || r_range.IsUnderflow() ||
710
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) >
711
+ static_cast<decltype(lhs + rhs)>(rhs));
712
+ }
713
+
714
+ template <typename L, typename R>
715
+ struct IsGreater {
716
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
717
+ "Types must be numeric.");
718
+ static constexpr bool Test(const L lhs, const R rhs) {
719
+ return IsGreaterImpl(lhs, rhs, DstRangeRelationToSrcRange<R>(lhs),
720
+ DstRangeRelationToSrcRange<L>(rhs));
721
+ }
722
+ };
723
+
724
+ template <typename L, typename R>
725
+ constexpr bool IsGreaterOrEqualImpl(const L lhs, const R rhs,
726
+ const RangeCheck l_range,
727
+ const RangeCheck r_range) {
728
+ return l_range.IsOverflow() || r_range.IsUnderflow() ||
729
+ (l_range == r_range && static_cast<decltype(lhs + rhs)>(lhs) >=
730
+ static_cast<decltype(lhs + rhs)>(rhs));
731
+ }
732
+
733
+ template <typename L, typename R>
734
+ struct IsGreaterOrEqual {
735
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
736
+ "Types must be numeric.");
737
+ static constexpr bool Test(const L lhs, const R rhs) {
738
+ return IsGreaterOrEqualImpl(lhs, rhs, DstRangeRelationToSrcRange<R>(lhs),
739
+ DstRangeRelationToSrcRange<L>(rhs));
740
+ }
741
+ };
742
+
743
+ template <typename L, typename R>
744
+ struct IsEqual {
745
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
746
+ "Types must be numeric.");
747
+ static constexpr bool Test(const L lhs, const R rhs) {
748
+ return DstRangeRelationToSrcRange<R>(lhs) ==
749
+ DstRangeRelationToSrcRange<L>(rhs) &&
750
+ static_cast<decltype(lhs + rhs)>(lhs) ==
751
+ static_cast<decltype(lhs + rhs)>(rhs);
752
+ }
753
+ };
754
+
755
+ template <typename L, typename R>
756
+ struct IsNotEqual {
757
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
758
+ "Types must be numeric.");
759
+ static constexpr bool Test(const L lhs, const R rhs) {
760
+ return DstRangeRelationToSrcRange<R>(lhs) !=
761
+ DstRangeRelationToSrcRange<L>(rhs) ||
762
+ static_cast<decltype(lhs + rhs)>(lhs) !=
763
+ static_cast<decltype(lhs + rhs)>(rhs);
764
+ }
765
+ };
766
+
767
+ // These perform the actual math operations on the CheckedNumerics.
768
+ // Binary arithmetic operations.
769
+ template <template <typename, typename> class C, typename L, typename R>
770
+ constexpr bool SafeCompare(const L lhs, const R rhs) {
771
+ static_assert(std::is_arithmetic<L>::value && std::is_arithmetic<R>::value,
772
+ "Types must be numeric.");
773
+ using Promotion = BigEnoughPromotion<L, R>;
774
+ using BigType = typename Promotion::type;
775
+ return Promotion::is_contained
776
+ // Force to a larger type for speed if both are contained.
777
+ ? C<BigType, BigType>::Test(
778
+ static_cast<BigType>(static_cast<L>(lhs)),
779
+ static_cast<BigType>(static_cast<R>(rhs)))
780
+ // Let the template functions figure it out for mixed types.
781
+ : C<L, R>::Test(lhs, rhs);
782
+ }
783
+
784
+ template <typename Dst, typename Src>
785
+ constexpr bool IsMaxInRangeForNumericType() {
786
+ return IsGreaterOrEqual<Dst, Src>::Test(std::numeric_limits<Dst>::max(),
787
+ std::numeric_limits<Src>::max());
788
+ }
789
+
790
+ template <typename Dst, typename Src>
791
+ constexpr bool IsMinInRangeForNumericType() {
792
+ return IsLessOrEqual<Dst, Src>::Test(std::numeric_limits<Dst>::lowest(),
793
+ std::numeric_limits<Src>::lowest());
794
+ }
795
+
796
+ template <typename Dst, typename Src>
797
+ constexpr Dst CommonMax() {
798
+ return !IsMaxInRangeForNumericType<Dst, Src>()
799
+ ? Dst(std::numeric_limits<Dst>::max())
800
+ : Dst(std::numeric_limits<Src>::max());
801
+ }
802
+
803
+ template <typename Dst, typename Src>
804
+ constexpr Dst CommonMin() {
805
+ return !IsMinInRangeForNumericType<Dst, Src>()
806
+ ? Dst(std::numeric_limits<Dst>::lowest())
807
+ : Dst(std::numeric_limits<Src>::lowest());
808
+ }
809
+
810
+ // This is a wrapper to generate return the max or min for a supplied type.
811
+ // If the argument is false, the returned value is the maximum. If true the
812
+ // returned value is the minimum.
813
+ template <typename Dst, typename Src = Dst>
814
+ constexpr Dst CommonMaxOrMin(bool is_min) {
815
+ return is_min ? CommonMin<Dst, Src>() : CommonMax<Dst, Src>();
816
+ }
817
+
818
+ } // namespace internal
819
+ } // namespace base
820
+ } // namespace v8
821
+
822
+ #endif // V8_BASE_SAFE_CONVERSIONS_IMPL_H_