@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.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 (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/node/include/acorn_version.h +6 -0
  4. package/dist/node/include/aliased_buffer-inl.h +244 -0
  5. package/dist/node/include/aliased_buffer.h +206 -0
  6. package/dist/node/include/aliased_struct-inl.h +54 -0
  7. package/dist/node/include/aliased_struct.h +63 -0
  8. package/dist/node/include/amaro_version.h +6 -0
  9. package/dist/node/include/async_context_frame.h +33 -0
  10. package/dist/node/include/async_wrap-inl.h +96 -0
  11. package/dist/node/include/async_wrap.h +243 -0
  12. package/dist/node/include/base_object-inl.h +335 -0
  13. package/dist/node/include/base_object.h +342 -0
  14. package/dist/node/include/base_object_types.h +74 -0
  15. package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
  16. package/dist/node/include/blob_serializer_deserializer.h +132 -0
  17. package/dist/node/include/callback_queue-inl.h +97 -0
  18. package/dist/node/include/callback_queue.h +79 -0
  19. package/dist/node/include/cares_wrap.h +447 -0
  20. package/dist/node/include/cjs_module_lexer_version.h +6 -0
  21. package/dist/node/include/cleanup_queue-inl.h +36 -0
  22. package/dist/node/include/cleanup_queue.h +79 -0
  23. package/dist/node/include/compile_cache.h +104 -0
  24. package/dist/node/include/connect_wrap.h +26 -0
  25. package/dist/node/include/connection_wrap.h +30 -0
  26. package/dist/node/include/cppgc/allocation.h +310 -0
  27. package/dist/node/include/cppgc/common.h +28 -0
  28. package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
  29. package/dist/node/include/cppgc/custom-space.h +97 -0
  30. package/dist/node/include/cppgc/default-platform.h +67 -0
  31. package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
  32. package/dist/node/include/cppgc/explicit-management.h +100 -0
  33. package/dist/node/include/cppgc/garbage-collected.h +106 -0
  34. package/dist/node/include/cppgc/heap-consistency.h +309 -0
  35. package/dist/node/include/cppgc/heap-handle.h +48 -0
  36. package/dist/node/include/cppgc/heap-state.h +82 -0
  37. package/dist/node/include/cppgc/heap-statistics.h +120 -0
  38. package/dist/node/include/cppgc/heap.h +202 -0
  39. package/dist/node/include/cppgc/internal/api-constants.h +87 -0
  40. package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
  41. package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
  42. package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
  43. package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
  44. package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
  45. package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
  46. package/dist/node/include/cppgc/internal/gc-info.h +148 -0
  47. package/dist/node/include/cppgc/internal/logging.h +50 -0
  48. package/dist/node/include/cppgc/internal/member-storage.h +256 -0
  49. package/dist/node/include/cppgc/internal/name-trait.h +137 -0
  50. package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
  51. package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
  52. package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
  53. package/dist/node/include/cppgc/liveness-broker.h +78 -0
  54. package/dist/node/include/cppgc/macros.h +35 -0
  55. package/dist/node/include/cppgc/member.h +629 -0
  56. package/dist/node/include/cppgc/name-provider.h +65 -0
  57. package/dist/node/include/cppgc/object-size-trait.h +58 -0
  58. package/dist/node/include/cppgc/persistent.h +377 -0
  59. package/dist/node/include/cppgc/platform.h +163 -0
  60. package/dist/node/include/cppgc/prefinalizer.h +75 -0
  61. package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
  62. package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
  63. package/dist/node/include/cppgc/source-location.h +16 -0
  64. package/dist/node/include/cppgc/testing.h +106 -0
  65. package/dist/node/include/cppgc/trace-trait.h +128 -0
  66. package/dist/node/include/cppgc/type-traits.h +271 -0
  67. package/dist/node/include/cppgc/visitor.h +504 -0
  68. package/dist/node/include/crypto/crypto_aes.h +88 -0
  69. package/dist/node/include/crypto/crypto_bio.h +193 -0
  70. package/dist/node/include/crypto/crypto_cipher.h +293 -0
  71. package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
  72. package/dist/node/include/crypto/crypto_clienthello.h +131 -0
  73. package/dist/node/include/crypto/crypto_common.h +64 -0
  74. package/dist/node/include/crypto/crypto_context.h +171 -0
  75. package/dist/node/include/crypto/crypto_dh.h +126 -0
  76. package/dist/node/include/crypto/crypto_dsa.h +52 -0
  77. package/dist/node/include/crypto/crypto_ec.h +164 -0
  78. package/dist/node/include/crypto/crypto_hash.h +91 -0
  79. package/dist/node/include/crypto/crypto_hkdf.h +61 -0
  80. package/dist/node/include/crypto/crypto_hmac.h +92 -0
  81. package/dist/node/include/crypto/crypto_keygen.h +299 -0
  82. package/dist/node/include/crypto/crypto_keys.h +392 -0
  83. package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
  84. package/dist/node/include/crypto/crypto_random.h +124 -0
  85. package/dist/node/include/crypto/crypto_rsa.h +136 -0
  86. package/dist/node/include/crypto/crypto_scrypt.h +85 -0
  87. package/dist/node/include/crypto/crypto_sig.h +165 -0
  88. package/dist/node/include/crypto/crypto_spkac.h +21 -0
  89. package/dist/node/include/crypto/crypto_timing.h +20 -0
  90. package/dist/node/include/crypto/crypto_tls.h +305 -0
  91. package/dist/node/include/crypto/crypto_util.h +725 -0
  92. package/dist/node/include/crypto/crypto_x509.h +140 -0
  93. package/dist/node/include/dataqueue/queue.h +306 -0
  94. package/dist/node/include/debug_utils-inl.h +278 -0
  95. package/dist/node/include/debug_utils.h +196 -0
  96. package/dist/node/include/diagnosticfilename-inl.h +33 -0
  97. package/dist/node/include/embedded_data.h +17 -0
  98. package/dist/node/include/encoding_binding.h +61 -0
  99. package/dist/node/include/env-inl.h +984 -0
  100. package/dist/node/include/env.h +1287 -0
  101. package/dist/node/include/env_properties.h +540 -0
  102. package/dist/node/include/handle_wrap.h +123 -0
  103. package/dist/node/include/histogram-inl.h +107 -0
  104. package/dist/node/include/histogram.h +279 -0
  105. package/dist/node/include/inspector/io_agent.h +30 -0
  106. package/dist/node/include/inspector/main_thread_interface.h +116 -0
  107. package/dist/node/include/inspector/network_agent.h +94 -0
  108. package/dist/node/include/inspector/network_inspector.h +45 -0
  109. package/dist/node/include/inspector/network_requests_buffer.h +195 -0
  110. package/dist/node/include/inspector/network_resource_manager.h +29 -0
  111. package/dist/node/include/inspector/node_json.h +24 -0
  112. package/dist/node/include/inspector/node_string.h +101 -0
  113. package/dist/node/include/inspector/protocol_helper.h +27 -0
  114. package/dist/node/include/inspector/runtime_agent.h +41 -0
  115. package/dist/node/include/inspector/target_agent.h +75 -0
  116. package/dist/node/include/inspector/tracing_agent.h +43 -0
  117. package/dist/node/include/inspector/worker_agent.h +40 -0
  118. package/dist/node/include/inspector/worker_inspector.h +124 -0
  119. package/dist/node/include/inspector_agent.h +165 -0
  120. package/dist/node/include/inspector_io.h +78 -0
  121. package/dist/node/include/inspector_profiler.h +149 -0
  122. package/dist/node/include/inspector_socket.h +60 -0
  123. package/dist/node/include/inspector_socket_server.h +110 -0
  124. package/dist/node/include/js_native_api.h +607 -0
  125. package/dist/node/include/js_native_api_types.h +226 -0
  126. package/dist/node/include/js_native_api_v8.h +485 -0
  127. package/dist/node/include/js_native_api_v8_internals.h +45 -0
  128. package/dist/node/include/js_stream.h +52 -0
  129. package/dist/node/include/json_utils.h +172 -0
  130. package/dist/node/include/large_pages/node_large_page.h +34 -0
  131. package/dist/node/include/libplatform/libplatform-export.h +29 -0
  132. package/dist/node/include/libplatform/libplatform.h +112 -0
  133. package/dist/node/include/libplatform/v8-tracing.h +333 -0
  134. package/dist/node/include/memory_tracker-inl.h +359 -0
  135. package/dist/node/include/memory_tracker.h +289 -0
  136. package/dist/node/include/module_wrap.h +216 -0
  137. package/dist/node/include/node.h +1593 -0
  138. package/dist/node/include/node_api.h +265 -0
  139. package/dist/node/include/node_api_internals.h +48 -0
  140. package/dist/node/include/node_api_types.h +56 -0
  141. package/dist/node/include/node_binding.h +161 -0
  142. package/dist/node/include/node_blob.h +159 -0
  143. package/dist/node/include/node_bob-inl.h +36 -0
  144. package/dist/node/include/node_bob.h +107 -0
  145. package/dist/node/include/node_buffer.h +92 -0
  146. package/dist/node/include/node_builtins.h +220 -0
  147. package/dist/node/include/node_config_file.h +46 -0
  148. package/dist/node/include/node_constants.h +82 -0
  149. package/dist/node/include/node_context_data.h +168 -0
  150. package/dist/node/include/node_contextify.h +204 -0
  151. package/dist/node/include/node_crypto.h +56 -0
  152. package/dist/node/include/node_debug.h +30 -0
  153. package/dist/node/include/node_dir.h +52 -0
  154. package/dist/node/include/node_dotenv.h +45 -0
  155. package/dist/node/include/node_errors.h +380 -0
  156. package/dist/node/include/node_exit_code.h +54 -0
  157. package/dist/node/include/node_external_reference.h +165 -0
  158. package/dist/node/include/node_file-inl.h +406 -0
  159. package/dist/node/include/node_file.h +537 -0
  160. package/dist/node/include/node_http2.h +1177 -0
  161. package/dist/node/include/node_http2_state.h +159 -0
  162. package/dist/node/include/node_http_common-inl.h +202 -0
  163. package/dist/node/include/node_http_common.h +535 -0
  164. package/dist/node/include/node_i18n.h +132 -0
  165. package/dist/node/include/node_internals.h +483 -0
  166. package/dist/node/include/node_main_instance.h +67 -0
  167. package/dist/node/include/node_mem-inl.h +113 -0
  168. package/dist/node/include/node_mem.h +45 -0
  169. package/dist/node/include/node_messaging.h +389 -0
  170. package/dist/node/include/node_metadata.h +164 -0
  171. package/dist/node/include/node_modules.h +91 -0
  172. package/dist/node/include/node_mutex.h +323 -0
  173. package/dist/node/include/node_object_wrap.h +132 -0
  174. package/dist/node/include/node_options-inl.h +490 -0
  175. package/dist/node/include/node_options.h +615 -0
  176. package/dist/node/include/node_perf.h +166 -0
  177. package/dist/node/include/node_perf_common.h +102 -0
  178. package/dist/node/include/node_platform.h +238 -0
  179. package/dist/node/include/node_process-inl.h +26 -0
  180. package/dist/node/include/node_process.h +112 -0
  181. package/dist/node/include/node_realm-inl.h +151 -0
  182. package/dist/node/include/node_realm.h +183 -0
  183. package/dist/node/include/node_report.h +43 -0
  184. package/dist/node/include/node_revert.h +82 -0
  185. package/dist/node/include/node_root_certs.h +3520 -0
  186. package/dist/node/include/node_sea.h +74 -0
  187. package/dist/node/include/node_shadow_realm.h +46 -0
  188. package/dist/node/include/node_snapshot_builder.h +57 -0
  189. package/dist/node/include/node_snapshotable.h +174 -0
  190. package/dist/node/include/node_sockaddr-inl.h +257 -0
  191. package/dist/node/include/node_sockaddr.h +394 -0
  192. package/dist/node/include/node_sqlite.h +270 -0
  193. package/dist/node/include/node_stat_watcher.h +73 -0
  194. package/dist/node/include/node_task_runner.h +92 -0
  195. package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
  196. package/dist/node/include/node_threadsafe_cow.h +105 -0
  197. package/dist/node/include/node_union_bytes.h +81 -0
  198. package/dist/node/include/node_url.h +96 -0
  199. package/dist/node/include/node_v8.h +77 -0
  200. package/dist/node/include/node_v8_platform-inl.h +185 -0
  201. package/dist/node/include/node_version.h +110 -0
  202. package/dist/node/include/node_wasi.h +184 -0
  203. package/dist/node/include/node_wasm_web_api.h +55 -0
  204. package/dist/node/include/node_watchdog.h +154 -0
  205. package/dist/node/include/node_webstorage.h +60 -0
  206. package/dist/node/include/node_worker.h +158 -0
  207. package/dist/node/include/path.h +33 -0
  208. package/dist/node/include/permission/addon_permission.h +31 -0
  209. package/dist/node/include/permission/child_process_permission.h +31 -0
  210. package/dist/node/include/permission/fs_permission.h +167 -0
  211. package/dist/node/include/permission/inspector_permission.h +31 -0
  212. package/dist/node/include/permission/permission.h +138 -0
  213. package/dist/node/include/permission/permission_base.h +65 -0
  214. package/dist/node/include/permission/wasi_permission.h +31 -0
  215. package/dist/node/include/permission/worker_permission.h +31 -0
  216. package/dist/node/include/pipe_wrap.h +80 -0
  217. package/dist/node/include/quic/application.h +159 -0
  218. package/dist/node/include/quic/bindingdata.h +272 -0
  219. package/dist/node/include/quic/cid.h +127 -0
  220. package/dist/node/include/quic/data.h +148 -0
  221. package/dist/node/include/quic/defs.h +245 -0
  222. package/dist/node/include/quic/endpoint.h +458 -0
  223. package/dist/node/include/quic/http3.h +15 -0
  224. package/dist/node/include/quic/logstream.h +81 -0
  225. package/dist/node/include/quic/packet.h +152 -0
  226. package/dist/node/include/quic/preferredaddress.h +72 -0
  227. package/dist/node/include/quic/session.h +443 -0
  228. package/dist/node/include/quic/sessionticket.h +108 -0
  229. package/dist/node/include/quic/streams.h +232 -0
  230. package/dist/node/include/quic/tlscontext.h +227 -0
  231. package/dist/node/include/quic/tokens.h +256 -0
  232. package/dist/node/include/quic/transportparams.h +165 -0
  233. package/dist/node/include/req_wrap-inl.h +171 -0
  234. package/dist/node/include/req_wrap.h +77 -0
  235. package/dist/node/include/spawn_sync.h +243 -0
  236. package/dist/node/include/stream_base-inl.h +173 -0
  237. package/dist/node/include/stream_base.h +478 -0
  238. package/dist/node/include/stream_pipe.h +76 -0
  239. package/dist/node/include/stream_wrap.h +132 -0
  240. package/dist/node/include/string_bytes.h +113 -0
  241. package/dist/node/include/string_decoder-inl.h +31 -0
  242. package/dist/node/include/string_decoder.h +49 -0
  243. package/dist/node/include/tcp_wrap.h +105 -0
  244. package/dist/node/include/threadpoolwork-inl.h +70 -0
  245. package/dist/node/include/timer_wrap-inl.h +32 -0
  246. package/dist/node/include/timer_wrap.h +85 -0
  247. package/dist/node/include/timers.h +70 -0
  248. package/dist/node/include/tracing/agent.h +195 -0
  249. package/dist/node/include/tracing/node_trace_buffer.h +83 -0
  250. package/dist/node/include/tracing/node_trace_writer.h +75 -0
  251. package/dist/node/include/tracing/trace_event.h +722 -0
  252. package/dist/node/include/tracing/trace_event_common.h +1109 -0
  253. package/dist/node/include/tracing/traced_value.h +129 -0
  254. package/dist/node/include/tty_wrap.h +65 -0
  255. package/dist/node/include/udp_wrap.h +230 -0
  256. package/dist/node/include/undici_version.h +6 -0
  257. package/dist/node/include/util-inl.h +700 -0
  258. package/dist/node/include/util.h +1021 -0
  259. package/dist/node/include/uv/aix.h +32 -0
  260. package/dist/node/include/uv/bsd.h +34 -0
  261. package/dist/node/include/uv/darwin.h +61 -0
  262. package/dist/node/include/uv/errno.h +483 -0
  263. package/dist/node/include/uv/linux.h +34 -0
  264. package/dist/node/include/uv/os390.h +33 -0
  265. package/dist/node/include/uv/posix.h +31 -0
  266. package/dist/node/include/uv/sunos.h +44 -0
  267. package/dist/node/include/uv/threadpool.h +37 -0
  268. package/dist/node/include/uv/tree.h +521 -0
  269. package/dist/node/include/uv/unix.h +512 -0
  270. package/dist/node/include/uv/version.h +43 -0
  271. package/dist/node/include/uv/win.h +698 -0
  272. package/dist/node/include/uv.h +1990 -0
  273. package/dist/node/include/v8-array-buffer.h +525 -0
  274. package/dist/node/include/v8-callbacks.h +462 -0
  275. package/dist/node/include/v8-container.h +183 -0
  276. package/dist/node/include/v8-context.h +485 -0
  277. package/dist/node/include/v8-cppgc.h +245 -0
  278. package/dist/node/include/v8-data.h +80 -0
  279. package/dist/node/include/v8-date.h +48 -0
  280. package/dist/node/include/v8-debug.h +168 -0
  281. package/dist/node/include/v8-embedder-heap.h +82 -0
  282. package/dist/node/include/v8-embedder-state-scope.h +52 -0
  283. package/dist/node/include/v8-exception.h +223 -0
  284. package/dist/node/include/v8-extension.h +62 -0
  285. package/dist/node/include/v8-external.h +37 -0
  286. package/dist/node/include/v8-fast-api-calls.h +984 -0
  287. package/dist/node/include/v8-forward.h +82 -0
  288. package/dist/node/include/v8-function-callback.h +607 -0
  289. package/dist/node/include/v8-function.h +140 -0
  290. package/dist/node/include/v8-handle-base.h +137 -0
  291. package/dist/node/include/v8-initialization.h +289 -0
  292. package/dist/node/include/v8-inspector-protocol.h +13 -0
  293. package/dist/node/include/v8-inspector.h +419 -0
  294. package/dist/node/include/v8-internal.h +1397 -0
  295. package/dist/node/include/v8-isolate.h +1767 -0
  296. package/dist/node/include/v8-json.h +47 -0
  297. package/dist/node/include/v8-local-handle.h +758 -0
  298. package/dist/node/include/v8-locker.h +138 -0
  299. package/dist/node/include/v8-maybe.h +160 -0
  300. package/dist/node/include/v8-memory-span.h +198 -0
  301. package/dist/node/include/v8-message.h +233 -0
  302. package/dist/node/include/v8-metrics.h +264 -0
  303. package/dist/node/include/v8-microtask-queue.h +157 -0
  304. package/dist/node/include/v8-microtask.h +28 -0
  305. package/dist/node/include/v8-object.h +824 -0
  306. package/dist/node/include/v8-persistent-handle.h +582 -0
  307. package/dist/node/include/v8-platform.h +1358 -0
  308. package/dist/node/include/v8-primitive-object.h +118 -0
  309. package/dist/node/include/v8-primitive.h +877 -0
  310. package/dist/node/include/v8-profiler.h +1302 -0
  311. package/dist/node/include/v8-promise.h +174 -0
  312. package/dist/node/include/v8-proxy.h +50 -0
  313. package/dist/node/include/v8-regexp.h +106 -0
  314. package/dist/node/include/v8-script.h +904 -0
  315. package/dist/node/include/v8-snapshot.h +266 -0
  316. package/dist/node/include/v8-source-location.h +92 -0
  317. package/dist/node/include/v8-statistics.h +238 -0
  318. package/dist/node/include/v8-template.h +1297 -0
  319. package/dist/node/include/v8-traced-handle.h +432 -0
  320. package/dist/node/include/v8-typed-array.h +390 -0
  321. package/dist/node/include/v8-unwinder-state.h +31 -0
  322. package/dist/node/include/v8-unwinder.h +132 -0
  323. package/dist/node/include/v8-util.h +665 -0
  324. package/dist/node/include/v8-value-serializer-version.h +24 -0
  325. package/dist/node/include/v8-value-serializer.h +316 -0
  326. package/dist/node/include/v8-value.h +655 -0
  327. package/dist/node/include/v8-version-string.h +38 -0
  328. package/dist/node/include/v8-version.h +20 -0
  329. package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
  330. package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
  331. package/dist/node/include/v8-wasm.h +201 -0
  332. package/dist/node/include/v8-weak-callback-info.h +80 -0
  333. package/dist/node/include/v8.h +88 -0
  334. package/dist/node/include/v8config.h +981 -0
  335. package/dist/node/include/zlib_version.h +6 -0
  336. package/dist/node/libnode.dll +0 -0
  337. package/dist/node/libnode.lib +0 -0
  338. package/dist/node/libnodebuildinfo.json +10 -0
  339. package/dist/node/link_node.lib +0 -0
  340. package/dist/node/link_node.node +0 -0
  341. package/index.js +5 -0
  342. package/libnode.release.json +8 -0
  343. package/package.json +29 -1
@@ -0,0 +1,394 @@
1
+ #ifndef SRC_NODE_SOCKADDR_H_
2
+ #define SRC_NODE_SOCKADDR_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "env.h"
7
+ #include "memory_tracker.h"
8
+ #include "base_object.h"
9
+ #include "node.h"
10
+ #include "node_worker.h"
11
+ #include "uv.h"
12
+ #include "v8.h"
13
+
14
+ #include <compare>
15
+ #include <list>
16
+ #include <memory>
17
+ #include <string>
18
+ #include <unordered_map>
19
+
20
+ namespace node {
21
+
22
+ class Environment;
23
+
24
+ class SocketAddress : public MemoryRetainer {
25
+ public:
26
+ struct Hash {
27
+ size_t operator()(const SocketAddress& addr) const;
28
+ };
29
+
30
+ inline bool operator==(const SocketAddress& other) const;
31
+ inline bool operator!=(const SocketAddress& other) const;
32
+
33
+ inline std::partial_ordering operator<=>(const SocketAddress& other) const;
34
+
35
+ inline static bool is_numeric_host(const char* hostname);
36
+ inline static bool is_numeric_host(const char* hostname, int family);
37
+
38
+ // Returns true if converting {family, host, port} to *addr succeeded.
39
+ static bool ToSockAddr(
40
+ int32_t family,
41
+ const char* host,
42
+ uint32_t port,
43
+ sockaddr_storage* addr);
44
+
45
+ // Returns true if converting {family, host, port} to *addr succeeded.
46
+ static bool New(
47
+ int32_t family,
48
+ const char* host,
49
+ uint32_t port,
50
+ SocketAddress* addr);
51
+
52
+ static bool New(
53
+ const char* host,
54
+ uint32_t port,
55
+ SocketAddress* addr);
56
+
57
+ // Returns the port for an IPv4 or IPv6 address.
58
+ inline static int GetPort(const sockaddr* addr);
59
+ inline static int GetPort(const sockaddr_storage* addr);
60
+
61
+ // Returns the numeric host as a string for an IPv4 or IPv6 address.
62
+ inline static std::string GetAddress(const sockaddr* addr);
63
+ inline static std::string GetAddress(const sockaddr_storage* addr);
64
+
65
+ // Returns the struct length for an IPv4, IPv6 or UNIX domain.
66
+ inline static size_t GetLength(const sockaddr* addr);
67
+ inline static size_t GetLength(const sockaddr_storage* addr);
68
+
69
+ SocketAddress() = default;
70
+
71
+ inline explicit SocketAddress(const sockaddr* addr);
72
+ inline SocketAddress(const SocketAddress& addr);
73
+ inline SocketAddress& operator=(const sockaddr* other);
74
+ inline SocketAddress& operator=(const SocketAddress& other);
75
+
76
+ inline const sockaddr& operator*() const;
77
+ inline const sockaddr* operator->() const;
78
+
79
+ inline const sockaddr* data() const;
80
+ inline const uint8_t* raw() const;
81
+ inline sockaddr* storage();
82
+ inline size_t length() const;
83
+
84
+ inline int family() const;
85
+ inline std::string address() const;
86
+ inline int port() const;
87
+
88
+ // Returns true if the given other SocketAddress is a match
89
+ // for this one. The addresses are a match if:
90
+ // 1. They are the same family and match identically
91
+ // 2. They are different family but match semantically (
92
+ // for instance, an IPv4 address in IPv6 notation)
93
+ bool is_match(const SocketAddress& other) const;
94
+
95
+ // Compares this SocketAddress to the given other SocketAddress.
96
+ std::partial_ordering compare(const SocketAddress& other) const;
97
+
98
+ // Returns true if this SocketAddress is within the subnet
99
+ // identified by the given network address and CIDR prefix.
100
+ bool is_in_network(const SocketAddress& network, int prefix) const;
101
+
102
+ // If the SocketAddress is an IPv6 address, returns the
103
+ // current value of the IPv6 flow label, if set. Otherwise
104
+ // returns 0.
105
+ inline uint32_t flow_label() const;
106
+
107
+ // If the SocketAddress is an IPv6 address, sets the
108
+ // current value of the IPv6 flow label. If not an
109
+ // IPv6 address, set_flow_label is a non-op. It
110
+ // is important to note that the flow label,
111
+ // while represented as an uint32_t, the flow
112
+ // label is strictly limited to 20 bits, and
113
+ // this will assert if any value larger than
114
+ // 20-bits is specified.
115
+ inline void set_flow_label(uint32_t label = 0);
116
+
117
+ inline void Update(uint8_t* data, size_t len);
118
+ inline void Update(const sockaddr* data, size_t len);
119
+
120
+ static SocketAddress FromSockName(const uv_udp_t& handle);
121
+ static SocketAddress FromSockName(const uv_tcp_t& handle);
122
+ static SocketAddress FromPeerName(const uv_udp_t& handle);
123
+ static SocketAddress FromPeerName(const uv_tcp_t& handle);
124
+
125
+ inline v8::MaybeLocal<v8::Object> ToJS(
126
+ Environment* env,
127
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>()) const;
128
+
129
+ inline std::string ToString() const;
130
+
131
+ SET_NO_MEMORY_INFO()
132
+ SET_MEMORY_INFO_NAME(SocketAddress)
133
+ SET_SELF_SIZE(SocketAddress)
134
+
135
+ template <typename T>
136
+ using Map = std::unordered_map<SocketAddress, T, Hash>;
137
+
138
+ private:
139
+ sockaddr_storage address_;
140
+ };
141
+
142
+ class SocketAddressBase : public BaseObject {
143
+ public:
144
+ static bool HasInstance(Environment* env, v8::Local<v8::Value> value);
145
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
146
+ Environment* env);
147
+ static void Initialize(Environment* env, v8::Local<v8::Object> target);
148
+ static BaseObjectPtr<SocketAddressBase> Create(
149
+ Environment* env,
150
+ std::shared_ptr<SocketAddress> address);
151
+
152
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
153
+ static void Detail(const v8::FunctionCallbackInfo<v8::Value>& args);
154
+ static void LegacyDetail(const v8::FunctionCallbackInfo<v8::Value>& args);
155
+ static void GetFlowLabel(const v8::FunctionCallbackInfo<v8::Value>& args);
156
+
157
+ SocketAddressBase(
158
+ Environment* env,
159
+ v8::Local<v8::Object> wrap,
160
+ std::shared_ptr<SocketAddress> address);
161
+
162
+ inline const std::shared_ptr<SocketAddress>& address() const {
163
+ return address_;
164
+ }
165
+
166
+ void MemoryInfo(MemoryTracker* tracker) const override;
167
+ SET_MEMORY_INFO_NAME(SocketAddressBase)
168
+ SET_SELF_SIZE(SocketAddressBase)
169
+
170
+ BaseObject::TransferMode GetTransferMode() const override {
171
+ return TransferMode::kCloneable;
172
+ }
173
+ std::unique_ptr<worker::TransferData> CloneForMessaging() const override;
174
+
175
+ class TransferData : public worker::TransferData {
176
+ public:
177
+ inline explicit TransferData(const SocketAddressBase* wrap)
178
+ : address_(wrap->address_) {}
179
+
180
+ inline explicit TransferData(std::shared_ptr<SocketAddress> address)
181
+ : address_(std::move(address)) {}
182
+
183
+ BaseObjectPtr<BaseObject> Deserialize(
184
+ Environment* env,
185
+ v8::Local<v8::Context> context,
186
+ std::unique_ptr<worker::TransferData> self) override;
187
+
188
+ void MemoryInfo(MemoryTracker* tracker) const override;
189
+ SET_MEMORY_INFO_NAME(SocketAddressBase::TransferData)
190
+ SET_SELF_SIZE(TransferData)
191
+
192
+ private:
193
+ std::shared_ptr<SocketAddress> address_;
194
+ };
195
+
196
+ private:
197
+ std::shared_ptr<SocketAddress> address_;
198
+ };
199
+
200
+ template <typename T>
201
+ class SocketAddressLRU : public MemoryRetainer {
202
+ public:
203
+ using Type = typename T::Type;
204
+
205
+ inline explicit SocketAddressLRU(size_t max_size);
206
+
207
+ // If the item already exists, returns a reference to
208
+ // the existing item, adjusting items position in the
209
+ // LRU. If the item does not exist, emplaces the item
210
+ // and returns the new item.
211
+ Type* Upsert(const SocketAddress& address);
212
+
213
+ // Returns a reference to the item if it exists, or
214
+ // nullptr. The position in the LRU is not modified.
215
+ Type* Peek(const SocketAddress& address) const;
216
+
217
+ size_t size() const { return map_.size(); }
218
+ size_t max_size() const { return max_size_; }
219
+
220
+ void MemoryInfo(MemoryTracker* tracker) const override;
221
+ SET_MEMORY_INFO_NAME(SocketAddressLRU)
222
+ SET_SELF_SIZE(SocketAddressLRU)
223
+
224
+ private:
225
+ using Pair = std::pair<SocketAddress, Type>;
226
+ using Iterator = typename std::list<Pair>::iterator;
227
+
228
+ void CheckExpired();
229
+
230
+ std::list<Pair> list_;
231
+ SocketAddress::Map<Iterator> map_;
232
+ size_t max_size_;
233
+ };
234
+
235
+ // A BlockList is used to evaluate whether a given
236
+ // SocketAddress should be accepted for inbound or
237
+ // outbound network activity.
238
+ class SocketAddressBlockList : public MemoryRetainer {
239
+ public:
240
+ explicit SocketAddressBlockList(
241
+ std::shared_ptr<SocketAddressBlockList> parent = {});
242
+ ~SocketAddressBlockList() = default;
243
+
244
+ void AddSocketAddress(const std::shared_ptr<SocketAddress>& address);
245
+
246
+ void RemoveSocketAddress(const std::shared_ptr<SocketAddress>& address);
247
+
248
+ void AddSocketAddressRange(
249
+ const std::shared_ptr<SocketAddress>& start,
250
+ const std::shared_ptr<SocketAddress>& end);
251
+
252
+ void AddSocketAddressMask(
253
+ const std::shared_ptr<SocketAddress>& address,
254
+ int prefix);
255
+
256
+ bool Apply(const std::shared_ptr<SocketAddress>& address);
257
+
258
+ size_t size() const { return rules_.size(); }
259
+
260
+ v8::MaybeLocal<v8::Array> ListRules(Environment* env);
261
+
262
+ struct Rule : public MemoryRetainer {
263
+ virtual bool Apply(const std::shared_ptr<SocketAddress>& address) = 0;
264
+ inline v8::MaybeLocal<v8::Value> ToV8String(Environment* env);
265
+ virtual std::string ToString() = 0;
266
+ };
267
+
268
+ struct SocketAddressRule final : Rule {
269
+ std::shared_ptr<SocketAddress> address;
270
+
271
+ explicit SocketAddressRule(const std::shared_ptr<SocketAddress>& address);
272
+
273
+ bool Apply(const std::shared_ptr<SocketAddress>& address) override;
274
+ std::string ToString() override;
275
+
276
+ void MemoryInfo(node::MemoryTracker* tracker) const override;
277
+ SET_MEMORY_INFO_NAME(SocketAddressRule)
278
+ SET_SELF_SIZE(SocketAddressRule)
279
+ };
280
+
281
+ struct SocketAddressRangeRule final : Rule {
282
+ std::shared_ptr<SocketAddress> start;
283
+ std::shared_ptr<SocketAddress> end;
284
+
285
+ SocketAddressRangeRule(
286
+ const std::shared_ptr<SocketAddress>& start,
287
+ const std::shared_ptr<SocketAddress>& end);
288
+
289
+ bool Apply(const std::shared_ptr<SocketAddress>& address) override;
290
+ std::string ToString() override;
291
+
292
+ void MemoryInfo(node::MemoryTracker* tracker) const override;
293
+ SET_MEMORY_INFO_NAME(SocketAddressRangeRule)
294
+ SET_SELF_SIZE(SocketAddressRangeRule)
295
+ };
296
+
297
+ struct SocketAddressMaskRule final : Rule {
298
+ std::shared_ptr<SocketAddress> network;
299
+ int prefix;
300
+
301
+ SocketAddressMaskRule(
302
+ const std::shared_ptr<SocketAddress>& address,
303
+ int prefix);
304
+
305
+ bool Apply(const std::shared_ptr<SocketAddress>& address) override;
306
+ std::string ToString() override;
307
+
308
+ void MemoryInfo(node::MemoryTracker* tracker) const override;
309
+ SET_MEMORY_INFO_NAME(SocketAddressMaskRule)
310
+ SET_SELF_SIZE(SocketAddressMaskRule)
311
+ };
312
+
313
+ void MemoryInfo(node::MemoryTracker* tracker) const override;
314
+ SET_MEMORY_INFO_NAME(SocketAddressBlockList)
315
+ SET_SELF_SIZE(SocketAddressBlockList)
316
+
317
+ private:
318
+ bool ListRules(Environment* env, v8::LocalVector<v8::Value>* vec);
319
+
320
+ std::shared_ptr<SocketAddressBlockList> parent_;
321
+ std::list<std::unique_ptr<Rule>> rules_;
322
+ SocketAddress::Map<std::list<std::unique_ptr<Rule>>::iterator> address_rules_;
323
+
324
+ Mutex mutex_;
325
+ };
326
+
327
+ class SocketAddressBlockListWrap : public BaseObject {
328
+ public:
329
+ static bool HasInstance(Environment* env, v8::Local<v8::Value> value);
330
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
331
+ Environment* env);
332
+ static void Initialize(v8::Local<v8::Object> target,
333
+ v8::Local<v8::Value> unused,
334
+ v8::Local<v8::Context> context,
335
+ void* priv);
336
+
337
+ static BaseObjectPtr<SocketAddressBlockListWrap> New(Environment* env);
338
+ static BaseObjectPtr<SocketAddressBlockListWrap> New(
339
+ Environment* env,
340
+ std::shared_ptr<SocketAddressBlockList> blocklist);
341
+
342
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
343
+ static void AddAddress(const v8::FunctionCallbackInfo<v8::Value>& args);
344
+ static void AddRange(const v8::FunctionCallbackInfo<v8::Value>& args);
345
+ static void AddSubnet(const v8::FunctionCallbackInfo<v8::Value>& args);
346
+ static void Check(const v8::FunctionCallbackInfo<v8::Value>& args);
347
+ static void GetRules(const v8::FunctionCallbackInfo<v8::Value>& args);
348
+
349
+ SocketAddressBlockListWrap(
350
+ Environment* env,
351
+ v8::Local<v8::Object> wrap,
352
+ std::shared_ptr<SocketAddressBlockList> blocklist =
353
+ std::make_shared<SocketAddressBlockList>());
354
+
355
+ void MemoryInfo(node::MemoryTracker* tracker) const override;
356
+ SET_MEMORY_INFO_NAME(SocketAddressBlockListWrap)
357
+ SET_SELF_SIZE(SocketAddressBlockListWrap)
358
+
359
+ BaseObject::TransferMode GetTransferMode() const override {
360
+ return TransferMode::kCloneable;
361
+ }
362
+ std::unique_ptr<worker::TransferData> CloneForMessaging() const override;
363
+
364
+ class TransferData : public worker::TransferData {
365
+ public:
366
+ inline explicit TransferData(const SocketAddressBlockListWrap* wrap)
367
+ : blocklist_(wrap->blocklist_) {}
368
+
369
+ inline explicit TransferData(
370
+ std::shared_ptr<SocketAddressBlockList> blocklist)
371
+ : blocklist_(std::move(blocklist)) {}
372
+
373
+ BaseObjectPtr<BaseObject> Deserialize(
374
+ Environment* env,
375
+ v8::Local<v8::Context> context,
376
+ std::unique_ptr<worker::TransferData> self) override;
377
+
378
+ void MemoryInfo(MemoryTracker* tracker) const override;
379
+ SET_MEMORY_INFO_NAME(SocketAddressBlockListWrap::TransferData)
380
+ SET_SELF_SIZE(TransferData)
381
+
382
+ private:
383
+ std::shared_ptr<SocketAddressBlockList> blocklist_;
384
+ };
385
+
386
+ private:
387
+ std::shared_ptr<SocketAddressBlockList> blocklist_;
388
+ };
389
+
390
+ } // namespace node
391
+
392
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
393
+
394
+ #endif // SRC_NODE_SOCKADDR_H_
@@ -0,0 +1,270 @@
1
+ #ifndef SRC_NODE_SQLITE_H_
2
+ #define SRC_NODE_SQLITE_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "base_object.h"
7
+ #include "node_mem.h"
8
+ #include "sqlite3.h"
9
+ #include "util.h"
10
+
11
+ #include <map>
12
+ #include <unordered_set>
13
+
14
+ namespace node {
15
+ namespace sqlite {
16
+
17
+ class DatabaseOpenConfiguration {
18
+ public:
19
+ explicit DatabaseOpenConfiguration(std::string&& location)
20
+ : location_(std::move(location)) {}
21
+
22
+ inline const std::string& location() const { return location_; }
23
+
24
+ inline bool get_read_only() const { return read_only_; }
25
+
26
+ inline void set_read_only(bool flag) { read_only_ = flag; }
27
+
28
+ inline bool get_enable_foreign_keys() const { return enable_foreign_keys_; }
29
+
30
+ inline void set_enable_foreign_keys(bool flag) {
31
+ enable_foreign_keys_ = flag;
32
+ }
33
+
34
+ inline bool get_enable_dqs() const { return enable_dqs_; }
35
+
36
+ inline void set_enable_dqs(bool flag) { enable_dqs_ = flag; }
37
+
38
+ inline void set_timeout(int timeout) { timeout_ = timeout; }
39
+
40
+ inline int get_timeout() { return timeout_; }
41
+
42
+ inline void set_use_big_ints(bool flag) { use_big_ints_ = flag; }
43
+
44
+ inline bool get_use_big_ints() const { return use_big_ints_; }
45
+
46
+ inline void set_return_arrays(bool flag) { return_arrays_ = flag; }
47
+
48
+ inline bool get_return_arrays() const { return return_arrays_; }
49
+
50
+ inline void set_allow_bare_named_params(bool flag) {
51
+ allow_bare_named_params_ = flag;
52
+ }
53
+
54
+ inline bool get_allow_bare_named_params() const {
55
+ return allow_bare_named_params_;
56
+ }
57
+
58
+ inline void set_allow_unknown_named_params(bool flag) {
59
+ allow_unknown_named_params_ = flag;
60
+ }
61
+
62
+ inline bool get_allow_unknown_named_params() const {
63
+ return allow_unknown_named_params_;
64
+ }
65
+
66
+ private:
67
+ std::string location_;
68
+ bool read_only_ = false;
69
+ bool enable_foreign_keys_ = true;
70
+ bool enable_dqs_ = false;
71
+ int timeout_ = 0;
72
+ bool use_big_ints_ = false;
73
+ bool return_arrays_ = false;
74
+ bool allow_bare_named_params_ = true;
75
+ bool allow_unknown_named_params_ = false;
76
+ };
77
+
78
+ class StatementSync;
79
+ class BackupJob;
80
+
81
+ class DatabaseSync : public BaseObject {
82
+ public:
83
+ DatabaseSync(Environment* env,
84
+ v8::Local<v8::Object> object,
85
+ DatabaseOpenConfiguration&& open_config,
86
+ bool open,
87
+ bool allow_load_extension);
88
+ void MemoryInfo(MemoryTracker* tracker) const override;
89
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
90
+ static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
91
+ static void IsOpenGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
92
+ static void IsTransactionGetter(
93
+ const v8::FunctionCallbackInfo<v8::Value>& args);
94
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
95
+ static void Prepare(const v8::FunctionCallbackInfo<v8::Value>& args);
96
+ static void Exec(const v8::FunctionCallbackInfo<v8::Value>& args);
97
+ static void Location(const v8::FunctionCallbackInfo<v8::Value>& args);
98
+ static void CustomFunction(const v8::FunctionCallbackInfo<v8::Value>& args);
99
+ static void AggregateFunction(
100
+ const v8::FunctionCallbackInfo<v8::Value>& args);
101
+ static void CreateSession(const v8::FunctionCallbackInfo<v8::Value>& args);
102
+ static void ApplyChangeset(const v8::FunctionCallbackInfo<v8::Value>& args);
103
+ static void EnableLoadExtension(
104
+ const v8::FunctionCallbackInfo<v8::Value>& args);
105
+ static void LoadExtension(const v8::FunctionCallbackInfo<v8::Value>& args);
106
+ void FinalizeStatements();
107
+ void RemoveBackup(BackupJob* backup);
108
+ void AddBackup(BackupJob* backup);
109
+ void FinalizeBackups();
110
+ void UntrackStatement(StatementSync* statement);
111
+ bool IsOpen();
112
+ bool use_big_ints() const { return open_config_.get_use_big_ints(); }
113
+ bool return_arrays() const { return open_config_.get_return_arrays(); }
114
+ bool allow_bare_named_params() const {
115
+ return open_config_.get_allow_bare_named_params();
116
+ }
117
+ bool allow_unknown_named_params() const {
118
+ return open_config_.get_allow_unknown_named_params();
119
+ }
120
+ sqlite3* Connection();
121
+
122
+ // In some situations, such as when using custom functions, it is possible
123
+ // that SQLite reports an error while JavaScript already has a pending
124
+ // exception. In this case, the SQLite error should be ignored. These methods
125
+ // enable that use case.
126
+ void SetIgnoreNextSQLiteError(bool ignore);
127
+ bool ShouldIgnoreSQLiteError();
128
+
129
+ SET_MEMORY_INFO_NAME(DatabaseSync)
130
+ SET_SELF_SIZE(DatabaseSync)
131
+
132
+ private:
133
+ bool Open();
134
+ void DeleteSessions();
135
+
136
+ ~DatabaseSync() override;
137
+ DatabaseOpenConfiguration open_config_;
138
+ bool allow_load_extension_;
139
+ bool enable_load_extension_;
140
+ sqlite3* connection_;
141
+ bool ignore_next_sqlite_error_;
142
+
143
+ std::set<BackupJob*> backups_;
144
+ std::set<sqlite3_session*> sessions_;
145
+ std::unordered_set<StatementSync*> statements_;
146
+
147
+ friend class Session;
148
+ };
149
+
150
+ class StatementSync : public BaseObject {
151
+ public:
152
+ StatementSync(Environment* env,
153
+ v8::Local<v8::Object> object,
154
+ BaseObjectPtr<DatabaseSync> db,
155
+ sqlite3_stmt* stmt);
156
+ void MemoryInfo(MemoryTracker* tracker) const override;
157
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
158
+ Environment* env);
159
+ static BaseObjectPtr<StatementSync> Create(Environment* env,
160
+ BaseObjectPtr<DatabaseSync> db,
161
+ sqlite3_stmt* stmt);
162
+ static void All(const v8::FunctionCallbackInfo<v8::Value>& args);
163
+ static void Iterate(const v8::FunctionCallbackInfo<v8::Value>& args);
164
+ static void Get(const v8::FunctionCallbackInfo<v8::Value>& args);
165
+ static void Run(const v8::FunctionCallbackInfo<v8::Value>& args);
166
+ static void Columns(const v8::FunctionCallbackInfo<v8::Value>& args);
167
+ static void SourceSQLGetter(const v8::FunctionCallbackInfo<v8::Value>& args);
168
+ static void ExpandedSQLGetter(
169
+ const v8::FunctionCallbackInfo<v8::Value>& args);
170
+ static void SetAllowBareNamedParameters(
171
+ const v8::FunctionCallbackInfo<v8::Value>& args);
172
+ static void SetAllowUnknownNamedParameters(
173
+ const v8::FunctionCallbackInfo<v8::Value>& args);
174
+ static void SetReadBigInts(const v8::FunctionCallbackInfo<v8::Value>& args);
175
+ static void SetReturnArrays(const v8::FunctionCallbackInfo<v8::Value>& args);
176
+ v8::MaybeLocal<v8::Value> ColumnToValue(const int column);
177
+ v8::MaybeLocal<v8::Name> ColumnNameToName(const int column);
178
+ void Finalize();
179
+ bool IsFinalized();
180
+
181
+ SET_MEMORY_INFO_NAME(StatementSync)
182
+ SET_SELF_SIZE(StatementSync)
183
+
184
+ private:
185
+ ~StatementSync() override;
186
+ BaseObjectPtr<DatabaseSync> db_;
187
+ sqlite3_stmt* statement_;
188
+ bool return_arrays_ = false;
189
+ bool use_big_ints_;
190
+ bool allow_bare_named_params_;
191
+ bool allow_unknown_named_params_;
192
+ std::optional<std::map<std::string, std::string>> bare_named_params_;
193
+ bool BindParams(const v8::FunctionCallbackInfo<v8::Value>& args);
194
+ bool BindValue(const v8::Local<v8::Value>& value, const int index);
195
+
196
+ friend class StatementSyncIterator;
197
+ };
198
+
199
+ class StatementSyncIterator : public BaseObject {
200
+ public:
201
+ StatementSyncIterator(Environment* env,
202
+ v8::Local<v8::Object> object,
203
+ BaseObjectPtr<StatementSync> stmt);
204
+ void MemoryInfo(MemoryTracker* tracker) const override;
205
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
206
+ Environment* env);
207
+ static BaseObjectPtr<StatementSyncIterator> Create(
208
+ Environment* env, BaseObjectPtr<StatementSync> stmt);
209
+ static void Next(const v8::FunctionCallbackInfo<v8::Value>& args);
210
+ static void Return(const v8::FunctionCallbackInfo<v8::Value>& args);
211
+
212
+ SET_MEMORY_INFO_NAME(StatementSyncIterator)
213
+ SET_SELF_SIZE(StatementSyncIterator)
214
+
215
+ private:
216
+ ~StatementSyncIterator() override;
217
+ BaseObjectPtr<StatementSync> stmt_;
218
+ bool done_;
219
+ };
220
+
221
+ using Sqlite3ChangesetGenFunc = int (*)(sqlite3_session*, int*, void**);
222
+
223
+ class Session : public BaseObject {
224
+ public:
225
+ Session(Environment* env,
226
+ v8::Local<v8::Object> object,
227
+ BaseObjectWeakPtr<DatabaseSync> database,
228
+ sqlite3_session* session);
229
+ ~Session() override;
230
+ template <Sqlite3ChangesetGenFunc sqliteChangesetFunc>
231
+ static void Changeset(const v8::FunctionCallbackInfo<v8::Value>& args);
232
+ static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
233
+ static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
234
+ Environment* env);
235
+ static BaseObjectPtr<Session> Create(Environment* env,
236
+ BaseObjectWeakPtr<DatabaseSync> database,
237
+ sqlite3_session* session);
238
+
239
+ void MemoryInfo(MemoryTracker* tracker) const override;
240
+ SET_MEMORY_INFO_NAME(Session)
241
+ SET_SELF_SIZE(Session)
242
+
243
+ private:
244
+ void Delete();
245
+ sqlite3_session* session_;
246
+ BaseObjectWeakPtr<DatabaseSync> database_; // The Parent Database
247
+ };
248
+
249
+ class UserDefinedFunction {
250
+ public:
251
+ UserDefinedFunction(Environment* env,
252
+ v8::Local<v8::Function> fn,
253
+ DatabaseSync* db,
254
+ bool use_bigint_args);
255
+ ~UserDefinedFunction();
256
+ static void xFunc(sqlite3_context* ctx, int argc, sqlite3_value** argv);
257
+ static void xDestroy(void* self);
258
+
259
+ private:
260
+ Environment* env_;
261
+ v8::Global<v8::Function> fn_;
262
+ DatabaseSync* db_;
263
+ bool use_bigint_args_;
264
+ };
265
+
266
+ } // namespace sqlite
267
+ } // namespace node
268
+
269
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
270
+ #endif // SRC_NODE_SQLITE_H_