@encharm/cws 4.4.1 → 4.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  2. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  3. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  4. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  5. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  6. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  7. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  8. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  9. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  10. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  11. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  12. package/package.json +1 -1
  13. package/src/Addon.h +8 -23
  14. package/src/Socket.h +0 -1
  15. package/src/headers/22/acorn_version.h +6 -0
  16. package/src/headers/22/aliased_buffer-inl.h +243 -0
  17. package/src/headers/22/aliased_buffer.h +206 -0
  18. package/src/headers/{18 → 22}/async_wrap-inl.h +8 -6
  19. package/src/headers/{18 → 22}/async_wrap.h +65 -59
  20. package/src/headers/{16 → 22}/base_object-inl.h +57 -117
  21. package/src/headers/{18 → 22}/base_object.h +58 -30
  22. package/src/headers/22/base_object_types.h +74 -0
  23. package/src/headers/22/blob_serializer_deserializer-inl.h +385 -0
  24. package/src/headers/22/blob_serializer_deserializer.h +132 -0
  25. package/src/headers/{16 → 22}/callback_queue.h +1 -0
  26. package/src/headers/{16 → 22}/cares_wrap.h +27 -20
  27. package/src/headers/22/cjs_module_lexer_version.h +6 -0
  28. package/src/headers/22/cleanup_queue-inl.h +62 -0
  29. package/src/headers/22/cleanup_queue.h +85 -0
  30. package/src/headers/22/compile_cache.h +104 -0
  31. package/src/headers/{18 → 22}/crypto/crypto_clienthello.h +1 -1
  32. package/src/headers/{18 → 22}/crypto/crypto_context.h +31 -7
  33. package/src/headers/{18 → 22}/crypto/crypto_keys.h +118 -148
  34. package/src/headers/{18 → 22}/crypto/crypto_tls.h +20 -5
  35. package/src/headers/{18 → 22}/crypto/crypto_util.h +219 -263
  36. package/src/headers/22/crypto/ncrypto.h +752 -0
  37. package/src/headers/{16 → 22}/debug_utils-inl.h +15 -7
  38. package/src/headers/{18 → 22}/debug_utils.h +25 -19
  39. package/src/headers/22/encoding_binding.h +59 -0
  40. package/src/headers/{14 → 22}/env-inl.h +276 -409
  41. package/src/headers/22/env.h +1266 -0
  42. package/src/headers/22/env_properties.h +497 -0
  43. package/src/headers/{18 → 22}/handle_wrap.h +2 -0
  44. package/src/headers/{18 → 22}/histogram.h +88 -48
  45. package/src/headers/{16 → 22}/inspector_agent.h +17 -1
  46. package/src/headers/{16 → 22}/inspector_profiler.h +15 -13
  47. package/src/headers/{18 → 22}/js_native_api.h +78 -30
  48. package/src/headers/{18 → 22}/js_native_api_types.h +46 -1
  49. package/src/headers/{18 → 22}/js_native_api_v8.h +206 -161
  50. package/src/headers/{18 → 22}/js_native_api_v8_internals.h +6 -0
  51. package/src/headers/22/json_parser.h +40 -0
  52. package/src/headers/{16 → 22}/json_utils.h +19 -8
  53. package/src/headers/{18 → 22}/memory_tracker-inl.h +16 -13
  54. package/src/headers/{14 → 22}/memory_tracker.h +13 -8
  55. package/src/headers/{16 → 22}/module_wrap.h +49 -19
  56. package/src/headers/22/ncrypto/ncrypto.h +752 -0
  57. package/src/headers/{18 → 22}/node.h +465 -68
  58. package/src/headers/{18 → 22}/node_api.h +66 -81
  59. package/src/headers/{18 → 22}/node_api_internals.h +8 -4
  60. package/src/headers/{18 → 22}/node_api_types.h +5 -0
  61. package/src/headers/22/node_binding.h +154 -0
  62. package/src/headers/{18 → 22}/node_blob.h +46 -78
  63. package/src/headers/{18 → 22}/node_bob-inl.h +1 -2
  64. package/src/headers/{18 → 22}/node_bob.h +2 -6
  65. package/src/headers/{18 → 22}/node_buffer.h +1 -1
  66. package/src/headers/22/node_builtins.h +220 -0
  67. package/src/headers/{18 → 22}/node_constants.h +3 -5
  68. package/src/headers/22/node_context_data.h +168 -0
  69. package/src/headers/22/node_contextify.h +199 -0
  70. package/src/headers/{16 → 22}/node_crypto.h +1 -2
  71. package/src/headers/22/node_dotenv.h +45 -0
  72. package/src/headers/{18 → 22}/node_errors.h +86 -27
  73. package/src/headers/22/node_exit_code.h +54 -0
  74. package/src/headers/22/node_external_reference.h +249 -0
  75. package/src/headers/{18 → 22}/node_file-inl.h +127 -30
  76. package/src/headers/{16 → 22}/node_file.h +122 -11
  77. package/src/headers/{18 → 22}/node_http2.h +28 -11
  78. package/src/headers/{16 → 22}/node_http2_state.h +34 -25
  79. package/src/headers/{18 → 22}/node_http_common-inl.h +2 -1
  80. package/src/headers/{18 → 22}/node_http_common.h +56 -55
  81. package/src/headers/{16 → 22}/node_i18n.h +5 -18
  82. package/src/headers/{18 → 22}/node_internals.h +121 -59
  83. package/src/headers/{18 → 22}/node_main_instance.h +4 -31
  84. package/src/headers/{18 → 22}/node_messaging.h +27 -10
  85. package/src/headers/{18 → 22}/node_metadata.h +23 -1
  86. package/src/headers/{18 → 22}/node_options-inl.h +24 -11
  87. package/src/headers/{18 → 22}/node_options.h +124 -39
  88. package/src/headers/{18 → 22}/node_perf.h +0 -2
  89. package/src/headers/{18 → 22}/node_perf_common.h +20 -9
  90. package/src/headers/{18 → 22}/node_platform.h +11 -5
  91. package/src/headers/{18 → 22}/node_process.h +26 -14
  92. package/src/headers/22/node_realm-inl.h +145 -0
  93. package/src/headers/22/node_realm.h +184 -0
  94. package/src/headers/{16 → 22}/node_report.h +13 -17
  95. package/src/headers/{16 → 22}/node_revert.h +3 -3
  96. package/src/headers/{16 → 22}/node_root_certs.h +902 -461
  97. package/src/headers/22/node_sea.h +64 -0
  98. package/src/headers/22/node_shadow_realm.h +46 -0
  99. package/src/headers/22/node_snapshot_builder.h +57 -0
  100. package/src/headers/22/node_snapshotable.h +174 -0
  101. package/src/headers/{18 → 22}/node_sockaddr.h +2 -2
  102. package/src/headers/{16 → 22}/node_stat_watcher.h +2 -1
  103. package/src/headers/22/node_threadsafe_cow-inl.h +54 -0
  104. package/src/headers/22/node_threadsafe_cow.h +105 -0
  105. package/src/headers/22/node_union_bytes.h +81 -0
  106. package/src/headers/22/node_url.h +96 -0
  107. package/src/headers/22/node_v8.h +77 -0
  108. package/src/headers/{14 → 22}/node_v8_platform-inl.h +17 -6
  109. package/src/headers/{18 → 22}/node_version.h +20 -8
  110. package/src/headers/22/node_wasi.h +185 -0
  111. package/src/headers/{14 → 22}/node_watchdog.h +2 -0
  112. package/src/headers/{18 → 22}/node_worker.h +7 -2
  113. package/src/headers/22/permission/child_process_permission.h +31 -0
  114. package/src/headers/22/permission/fs_permission.h +167 -0
  115. package/src/headers/22/permission/inspector_permission.h +31 -0
  116. package/src/headers/22/permission/permission.h +99 -0
  117. package/src/headers/22/permission/permission_base.h +60 -0
  118. package/src/headers/22/permission/wasi_permission.h +31 -0
  119. package/src/headers/22/permission/worker_permission.h +31 -0
  120. package/src/headers/{16 → 22}/req_wrap-inl.h +7 -6
  121. package/src/headers/{14 → 22}/spawn_sync.h +3 -3
  122. package/src/headers/{18 → 22}/stream_base-inl.h +0 -135
  123. package/src/headers/{18 → 22}/stream_base.h +35 -16
  124. package/src/headers/{18 → 22}/stream_pipe.h +3 -4
  125. package/src/headers/{16 → 22}/stream_wrap.h +2 -1
  126. package/src/headers/{18 → 22}/string_bytes.h +5 -14
  127. package/src/headers/{14 → 22}/string_decoder-inl.h +0 -6
  128. package/src/headers/{16 → 22}/string_decoder.h +0 -1
  129. package/src/headers/{18 → 22}/tcp_wrap.h +1 -1
  130. package/src/headers/{18 → 22}/threadpoolwork-inl.h +14 -1
  131. package/src/headers/22/timers.h +76 -0
  132. package/src/headers/{18 → 22}/tracing/trace_event.h +7 -5
  133. package/src/headers/{16 → 22}/udp_wrap.h +8 -5
  134. package/src/headers/22/undici_version.h +6 -0
  135. package/src/headers/{18 → 22}/util-inl.h +97 -127
  136. package/src/headers/{18 → 22}/util.h +293 -106
  137. package/src/headers/{18 → 22}/v8-fast-api-calls.h +103 -58
  138. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  139. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  140. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  141. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  142. package/dist/bindings/cws_linux_arm64_node83.node +0 -0
  143. package/dist/bindings/cws_linux_arm64_node93.node +0 -0
  144. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  145. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  146. package/src/headers/14/aliased_buffer.h +0 -263
  147. package/src/headers/14/allocated_buffer-inl.h +0 -110
  148. package/src/headers/14/allocated_buffer.h +0 -73
  149. package/src/headers/14/async_wrap-inl.h +0 -94
  150. package/src/headers/14/async_wrap.h +0 -230
  151. package/src/headers/14/base64.h +0 -183
  152. package/src/headers/14/base_object-inl.h +0 -371
  153. package/src/headers/14/base_object.h +0 -281
  154. package/src/headers/14/callback_queue-inl.h +0 -97
  155. package/src/headers/14/callback_queue.h +0 -78
  156. package/src/headers/14/debug_utils-inl.h +0 -223
  157. package/src/headers/14/debug_utils.h +0 -181
  158. package/src/headers/14/env.h +0 -1388
  159. package/src/headers/14/handle_wrap.h +0 -117
  160. package/src/headers/14/histogram-inl.h +0 -83
  161. package/src/headers/14/histogram.h +0 -98
  162. package/src/headers/14/inspector_agent.h +0 -149
  163. package/src/headers/14/inspector_profiler.h +0 -137
  164. package/src/headers/14/js_native_api.h +0 -544
  165. package/src/headers/14/js_native_api_types.h +0 -143
  166. package/src/headers/14/js_native_api_v8.h +0 -301
  167. package/src/headers/14/js_native_api_v8_internals.h +0 -38
  168. package/src/headers/14/json_utils.h +0 -161
  169. package/src/headers/14/memory_tracker-inl.h +0 -355
  170. package/src/headers/14/module_wrap.h +0 -99
  171. package/src/headers/14/node.h +0 -1032
  172. package/src/headers/14/node_api.h +0 -255
  173. package/src/headers/14/node_api_types.h +0 -44
  174. package/src/headers/14/node_binding.h +0 -99
  175. package/src/headers/14/node_buffer.h +0 -92
  176. package/src/headers/14/node_constants.h +0 -84
  177. package/src/headers/14/node_context_data.h +0 -44
  178. package/src/headers/14/node_contextify.h +0 -161
  179. package/src/headers/14/node_crypto.h +0 -865
  180. package/src/headers/14/node_crypto_bio.h +0 -195
  181. package/src/headers/14/node_crypto_clienthello-inl.h +0 -91
  182. package/src/headers/14/node_crypto_clienthello.h +0 -132
  183. package/src/headers/14/node_crypto_common.h +0 -138
  184. package/src/headers/14/node_crypto_groups.h +0 -415
  185. package/src/headers/14/node_dtrace.h +0 -86
  186. package/src/headers/14/node_errors.h +0 -214
  187. package/src/headers/14/node_file-inl.h +0 -306
  188. package/src/headers/14/node_file.h +0 -417
  189. package/src/headers/14/node_http2.h +0 -1191
  190. package/src/headers/14/node_http2_state.h +0 -149
  191. package/src/headers/14/node_http_common-inl.h +0 -194
  192. package/src/headers/14/node_http_common.h +0 -529
  193. package/src/headers/14/node_i18n.h +0 -144
  194. package/src/headers/14/node_internals.h +0 -405
  195. package/src/headers/14/node_main_instance.h +0 -96
  196. package/src/headers/14/node_mem.h +0 -45
  197. package/src/headers/14/node_messaging.h +0 -303
  198. package/src/headers/14/node_metadata.h +0 -109
  199. package/src/headers/14/node_mutex.h +0 -247
  200. package/src/headers/14/node_native_module.h +0 -101
  201. package/src/headers/14/node_native_module_env.h +0 -66
  202. package/src/headers/14/node_options-inl.h +0 -451
  203. package/src/headers/14/node_options.h +0 -481
  204. package/src/headers/14/node_perf.h +0 -181
  205. package/src/headers/14/node_perf_common.h +0 -97
  206. package/src/headers/14/node_platform.h +0 -189
  207. package/src/headers/14/node_process.h +0 -40
  208. package/src/headers/14/node_report.h +0 -47
  209. package/src/headers/14/node_revert.h +0 -72
  210. package/src/headers/14/node_root_certs.h +0 -3458
  211. package/src/headers/14/node_sockaddr-inl.h +0 -170
  212. package/src/headers/14/node_sockaddr.h +0 -123
  213. package/src/headers/14/node_stat_watcher.h +0 -70
  214. package/src/headers/14/node_union_bytes.h +0 -103
  215. package/src/headers/14/node_url.h +0 -188
  216. package/src/headers/14/node_version.h +0 -98
  217. package/src/headers/14/node_wasi.h +0 -108
  218. package/src/headers/14/node_win32_etw_provider-inl.h +0 -287
  219. package/src/headers/14/node_win32_etw_provider.h +0 -99
  220. package/src/headers/14/node_worker.h +0 -141
  221. package/src/headers/14/pipe_wrap.h +0 -78
  222. package/src/headers/14/req_wrap-inl.h +0 -170
  223. package/src/headers/14/req_wrap.h +0 -77
  224. package/src/headers/14/stream_base-inl.h +0 -275
  225. package/src/headers/14/stream_base.h +0 -434
  226. package/src/headers/14/stream_pipe.h +0 -73
  227. package/src/headers/14/stream_wrap.h +0 -130
  228. package/src/headers/14/string_bytes.h +0 -129
  229. package/src/headers/14/string_decoder.h +0 -50
  230. package/src/headers/14/string_search.h +0 -638
  231. package/src/headers/14/tcp_wrap.h +0 -101
  232. package/src/headers/14/threadpoolwork-inl.h +0 -57
  233. package/src/headers/14/tls_wrap.h +0 -222
  234. package/src/headers/14/tracing/agent.h +0 -195
  235. package/src/headers/14/tracing/node_trace_buffer.h +0 -83
  236. package/src/headers/14/tracing/node_trace_writer.h +0 -75
  237. package/src/headers/14/tracing/trace_event.h +0 -720
  238. package/src/headers/14/tracing/traced_value.h +0 -70
  239. package/src/headers/14/tty_wrap.h +0 -64
  240. package/src/headers/14/udp_wrap.h +0 -227
  241. package/src/headers/14/util-inl.h +0 -566
  242. package/src/headers/14/util.h +0 -804
  243. package/src/headers/14/v8abbr.h +0 -124
  244. package/src/headers/16/aliased_buffer.h +0 -315
  245. package/src/headers/16/aliased_struct-inl.h +0 -54
  246. package/src/headers/16/aliased_struct.h +0 -63
  247. package/src/headers/16/allocated_buffer-inl.h +0 -110
  248. package/src/headers/16/allocated_buffer.h +0 -73
  249. package/src/headers/16/async_wrap-inl.h +0 -94
  250. package/src/headers/16/async_wrap.h +0 -246
  251. package/src/headers/16/base64-inl.h +0 -189
  252. package/src/headers/16/base64.h +0 -69
  253. package/src/headers/16/base_object.h +0 -294
  254. package/src/headers/16/connect_wrap.h +0 -26
  255. package/src/headers/16/connection_wrap.h +0 -30
  256. package/src/headers/16/crypto/crypto_aes.h +0 -89
  257. package/src/headers/16/crypto/crypto_bio.h +0 -194
  258. package/src/headers/16/crypto/crypto_cipher.h +0 -286
  259. package/src/headers/16/crypto/crypto_clienthello-inl.h +0 -90
  260. package/src/headers/16/crypto/crypto_clienthello.h +0 -131
  261. package/src/headers/16/crypto/crypto_common.h +0 -187
  262. package/src/headers/16/crypto/crypto_context.h +0 -147
  263. package/src/headers/16/crypto/crypto_dh.h +0 -157
  264. package/src/headers/16/crypto/crypto_dsa.h +0 -76
  265. package/src/headers/16/crypto/crypto_ec.h +0 -169
  266. package/src/headers/16/crypto/crypto_groups.h +0 -415
  267. package/src/headers/16/crypto/crypto_hash.h +0 -89
  268. package/src/headers/16/crypto/crypto_hkdf.h +0 -66
  269. package/src/headers/16/crypto/crypto_hmac.h +0 -94
  270. package/src/headers/16/crypto/crypto_keygen.h +0 -301
  271. package/src/headers/16/crypto/crypto_keys.h +0 -412
  272. package/src/headers/16/crypto/crypto_pbkdf2.h +0 -76
  273. package/src/headers/16/crypto/crypto_random.h +0 -130
  274. package/src/headers/16/crypto/crypto_rsa.h +0 -141
  275. package/src/headers/16/crypto/crypto_scrypt.h +0 -87
  276. package/src/headers/16/crypto/crypto_sig.h +0 -167
  277. package/src/headers/16/crypto/crypto_spkac.h +0 -20
  278. package/src/headers/16/crypto/crypto_timing.h +0 -20
  279. package/src/headers/16/crypto/crypto_tls.h +0 -292
  280. package/src/headers/16/crypto/crypto_util.h +0 -736
  281. package/src/headers/16/crypto/crypto_x509.h +0 -141
  282. package/src/headers/16/debug_utils.h +0 -184
  283. package/src/headers/16/diagnosticfilename-inl.h +0 -33
  284. package/src/headers/16/env-inl.h +0 -1277
  285. package/src/headers/16/env.h +0 -1629
  286. package/src/headers/16/handle_wrap.h +0 -121
  287. package/src/headers/16/histogram-inl.h +0 -88
  288. package/src/headers/16/histogram.h +0 -216
  289. package/src/headers/16/inspector_io.h +0 -78
  290. package/src/headers/16/inspector_socket.h +0 -60
  291. package/src/headers/16/inspector_socket_server.h +0 -110
  292. package/src/headers/16/js_native_api.h +0 -561
  293. package/src/headers/16/js_native_api_types.h +0 -160
  294. package/src/headers/16/js_native_api_v8.h +0 -451
  295. package/src/headers/16/js_native_api_v8_internals.h +0 -39
  296. package/src/headers/16/js_stream.h +0 -52
  297. package/src/headers/16/memory_tracker-inl.h +0 -356
  298. package/src/headers/16/memory_tracker.h +0 -284
  299. package/src/headers/16/node.d +0 -315
  300. package/src/headers/16/node.h +0 -1132
  301. package/src/headers/16/node.stp +0 -146
  302. package/src/headers/16/node_api.h +0 -275
  303. package/src/headers/16/node_api_internals.h +0 -30
  304. package/src/headers/16/node_api_types.h +0 -50
  305. package/src/headers/16/node_binding.h +0 -99
  306. package/src/headers/16/node_blob.h +0 -191
  307. package/src/headers/16/node_bob-inl.h +0 -37
  308. package/src/headers/16/node_bob.h +0 -111
  309. package/src/headers/16/node_buffer.h +0 -92
  310. package/src/headers/16/node_constants.h +0 -84
  311. package/src/headers/16/node_context_data.h +0 -44
  312. package/src/headers/16/node_contextify.h +0 -196
  313. package/src/headers/16/node_dir.h +0 -52
  314. package/src/headers/16/node_dtrace.h +0 -86
  315. package/src/headers/16/node_errors.h +0 -277
  316. package/src/headers/16/node_external_reference.h +0 -129
  317. package/src/headers/16/node_file-inl.h +0 -306
  318. package/src/headers/16/node_http2.h +0 -1140
  319. package/src/headers/16/node_http_common-inl.h +0 -200
  320. package/src/headers/16/node_http_common.h +0 -531
  321. package/src/headers/16/node_internals.h +0 -421
  322. package/src/headers/16/node_main_instance.h +0 -103
  323. package/src/headers/16/node_mem-inl.h +0 -112
  324. package/src/headers/16/node_messaging.h +0 -373
  325. package/src/headers/16/node_metadata.h +0 -122
  326. package/src/headers/16/node_native_module.h +0 -101
  327. package/src/headers/16/node_native_module_env.h +0 -68
  328. package/src/headers/16/node_object_wrap.h +0 -132
  329. package/src/headers/16/node_options-inl.h +0 -477
  330. package/src/headers/16/node_options.h +0 -494
  331. package/src/headers/16/node_perf.h +0 -185
  332. package/src/headers/16/node_perf_common.h +0 -89
  333. package/src/headers/16/node_platform.h +0 -192
  334. package/src/headers/16/node_process.h +0 -43
  335. package/src/headers/16/node_provider.d +0 -80
  336. package/src/headers/16/node_snapshotable.h +0 -137
  337. package/src/headers/16/node_sockaddr-inl.h +0 -266
  338. package/src/headers/16/node_sockaddr.h +0 -405
  339. package/src/headers/16/node_union_bytes.h +0 -103
  340. package/src/headers/16/node_url.h +0 -205
  341. package/src/headers/16/node_v8.h +0 -41
  342. package/src/headers/16/node_v8_platform-inl.h +0 -194
  343. package/src/headers/16/node_version.h +0 -98
  344. package/src/headers/16/node_wasi.h +0 -108
  345. package/src/headers/16/node_watchdog.h +0 -152
  346. package/src/headers/16/node_win32_etw_provider-inl.h +0 -288
  347. package/src/headers/16/node_win32_etw_provider.h +0 -99
  348. package/src/headers/16/node_worker.h +0 -145
  349. package/src/headers/16/req_wrap.h +0 -77
  350. package/src/headers/16/spawn_sync.h +0 -242
  351. package/src/headers/16/stream_base-inl.h +0 -303
  352. package/src/headers/16/stream_base.h +0 -454
  353. package/src/headers/16/stream_pipe.h +0 -73
  354. package/src/headers/16/string_bytes.h +0 -122
  355. package/src/headers/16/string_decoder-inl.h +0 -37
  356. package/src/headers/16/string_search.h +0 -638
  357. package/src/headers/16/tcp_wrap.h +0 -103
  358. package/src/headers/16/threadpoolwork-inl.h +0 -57
  359. package/src/headers/16/timer_wrap.h +0 -84
  360. package/src/headers/16/tracing/agent.h +0 -195
  361. package/src/headers/16/tracing/node_trace_buffer.h +0 -83
  362. package/src/headers/16/tracing/node_trace_writer.h +0 -75
  363. package/src/headers/16/tracing/trace_event.h +0 -720
  364. package/src/headers/16/tracing/trace_event_common.h +0 -1109
  365. package/src/headers/16/tracing/traced_value.h +0 -70
  366. package/src/headers/16/tty_wrap.h +0 -66
  367. package/src/headers/16/util-inl.h +0 -575
  368. package/src/headers/16/util.h +0 -824
  369. package/src/headers/16/v8abbr.h +0 -123
  370. package/src/headers/16/v8ustack.d +0 -695
  371. package/src/headers/18/aliased_buffer.h +0 -315
  372. package/src/headers/18/aliased_struct-inl.h +0 -54
  373. package/src/headers/18/aliased_struct.h +0 -63
  374. package/src/headers/18/base64-inl.h +0 -189
  375. package/src/headers/18/base64.h +0 -69
  376. package/src/headers/18/base_object-inl.h +0 -374
  377. package/src/headers/18/callback_queue-inl.h +0 -97
  378. package/src/headers/18/callback_queue.h +0 -78
  379. package/src/headers/18/cares_wrap.h +0 -523
  380. package/src/headers/18/connect_wrap.h +0 -26
  381. package/src/headers/18/connection_wrap.h +0 -30
  382. package/src/headers/18/crypto/crypto_aes.h +0 -89
  383. package/src/headers/18/crypto/crypto_bio.h +0 -194
  384. package/src/headers/18/crypto/crypto_cipher.h +0 -291
  385. package/src/headers/18/crypto/crypto_clienthello-inl.h +0 -90
  386. package/src/headers/18/crypto/crypto_common.h +0 -151
  387. package/src/headers/18/crypto/crypto_dh.h +0 -156
  388. package/src/headers/18/crypto/crypto_dsa.h +0 -77
  389. package/src/headers/18/crypto/crypto_ec.h +0 -170
  390. package/src/headers/18/crypto/crypto_groups.h +0 -415
  391. package/src/headers/18/crypto/crypto_hash.h +0 -89
  392. package/src/headers/18/crypto/crypto_hkdf.h +0 -65
  393. package/src/headers/18/crypto/crypto_hmac.h +0 -94
  394. package/src/headers/18/crypto/crypto_keygen.h +0 -305
  395. package/src/headers/18/crypto/crypto_pbkdf2.h +0 -76
  396. package/src/headers/18/crypto/crypto_random.h +0 -130
  397. package/src/headers/18/crypto/crypto_rsa.h +0 -141
  398. package/src/headers/18/crypto/crypto_scrypt.h +0 -87
  399. package/src/headers/18/crypto/crypto_sig.h +0 -168
  400. package/src/headers/18/crypto/crypto_spkac.h +0 -21
  401. package/src/headers/18/crypto/crypto_timing.h +0 -20
  402. package/src/headers/18/crypto/crypto_x509.h +0 -143
  403. package/src/headers/18/debug_utils-inl.h +0 -223
  404. package/src/headers/18/diagnosticfilename-inl.h +0 -33
  405. package/src/headers/18/env-inl.h +0 -1308
  406. package/src/headers/18/env.h +0 -1667
  407. package/src/headers/18/inspector_agent.h +0 -144
  408. package/src/headers/18/inspector_io.h +0 -78
  409. package/src/headers/18/inspector_profiler.h +0 -149
  410. package/src/headers/18/inspector_socket.h +0 -60
  411. package/src/headers/18/inspector_socket_server.h +0 -110
  412. package/src/headers/18/js_stream.h +0 -52
  413. package/src/headers/18/json_utils.h +0 -161
  414. package/src/headers/18/memory_tracker.h +0 -284
  415. package/src/headers/18/module_wrap.h +0 -116
  416. package/src/headers/18/node_binding.h +0 -99
  417. package/src/headers/18/node_context_data.h +0 -44
  418. package/src/headers/18/node_contextify.h +0 -196
  419. package/src/headers/18/node_crypto.h +0 -57
  420. package/src/headers/18/node_dir.h +0 -52
  421. package/src/headers/18/node_dtrace.h +0 -86
  422. package/src/headers/18/node_external_reference.h +0 -145
  423. package/src/headers/18/node_file.h +0 -426
  424. package/src/headers/18/node_http2_state.h +0 -149
  425. package/src/headers/18/node_i18n.h +0 -145
  426. package/src/headers/18/node_mem-inl.h +0 -112
  427. package/src/headers/18/node_mem.h +0 -45
  428. package/src/headers/18/node_mutex.h +0 -323
  429. package/src/headers/18/node_native_module.h +0 -109
  430. package/src/headers/18/node_native_module_env.h +0 -71
  431. package/src/headers/18/node_object_wrap.h +0 -132
  432. package/src/headers/18/node_process-inl.h +0 -26
  433. package/src/headers/18/node_report.h +0 -47
  434. package/src/headers/18/node_revert.h +0 -82
  435. package/src/headers/18/node_root_certs.h +0 -3246
  436. package/src/headers/18/node_snapshot_builder.h +0 -43
  437. package/src/headers/18/node_snapshotable.h +0 -130
  438. package/src/headers/18/node_stat_watcher.h +0 -72
  439. package/src/headers/18/node_union_bytes.h +0 -103
  440. package/src/headers/18/node_url.h +0 -205
  441. package/src/headers/18/node_v8.h +0 -41
  442. package/src/headers/18/node_v8_platform-inl.h +0 -194
  443. package/src/headers/18/node_wasi.h +0 -108
  444. package/src/headers/18/node_watchdog.h +0 -152
  445. package/src/headers/18/node_win32_etw_provider-inl.h +0 -288
  446. package/src/headers/18/node_win32_etw_provider.h +0 -99
  447. package/src/headers/18/pipe_wrap.h +0 -80
  448. package/src/headers/18/req_wrap-inl.h +0 -170
  449. package/src/headers/18/spawn_sync.h +0 -242
  450. package/src/headers/18/stream_wrap.h +0 -133
  451. package/src/headers/18/string_decoder-inl.h +0 -37
  452. package/src/headers/18/string_decoder.h +0 -50
  453. package/src/headers/18/string_search.h +0 -638
  454. package/src/headers/18/tracing/node_trace_buffer.h +0 -83
  455. package/src/headers/18/tracing/node_trace_writer.h +0 -75
  456. package/src/headers/18/tracing/trace_event_common.h +0 -1109
  457. package/src/headers/18/tracing/traced_value.h +0 -70
  458. package/src/headers/18/udp_wrap.h +0 -227
  459. package/src/headers/18/v8abbr.h +0 -123
  460. /package/src/headers/{14 → 22}/aliased_struct-inl.h +0 -0
  461. /package/src/headers/{14 → 22}/aliased_struct.h +0 -0
  462. /package/src/headers/{16 → 22}/callback_queue-inl.h +0 -0
  463. /package/src/headers/{14 → 22}/connect_wrap.h +0 -0
  464. /package/src/headers/{14 → 22}/connection_wrap.h +0 -0
  465. /package/src/headers/{14 → 22}/diagnosticfilename-inl.h +0 -0
  466. /package/src/headers/{18 → 22}/histogram-inl.h +0 -0
  467. /package/src/headers/{14 → 22}/inspector_io.h +0 -0
  468. /package/src/headers/{14 → 22}/inspector_socket.h +0 -0
  469. /package/src/headers/{14 → 22}/inspector_socket_server.h +0 -0
  470. /package/src/headers/{14 → 22}/js_stream.h +0 -0
  471. /package/src/headers/{14 → 22}/node_dir.h +0 -0
  472. /package/src/headers/{14 → 22}/node_mem-inl.h +0 -0
  473. /package/src/headers/{16 → 22}/node_mem.h +0 -0
  474. /package/src/headers/{16 → 22}/node_mutex.h +0 -0
  475. /package/src/headers/{14 → 22}/node_object_wrap.h +0 -0
  476. /package/src/headers/{16 → 22}/node_process-inl.h +0 -0
  477. /package/src/headers/{18 → 22}/node_sockaddr-inl.h +0 -0
  478. /package/src/headers/{18 → 22}/node_wasm_web_api.h +0 -0
  479. /package/src/headers/{16 → 22}/pipe_wrap.h +0 -0
  480. /package/src/headers/{18 → 22}/req_wrap.h +0 -0
  481. /package/src/headers/{18 → 22}/timer_wrap-inl.h +0 -0
  482. /package/src/headers/{18 → 22}/timer_wrap.h +0 -0
  483. /package/src/headers/{18 → 22}/tracing/agent.h +0 -0
  484. /package/src/headers/{14 → 22}/tracing/trace_event_common.h +0 -0
  485. /package/src/headers/{18 → 22}/tty_wrap.h +0 -0
@@ -1,824 +0,0 @@
1
- // Copyright Joyent, Inc. and other Node contributors.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a
4
- // copy of this software and associated documentation files (the
5
- // "Software"), to deal in the Software without restriction, including
6
- // without limitation the rights to use, copy, modify, merge, publish,
7
- // distribute, sublicense, and/or sell copies of the Software, and to permit
8
- // persons to whom the Software is furnished to do so, subject to the
9
- // following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be included
12
- // in all copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- #ifndef SRC_UTIL_H_
23
- #define SRC_UTIL_H_
24
-
25
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
-
27
- #include "v8.h"
28
-
29
- #include <climits>
30
- #include <cstddef>
31
- #include <cstdio>
32
- #include <cstdlib>
33
- #include <cstring>
34
-
35
- #include <functional> // std::function
36
- #include <limits>
37
- #include <set>
38
- #include <string>
39
- #include <array>
40
- #include <unordered_map>
41
- #include <utility>
42
-
43
- #ifdef __GNUC__
44
- #define MUST_USE_RESULT __attribute__((warn_unused_result))
45
- #else
46
- #define MUST_USE_RESULT
47
- #endif
48
-
49
- namespace node {
50
-
51
- // Maybe remove kPathSeparator when cpp17 is ready
52
- #ifdef _WIN32
53
- constexpr char kPathSeparator = '\\';
54
- /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
55
- #define PATH_MAX_BYTES (MAX_PATH * 4)
56
- #else
57
- constexpr char kPathSeparator = '/';
58
- #define PATH_MAX_BYTES (PATH_MAX)
59
- #endif
60
-
61
- // These should be used in our code as opposed to the native
62
- // versions as they abstract out some platform and or
63
- // compiler version specific functionality
64
- // malloc(0) and realloc(ptr, 0) have implementation-defined behavior in
65
- // that the standard allows them to either return a unique pointer or a
66
- // nullptr for zero-sized allocation requests. Normalize by always using
67
- // a nullptr.
68
- template <typename T>
69
- inline T* UncheckedRealloc(T* pointer, size_t n);
70
- template <typename T>
71
- inline T* UncheckedMalloc(size_t n);
72
- template <typename T>
73
- inline T* UncheckedCalloc(size_t n);
74
-
75
- // Same things, but aborts immediately instead of returning nullptr when
76
- // no memory is available.
77
- template <typename T>
78
- inline T* Realloc(T* pointer, size_t n);
79
- template <typename T>
80
- inline T* Malloc(size_t n);
81
- template <typename T>
82
- inline T* Calloc(size_t n);
83
-
84
- inline char* Malloc(size_t n);
85
- inline char* Calloc(size_t n);
86
- inline char* UncheckedMalloc(size_t n);
87
- inline char* UncheckedCalloc(size_t n);
88
-
89
- template <typename T>
90
- inline T MultiplyWithOverflowCheck(T a, T b);
91
-
92
- namespace per_process {
93
- // Tells whether the per-process V8::Initialize() is called and
94
- // if it is safe to call v8::Isolate::TryGetCurrent().
95
- extern bool v8_initialized;
96
- } // namespace per_process
97
-
98
- // Used by the allocation functions when allocation fails.
99
- // Thin wrapper around v8::Isolate::LowMemoryNotification() that checks
100
- // whether V8 is initialized.
101
- void LowMemoryNotification();
102
-
103
- // The reason that Assert() takes a struct argument instead of individual
104
- // const char*s is to ease instruction cache pressure in calls from CHECK.
105
- struct AssertionInfo {
106
- const char* file_line; // filename:line
107
- const char* message;
108
- const char* function;
109
- };
110
- [[noreturn]] void Assert(const AssertionInfo& info);
111
- [[noreturn]] void Abort();
112
- void DumpBacktrace(FILE* fp);
113
-
114
- // Windows 8+ does not like abort() in Release mode
115
- #ifdef _WIN32
116
- #define ABORT_NO_BACKTRACE() _exit(134)
117
- #else
118
- #define ABORT_NO_BACKTRACE() abort()
119
- #endif
120
-
121
- #define ABORT() node::Abort()
122
-
123
- #define ERROR_AND_ABORT(expr) \
124
- do { \
125
- /* Make sure that this struct does not end up in inline code, but */ \
126
- /* rather in a read-only data section when modifying this code. */ \
127
- static const node::AssertionInfo args = { \
128
- __FILE__ ":" STRINGIFY(__LINE__), #expr, PRETTY_FUNCTION_NAME \
129
- }; \
130
- node::Assert(args); \
131
- } while (0)
132
-
133
- #ifdef __GNUC__
134
- #define LIKELY(expr) __builtin_expect(!!(expr), 1)
135
- #define UNLIKELY(expr) __builtin_expect(!!(expr), 0)
136
- #define PRETTY_FUNCTION_NAME __PRETTY_FUNCTION__
137
- #else
138
- #define LIKELY(expr) expr
139
- #define UNLIKELY(expr) expr
140
- #define PRETTY_FUNCTION_NAME ""
141
- #endif
142
-
143
- #define STRINGIFY_(x) #x
144
- #define STRINGIFY(x) STRINGIFY_(x)
145
-
146
- #define CHECK(expr) \
147
- do { \
148
- if (UNLIKELY(!(expr))) { \
149
- ERROR_AND_ABORT(expr); \
150
- } \
151
- } while (0)
152
-
153
- #define CHECK_EQ(a, b) CHECK((a) == (b))
154
- #define CHECK_GE(a, b) CHECK((a) >= (b))
155
- #define CHECK_GT(a, b) CHECK((a) > (b))
156
- #define CHECK_LE(a, b) CHECK((a) <= (b))
157
- #define CHECK_LT(a, b) CHECK((a) < (b))
158
- #define CHECK_NE(a, b) CHECK((a) != (b))
159
- #define CHECK_NULL(val) CHECK((val) == nullptr)
160
- #define CHECK_NOT_NULL(val) CHECK((val) != nullptr)
161
- #define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))
162
-
163
- #ifdef DEBUG
164
- #define DCHECK(expr) CHECK(expr)
165
- #define DCHECK_EQ(a, b) CHECK((a) == (b))
166
- #define DCHECK_GE(a, b) CHECK((a) >= (b))
167
- #define DCHECK_GT(a, b) CHECK((a) > (b))
168
- #define DCHECK_LE(a, b) CHECK((a) <= (b))
169
- #define DCHECK_LT(a, b) CHECK((a) < (b))
170
- #define DCHECK_NE(a, b) CHECK((a) != (b))
171
- #define DCHECK_NULL(val) CHECK((val) == nullptr)
172
- #define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
173
- #define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
174
- #else
175
- #define DCHECK(expr)
176
- #define DCHECK_EQ(a, b)
177
- #define DCHECK_GE(a, b)
178
- #define DCHECK_GT(a, b)
179
- #define DCHECK_LE(a, b)
180
- #define DCHECK_LT(a, b)
181
- #define DCHECK_NE(a, b)
182
- #define DCHECK_NULL(val)
183
- #define DCHECK_NOT_NULL(val)
184
- #define DCHECK_IMPLIES(a, b)
185
- #endif
186
-
187
-
188
- #define UNREACHABLE(...) \
189
- ERROR_AND_ABORT("Unreachable code reached" __VA_OPT__(": ") __VA_ARGS__)
190
-
191
- // ECMA262 20.1.2.6 Number.MAX_SAFE_INTEGER (2^53-1)
192
- constexpr int64_t kMaxSafeJsInteger = 9007199254740991;
193
-
194
- inline bool IsSafeJsInt(v8::Local<v8::Value> v);
195
-
196
- // TAILQ-style intrusive list node.
197
- template <typename T>
198
- class ListNode;
199
-
200
- // TAILQ-style intrusive list head.
201
- template <typename T, ListNode<T> (T::*M)>
202
- class ListHead;
203
-
204
- template <typename T>
205
- class ListNode {
206
- public:
207
- inline ListNode();
208
- inline ~ListNode();
209
- inline void Remove();
210
- inline bool IsEmpty() const;
211
-
212
- ListNode(const ListNode&) = delete;
213
- ListNode& operator=(const ListNode&) = delete;
214
-
215
- private:
216
- template <typename U, ListNode<U> (U::*M)> friend class ListHead;
217
- friend int GenDebugSymbols();
218
- ListNode* prev_;
219
- ListNode* next_;
220
- };
221
-
222
- template <typename T, ListNode<T> (T::*M)>
223
- class ListHead {
224
- public:
225
- class Iterator {
226
- public:
227
- inline T* operator*() const;
228
- inline const Iterator& operator++();
229
- inline bool operator!=(const Iterator& that) const;
230
-
231
- private:
232
- friend class ListHead;
233
- inline explicit Iterator(ListNode<T>* node);
234
- ListNode<T>* node_;
235
- };
236
-
237
- inline ListHead() = default;
238
- inline ~ListHead();
239
- inline void PushBack(T* element);
240
- inline void PushFront(T* element);
241
- inline bool IsEmpty() const;
242
- inline T* PopFront();
243
- inline Iterator begin() const;
244
- inline Iterator end() const;
245
-
246
- ListHead(const ListHead&) = delete;
247
- ListHead& operator=(const ListHead&) = delete;
248
-
249
- private:
250
- friend int GenDebugSymbols();
251
- ListNode<T> head_;
252
- };
253
-
254
- // The helper is for doing safe downcasts from base types to derived types.
255
- template <typename Inner, typename Outer>
256
- class ContainerOfHelper {
257
- public:
258
- inline ContainerOfHelper(Inner Outer::*field, Inner* pointer);
259
- template <typename TypeName>
260
- inline operator TypeName*() const;
261
- private:
262
- Outer* const pointer_;
263
- };
264
-
265
- // Calculate the address of the outer (i.e. embedding) struct from
266
- // the interior pointer to a data member.
267
- template <typename Inner, typename Outer>
268
- constexpr ContainerOfHelper<Inner, Outer> ContainerOf(Inner Outer::*field,
269
- Inner* pointer);
270
-
271
- // Convenience wrapper around v8::String::NewFromOneByte().
272
- inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
273
- const char* data,
274
- int length = -1);
275
-
276
- // For the people that compile with -funsigned-char.
277
- inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
278
- const signed char* data,
279
- int length = -1);
280
-
281
- inline v8::Local<v8::String> OneByteString(v8::Isolate* isolate,
282
- const unsigned char* data,
283
- int length = -1);
284
-
285
- // Used to be a macro, hence the uppercase name.
286
- template <int N>
287
- inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(
288
- v8::Isolate* isolate,
289
- const char(&data)[N]) {
290
- return OneByteString(isolate, data, N - 1);
291
- }
292
-
293
- template <std::size_t N>
294
- inline v8::Local<v8::String> FIXED_ONE_BYTE_STRING(
295
- v8::Isolate* isolate,
296
- const std::array<char, N>& arr) {
297
- return OneByteString(isolate, arr.data(), N - 1);
298
- }
299
-
300
-
301
-
302
- // Swaps bytes in place. nbytes is the number of bytes to swap and must be a
303
- // multiple of the word size (checked by function).
304
- inline void SwapBytes16(char* data, size_t nbytes);
305
- inline void SwapBytes32(char* data, size_t nbytes);
306
- inline void SwapBytes64(char* data, size_t nbytes);
307
-
308
- // tolower() is locale-sensitive. Use ToLower() instead.
309
- inline char ToLower(char c);
310
- inline std::string ToLower(const std::string& in);
311
-
312
- // toupper() is locale-sensitive. Use ToUpper() instead.
313
- inline char ToUpper(char c);
314
- inline std::string ToUpper(const std::string& in);
315
-
316
- // strcasecmp() is locale-sensitive. Use StringEqualNoCase() instead.
317
- inline bool StringEqualNoCase(const char* a, const char* b);
318
-
319
- // strncasecmp() is locale-sensitive. Use StringEqualNoCaseN() instead.
320
- inline bool StringEqualNoCaseN(const char* a, const char* b, size_t length);
321
-
322
- template <typename T, size_t N>
323
- constexpr size_t arraysize(const T (&)[N]) {
324
- return N;
325
- }
326
-
327
- template <typename T, size_t N>
328
- constexpr size_t strsize(const T (&)[N]) {
329
- return N - 1;
330
- }
331
-
332
- // Allocates an array of member type T. For up to kStackStorageSize items,
333
- // the stack is used, otherwise malloc().
334
- template <typename T, size_t kStackStorageSize = 1024>
335
- class MaybeStackBuffer {
336
- public:
337
- const T* out() const {
338
- return buf_;
339
- }
340
-
341
- T* out() {
342
- return buf_;
343
- }
344
-
345
- // operator* for compatibility with `v8::String::(Utf8)Value`
346
- T* operator*() {
347
- return buf_;
348
- }
349
-
350
- const T* operator*() const {
351
- return buf_;
352
- }
353
-
354
- T& operator[](size_t index) {
355
- CHECK_LT(index, length());
356
- return buf_[index];
357
- }
358
-
359
- const T& operator[](size_t index) const {
360
- CHECK_LT(index, length());
361
- return buf_[index];
362
- }
363
-
364
- size_t length() const {
365
- return length_;
366
- }
367
-
368
- // Current maximum capacity of the buffer with which SetLength() can be used
369
- // without first calling AllocateSufficientStorage().
370
- size_t capacity() const {
371
- return capacity_;
372
- }
373
-
374
- // Make sure enough space for `storage` entries is available.
375
- // This method can be called multiple times throughout the lifetime of the
376
- // buffer, but once this has been called Invalidate() cannot be used.
377
- // Content of the buffer in the range [0, length()) is preserved.
378
- void AllocateSufficientStorage(size_t storage) {
379
- CHECK(!IsInvalidated());
380
- if (storage > capacity()) {
381
- bool was_allocated = IsAllocated();
382
- T* allocated_ptr = was_allocated ? buf_ : nullptr;
383
- buf_ = Realloc(allocated_ptr, storage);
384
- capacity_ = storage;
385
- if (!was_allocated && length_ > 0)
386
- memcpy(buf_, buf_st_, length_ * sizeof(buf_[0]));
387
- }
388
-
389
- length_ = storage;
390
- }
391
-
392
- void SetLength(size_t length) {
393
- // capacity() returns how much memory is actually available.
394
- CHECK_LE(length, capacity());
395
- length_ = length;
396
- }
397
-
398
- void SetLengthAndZeroTerminate(size_t length) {
399
- // capacity() returns how much memory is actually available.
400
- CHECK_LE(length + 1, capacity());
401
- SetLength(length);
402
-
403
- // T() is 0 for integer types, nullptr for pointers, etc.
404
- buf_[length] = T();
405
- }
406
-
407
- // Make dereferencing this object return nullptr.
408
- // This method can be called multiple times throughout the lifetime of the
409
- // buffer, but once this has been called AllocateSufficientStorage() cannot
410
- // be used.
411
- void Invalidate() {
412
- CHECK(!IsAllocated());
413
- capacity_ = 0;
414
- length_ = 0;
415
- buf_ = nullptr;
416
- }
417
-
418
- // If the buffer is stored in the heap rather than on the stack.
419
- bool IsAllocated() const {
420
- return !IsInvalidated() && buf_ != buf_st_;
421
- }
422
-
423
- // If Invalidate() has been called.
424
- bool IsInvalidated() const {
425
- return buf_ == nullptr;
426
- }
427
-
428
- // Release ownership of the malloc'd buffer.
429
- // Note: This does not free the buffer.
430
- void Release() {
431
- CHECK(IsAllocated());
432
- buf_ = buf_st_;
433
- length_ = 0;
434
- capacity_ = arraysize(buf_st_);
435
- }
436
-
437
- MaybeStackBuffer()
438
- : length_(0), capacity_(arraysize(buf_st_)), buf_(buf_st_) {
439
- // Default to a zero-length, null-terminated buffer.
440
- buf_[0] = T();
441
- }
442
-
443
- explicit MaybeStackBuffer(size_t storage) : MaybeStackBuffer() {
444
- AllocateSufficientStorage(storage);
445
- }
446
-
447
- ~MaybeStackBuffer() {
448
- if (IsAllocated())
449
- free(buf_);
450
- }
451
-
452
- private:
453
- size_t length_;
454
- // capacity of the malloc'ed buf_
455
- size_t capacity_;
456
- T* buf_;
457
- T buf_st_[kStackStorageSize];
458
- };
459
-
460
- // Provides access to an ArrayBufferView's storage, either the original,
461
- // or for small data, a copy of it. This object's lifetime is bound to the
462
- // original ArrayBufferView's lifetime.
463
- template <typename T, size_t kStackStorageSize = 64>
464
- class ArrayBufferViewContents {
465
- public:
466
- ArrayBufferViewContents() = default;
467
-
468
- explicit inline ArrayBufferViewContents(v8::Local<v8::Value> value);
469
- explicit inline ArrayBufferViewContents(v8::Local<v8::Object> value);
470
- explicit inline ArrayBufferViewContents(v8::Local<v8::ArrayBufferView> abv);
471
- inline void Read(v8::Local<v8::ArrayBufferView> abv);
472
-
473
- inline const T* data() const { return data_; }
474
- inline size_t length() const { return length_; }
475
-
476
- private:
477
- T stack_storage_[kStackStorageSize];
478
- T* data_ = nullptr;
479
- size_t length_ = 0;
480
- };
481
-
482
- class Utf8Value : public MaybeStackBuffer<char> {
483
- public:
484
- explicit Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> value);
485
-
486
- inline std::string ToString() const { return std::string(out(), length()); }
487
-
488
- inline bool operator==(const char* a) const {
489
- return strcmp(out(), a) == 0;
490
- }
491
- };
492
-
493
- class TwoByteValue : public MaybeStackBuffer<uint16_t> {
494
- public:
495
- explicit TwoByteValue(v8::Isolate* isolate, v8::Local<v8::Value> value);
496
- };
497
-
498
- class BufferValue : public MaybeStackBuffer<char> {
499
- public:
500
- explicit BufferValue(v8::Isolate* isolate, v8::Local<v8::Value> value);
501
-
502
- inline std::string ToString() const { return std::string(out(), length()); }
503
- };
504
-
505
- #define SPREAD_BUFFER_ARG(val, name) \
506
- CHECK((val)->IsArrayBufferView()); \
507
- v8::Local<v8::ArrayBufferView> name = (val).As<v8::ArrayBufferView>(); \
508
- std::shared_ptr<v8::BackingStore> name##_bs = \
509
- name->Buffer()->GetBackingStore(); \
510
- const size_t name##_offset = name->ByteOffset(); \
511
- const size_t name##_length = name->ByteLength(); \
512
- char* const name##_data = \
513
- static_cast<char*>(name##_bs->Data()) + name##_offset; \
514
- if (name##_length > 0) \
515
- CHECK_NE(name##_data, nullptr);
516
-
517
- // Use this when a variable or parameter is unused in order to explicitly
518
- // silence a compiler warning about that.
519
- template <typename T> inline void USE(T&&) {}
520
-
521
- template <typename Fn>
522
- struct OnScopeLeaveImpl {
523
- Fn fn_;
524
- bool active_;
525
-
526
- explicit OnScopeLeaveImpl(Fn&& fn) : fn_(std::move(fn)), active_(true) {}
527
- ~OnScopeLeaveImpl() { if (active_) fn_(); }
528
-
529
- OnScopeLeaveImpl(const OnScopeLeaveImpl& other) = delete;
530
- OnScopeLeaveImpl& operator=(const OnScopeLeaveImpl& other) = delete;
531
- OnScopeLeaveImpl(OnScopeLeaveImpl&& other)
532
- : fn_(std::move(other.fn_)), active_(other.active_) {
533
- other.active_ = false;
534
- }
535
- OnScopeLeaveImpl& operator=(OnScopeLeaveImpl&& other) {
536
- if (this == &other) return *this;
537
- this->~OnScopeLeave();
538
- new (this)OnScopeLeaveImpl(std::move(other));
539
- return *this;
540
- }
541
- };
542
-
543
- // Run a function when exiting the current scope. Used like this:
544
- // auto on_scope_leave = OnScopeLeave([&] {
545
- // // ... run some code ...
546
- // });
547
- template <typename Fn>
548
- inline MUST_USE_RESULT OnScopeLeaveImpl<Fn> OnScopeLeave(Fn&& fn) {
549
- return OnScopeLeaveImpl<Fn>{std::move(fn)};
550
- }
551
-
552
- // Simple RAII wrapper for contiguous data that uses malloc()/free().
553
- template <typename T>
554
- struct MallocedBuffer {
555
- T* data;
556
- size_t size;
557
-
558
- T* release() {
559
- T* ret = data;
560
- data = nullptr;
561
- return ret;
562
- }
563
-
564
- void Truncate(size_t new_size) {
565
- CHECK(new_size <= size);
566
- size = new_size;
567
- }
568
-
569
- void Realloc(size_t new_size) {
570
- Truncate(new_size);
571
- data = UncheckedRealloc(data, new_size);
572
- }
573
-
574
- inline bool is_empty() const { return data == nullptr; }
575
-
576
- MallocedBuffer() : data(nullptr), size(0) {}
577
- explicit MallocedBuffer(size_t size) : data(Malloc<T>(size)), size(size) {}
578
- MallocedBuffer(T* data, size_t size) : data(data), size(size) {}
579
- MallocedBuffer(MallocedBuffer&& other) : data(other.data), size(other.size) {
580
- other.data = nullptr;
581
- }
582
- MallocedBuffer& operator=(MallocedBuffer&& other) {
583
- this->~MallocedBuffer();
584
- return *new(this) MallocedBuffer(std::move(other));
585
- }
586
- ~MallocedBuffer() {
587
- free(data);
588
- }
589
- MallocedBuffer(const MallocedBuffer&) = delete;
590
- MallocedBuffer& operator=(const MallocedBuffer&) = delete;
591
- };
592
-
593
- template <typename T>
594
- class NonCopyableMaybe {
595
- public:
596
- NonCopyableMaybe() : empty_(true) {}
597
- explicit NonCopyableMaybe(T&& value)
598
- : empty_(false),
599
- value_(std::move(value)) {}
600
-
601
- bool IsEmpty() const {
602
- return empty_;
603
- }
604
-
605
- const T* get() const {
606
- return empty_ ? nullptr : &value_;
607
- }
608
-
609
- const T* operator->() const {
610
- CHECK(!empty_);
611
- return &value_;
612
- }
613
-
614
- T&& Release() {
615
- CHECK_EQ(empty_, false);
616
- empty_ = true;
617
- return std::move(value_);
618
- }
619
-
620
- private:
621
- bool empty_;
622
- T value_;
623
- };
624
-
625
- // Test whether some value can be called with ().
626
- template <typename T, typename = void>
627
- struct is_callable : std::is_function<T> { };
628
-
629
- template <typename T>
630
- struct is_callable<T, typename std::enable_if<
631
- std::is_same<decltype(void(&T::operator())), void>::value
632
- >::type> : std::true_type { };
633
-
634
- template <typename T, void (*function)(T*)>
635
- struct FunctionDeleter {
636
- void operator()(T* pointer) const { function(pointer); }
637
- typedef std::unique_ptr<T, FunctionDeleter> Pointer;
638
- };
639
-
640
- template <typename T, void (*function)(T*)>
641
- using DeleteFnPtr = typename FunctionDeleter<T, function>::Pointer;
642
-
643
- std::vector<std::string> SplitString(const std::string& in, char delim);
644
-
645
- inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
646
- const std::string& str,
647
- v8::Isolate* isolate = nullptr);
648
- template <typename T, typename test_for_number =
649
- typename std::enable_if<std::numeric_limits<T>::is_specialized, bool>::type>
650
- inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
651
- const T& number,
652
- v8::Isolate* isolate = nullptr);
653
- template <typename T>
654
- inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
655
- const std::vector<T>& vec,
656
- v8::Isolate* isolate = nullptr);
657
- template <typename T, typename U>
658
- inline v8::MaybeLocal<v8::Value> ToV8Value(v8::Local<v8::Context> context,
659
- const std::unordered_map<T, U>& map,
660
- v8::Isolate* isolate = nullptr);
661
-
662
- // These macros expects a `Isolate* isolate` and a `Local<Context> context`
663
- // to be in the scope.
664
- #define READONLY_PROPERTY(obj, name, value) \
665
- do { \
666
- obj->DefineOwnProperty( \
667
- context, FIXED_ONE_BYTE_STRING(isolate, name), value, v8::ReadOnly) \
668
- .Check(); \
669
- } while (0)
670
-
671
- #define READONLY_DONT_ENUM_PROPERTY(obj, name, var) \
672
- do { \
673
- obj->DefineOwnProperty( \
674
- context, \
675
- OneByteString(isolate, name), \
676
- var, \
677
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)) \
678
- .Check(); \
679
- } while (0)
680
-
681
- #define READONLY_FALSE_PROPERTY(obj, name) \
682
- READONLY_PROPERTY(obj, name, v8::False(isolate))
683
-
684
- #define READONLY_TRUE_PROPERTY(obj, name) \
685
- READONLY_PROPERTY(obj, name, v8::True(isolate))
686
-
687
- #define READONLY_STRING_PROPERTY(obj, name, str) \
688
- READONLY_PROPERTY(obj, name, ToV8Value(context, str).ToLocalChecked())
689
-
690
- // Variation on NODE_DEFINE_CONSTANT that sets a String value.
691
- #define NODE_DEFINE_STRING_CONSTANT(target, name, constant) \
692
- do { \
693
- v8::Isolate* isolate = target->GetIsolate(); \
694
- v8::Local<v8::String> constant_name = \
695
- v8::String::NewFromUtf8(isolate, name).ToLocalChecked(); \
696
- v8::Local<v8::String> constant_value = \
697
- v8::String::NewFromUtf8(isolate, constant).ToLocalChecked(); \
698
- v8::PropertyAttribute constant_attributes = \
699
- static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \
700
- target \
701
- ->DefineOwnProperty(isolate->GetCurrentContext(), \
702
- constant_name, \
703
- constant_value, \
704
- constant_attributes) \
705
- .Check(); \
706
- } while (0)
707
-
708
- enum Endianness {
709
- kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h.
710
- kBigEndian
711
- };
712
-
713
- inline enum Endianness GetEndianness() {
714
- // Constant-folded by the compiler.
715
- const union {
716
- uint8_t u8[2];
717
- uint16_t u16;
718
- } u = {{1, 0}};
719
- return u.u16 == 1 ? kLittleEndian : kBigEndian;
720
- }
721
-
722
- inline bool IsLittleEndian() {
723
- return GetEndianness() == kLittleEndian;
724
- }
725
-
726
- inline bool IsBigEndian() {
727
- return GetEndianness() == kBigEndian;
728
- }
729
-
730
- // Round up a to the next highest multiple of b.
731
- template <typename T>
732
- constexpr T RoundUp(T a, T b) {
733
- return a % b != 0 ? a + b - (a % b) : a;
734
- }
735
-
736
- // Align ptr to an `alignment`-bytes boundary.
737
- template <typename T, typename U>
738
- constexpr T* AlignUp(T* ptr, U alignment) {
739
- return reinterpret_cast<T*>(
740
- RoundUp(reinterpret_cast<uintptr_t>(ptr), alignment));
741
- }
742
-
743
- class SlicedArguments : public MaybeStackBuffer<v8::Local<v8::Value>> {
744
- public:
745
- inline explicit SlicedArguments(
746
- const v8::FunctionCallbackInfo<v8::Value>& args, size_t start = 0);
747
- };
748
-
749
- // Convert a v8::PersistentBase, e.g. v8::Global, to a Local, with an extra
750
- // optimization for strong persistent handles.
751
- class PersistentToLocal {
752
- public:
753
- // If persistent.IsWeak() == false, then do not call persistent.Reset()
754
- // while the returned Local<T> is still in scope, it will destroy the
755
- // reference to the object.
756
- template <class TypeName>
757
- static inline v8::Local<TypeName> Default(
758
- v8::Isolate* isolate,
759
- const v8::PersistentBase<TypeName>& persistent) {
760
- if (persistent.IsWeak()) {
761
- return PersistentToLocal::Weak(isolate, persistent);
762
- } else {
763
- return PersistentToLocal::Strong(persistent);
764
- }
765
- }
766
-
767
- // Unchecked conversion from a non-weak Persistent<T> to Local<T>,
768
- // use with care!
769
- //
770
- // Do not call persistent.Reset() while the returned Local<T> is still in
771
- // scope, it will destroy the reference to the object.
772
- template <class TypeName>
773
- static inline v8::Local<TypeName> Strong(
774
- const v8::PersistentBase<TypeName>& persistent) {
775
- DCHECK(!persistent.IsWeak());
776
- return *reinterpret_cast<v8::Local<TypeName>*>(
777
- const_cast<v8::PersistentBase<TypeName>*>(&persistent));
778
- }
779
-
780
- template <class TypeName>
781
- static inline v8::Local<TypeName> Weak(
782
- v8::Isolate* isolate,
783
- const v8::PersistentBase<TypeName>& persistent) {
784
- return v8::Local<TypeName>::New(isolate, persistent);
785
- }
786
- };
787
-
788
- // Can be used as a key for std::unordered_map when lookup performance is more
789
- // important than size and the keys are statically used to avoid redundant hash
790
- // computations.
791
- class FastStringKey {
792
- public:
793
- constexpr explicit FastStringKey(const char* name);
794
-
795
- struct Hash {
796
- constexpr size_t operator()(const FastStringKey& key) const;
797
- };
798
- constexpr bool operator==(const FastStringKey& other) const;
799
-
800
- constexpr const char* c_str() const;
801
-
802
- private:
803
- static constexpr size_t HashImpl(const char* str);
804
-
805
- const char* name_;
806
- size_t cached_hash_;
807
- };
808
-
809
- // Like std::static_pointer_cast but for unique_ptr with the default deleter.
810
- template <typename T, typename U>
811
- std::unique_ptr<T> static_unique_pointer_cast(std::unique_ptr<U>&& ptr) {
812
- return std::unique_ptr<T>(static_cast<T*>(ptr.release()));
813
- }
814
-
815
- #define MAYBE_FIELD_PTR(ptr, field) ptr == nullptr ? nullptr : &(ptr->field)
816
-
817
- // Returns a non-zero code if it fails to open or read the file,
818
- // aborts if it fails to close the file.
819
- int ReadFileSync(std::string* result, const char* path);
820
- } // namespace node
821
-
822
- #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
823
-
824
- #endif // SRC_UTIL_H_