diff --git a/node.gyp b/node.gyp index e199ac99ce7799..3c78348b2080aa 100644 --- a/node.gyp +++ b/node.gyp @@ -713,6 +713,7 @@ 'src/node_perf_common.h', 'src/node_platform.h', 'src/node_process.h', + 'src/node_process-inl.h', 'src/node_report.h', 'src/node_revert.h', 'src/node_root_certs.h', diff --git a/src/api/hooks.cc b/src/api/hooks.cc index 84c91a2100b156..79fa896a10e91d 100644 --- a/src/api/hooks.cc +++ b/src/api/hooks.cc @@ -1,6 +1,6 @@ #include "env-inl.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "async_wrap.h" namespace node { diff --git a/src/env.cc b/src/env.cc index 179a553e96592f..30b7ab671f5373 100644 --- a/src/env.cc +++ b/src/env.cc @@ -9,7 +9,7 @@ #include "node_errors.h" #include "node_internals.h" #include "node_options-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_v8_platform-inl.h" #include "node_worker.h" #include "req_wrap-inl.h" diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index 81dece656fc3bb..ebe451106b24af 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -12,7 +12,7 @@ #include "node_errors.h" #include "node_internals.h" #include "node_options-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_url.h" #include "util-inl.h" #include "timer_wrap.h" diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 90484774eb29ab..1da35f9f2fdaa3 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -5,7 +5,7 @@ #include "node_contextify.h" #include "node_errors.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_url.h" #include "node_watchdog.h" #include "util-inl.h" diff --git a/src/node.cc b/src/node.cc index 905afd8c235b7b..b3823235def9bf 100644 --- a/src/node.cc +++ b/src/node.cc @@ -34,7 +34,7 @@ #include "node_native_module_env.h" #include "node_options-inl.h" #include "node_perf.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_report.h" #include "node_revert.h" #include "node_v8_platform-inl.h" diff --git a/src/node_crypto.cc b/src/node_crypto.cc index bd40705e6b1ae0..61db9f04bba143 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -27,7 +27,7 @@ #include "node_crypto_groups.h" #include "node_errors.h" #include "node_mutex.h" -#include "node_process.h" +#include "node_process-inl.h" #include "allocated_buffer-inl.h" #include "tls_wrap.h" // TLSWrap diff --git a/src/node_dir.cc b/src/node_dir.cc index ac5739b99325c5..a6800a8350d766 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -1,6 +1,6 @@ #include "node_dir.h" #include "node_file-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "memory_tracker-inl.h" #include "util.h" diff --git a/src/node_env_var.cc b/src/node_env_var.cc index 2b118326e5c4f6..9192ea334be4c1 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -1,7 +1,7 @@ #include "debug_utils-inl.h" #include "env-inl.h" #include "node_errors.h" -#include "node_process.h" +#include "node_process-inl.h" #include // tzset(), _tzset() diff --git a/src/node_errors.cc b/src/node_errors.cc index c69ced947a4e33..43e9705ec89800 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -5,7 +5,7 @@ #include "node_errors.h" #include "node_internals.h" #include "node_report.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_v8_platform-inl.h" #include "util-inl.h" diff --git a/src/node_file.cc b/src/node_file.cc index 6f565d89fb13d2..58727908a2cfd9 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -23,7 +23,7 @@ #include "aliased_buffer.h" #include "memory_tracker-inl.h" #include "node_buffer.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_stat_watcher.h" #include "util-inl.h" diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 804d520497cf3a..24b0c48bd76a02 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -6,7 +6,7 @@ #include "node_contextify.h" #include "node_buffer.h" #include "node_errors.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" using node::contextify::ContextifyContext; diff --git a/src/node_perf.cc b/src/node_perf.cc index 42bfdd25d29856..546cbfc911485e 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -3,7 +3,7 @@ #include "node_internals.h" #include "node_perf.h" #include "node_buffer.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include diff --git a/src/node_process-inl.h b/src/node_process-inl.h new file mode 100644 index 00000000000000..21a448cfdb2a75 --- /dev/null +++ b/src/node_process-inl.h @@ -0,0 +1,26 @@ +#ifndef SRC_NODE_PROCESS_INL_H_ +#define SRC_NODE_PROCESS_INL_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include "node_process.h" +#include "v8.h" +#include "debug_utils-inl.h" + +namespace node { + +// Call process.emitWarning(str), fmt is a snprintf() format string +template +inline v8::Maybe ProcessEmitWarning(Environment* env, + const char* fmt, + Args&&... args) { + std::string warning = SPrintF(fmt, std::forward(args)...); + + return ProcessEmitWarningGeneric(env, warning.c_str()); +} + +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_NODE_PROCESS_INL_H_ diff --git a/src/node_process.h b/src/node_process.h index 2e87385348d936..14c8f659168975 100644 --- a/src/node_process.h +++ b/src/node_process.h @@ -25,7 +25,10 @@ v8::Maybe ProcessEmitWarningGeneric(Environment* env, const char* type = nullptr, const char* code = nullptr); -v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); +template +inline v8::Maybe ProcessEmitWarning(Environment* env, + const char* fmt, + Args&&... args); v8::Maybe ProcessEmitExperimentalWarning(Environment* env, const char* warning); v8::Maybe ProcessEmitDeprecationWarning(Environment* env, diff --git a/src/node_process_events.cc b/src/node_process_events.cc index 0c149b26e334b0..34f0251cabc02b 100644 --- a/src/node_process_events.cc +++ b/src/node_process_events.cc @@ -1,8 +1,7 @@ -#include #include #include "env-inl.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util.h" namespace node { @@ -84,18 +83,6 @@ Maybe ProcessEmitWarningGeneric(Environment* env, return Just(true); } -// Call process.emitWarning(str), fmt is a snprintf() format string -Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...) { - char warning[1024]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(warning, sizeof(warning), fmt, ap); - va_end(ap); - - return ProcessEmitWarningGeneric(env, warning); -} - std::set experimental_warnings; diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index 4614fdd0711968..29950aeb5b1680 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -4,7 +4,7 @@ #include "node.h" #include "node_errors.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "uv.h" #include "v8.h" diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 5bec65805a1024..a11241cd3a7247 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -2,7 +2,7 @@ #include "node_internals.h" #include "node_options-inl.h" #include "node_metadata.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_revert.h" #include "util-inl.h" diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index b55a2a4387d655..de38e8e7d2ee42 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -2,7 +2,7 @@ #include "node.h" #include "node_errors.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index 693231a3268efb..ac7be821ea4fb3 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -22,7 +22,7 @@ #include "async_wrap-inl.h" #include "env-inl.h" #include "handle_wrap.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "v8.h" diff --git a/src/uv.cc b/src/uv.cc index ba40e705c98266..dbec7e505e2d71 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -22,7 +22,7 @@ #include "uv.h" #include "env-inl.h" #include "node.h" -#include "node_process.h" +#include "node_process-inl.h" namespace node {