diff --git a/node.gyp b/node.gyp index 642a9767fb64d8..30327b38a59df5 100644 --- a/node.gyp +++ b/node.gyp @@ -749,6 +749,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 cb46c5c1b87643..c19d8c5b9106f4 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/crypto/crypto_cipher.cc b/src/crypto/crypto_cipher.cc index 5ce466582823ae..4629143d47e492 100644 --- a/src/crypto/crypto_cipher.cc +++ b/src/crypto/crypto_cipher.cc @@ -6,7 +6,7 @@ #include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "v8.h" namespace node { diff --git a/src/env.cc b/src/env.cc index 28a1c2fd3c3676..4ee4b675d87953 100644 --- a/src/env.cc +++ b/src/env.cc @@ -10,7 +10,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 4b30c177bea55c..a3c901dca2eafc 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 ed48c0bc5f45a9..f45ee7627b0a9b 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 b7dd3e10cdb1c9..466787750fced0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -35,7 +35,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_dir.cc b/src/node_dir.cc index b103c08262a5e8..c530da0cc3be4b 100644 --- a/src/node_dir.cc +++ b/src/node_dir.cc @@ -1,7 +1,7 @@ #include "node_dir.h" #include "node_external_reference.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 b13f7fcd16fd50..27c833d498ec77 100644 --- a/src/node_env_var.cc +++ b/src/node_env_var.cc @@ -3,7 +3,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_i18n.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 47b13f6149545b..3aee2533a8c078 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -5,7 +5,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "node_report.h" #include "node_v8_platform-inl.h" #include "util-inl.h" diff --git a/src/node_file.cc b/src/node_file.cc index 228e2260661391..7eb0de310f7e1d 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -24,7 +24,7 @@ #include "memory_tracker-inl.h" #include "node_buffer.h" #include "node_external_reference.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 ac4abc3af01568..7dd18979530b44 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -7,7 +7,7 @@ #include "node_contextify.h" #include "node_errors.h" #include "node_external_reference.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 c1a0b2cf3a14d7..8c5778ecb10bb0 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -5,7 +5,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 5030ab872f4f16..3bb56458d0eb33 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -6,7 +6,7 @@ #include "node_errors.h" #include "node_external_reference.h" #include "node_internals.h" -#include "node_process.h" +#include "node_process-inl.h" #include "util-inl.h" #include "uv.h" #include "v8-fast-api-calls.h" diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 3d573d534601e0..587b4ecb936835 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -4,7 +4,7 @@ #include "node_internals.h" #include "node_metadata.h" #include "node_options-inl.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 004eb6a6529f79..9bbdb3180217b3 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -4,7 +4,7 @@ #include "node_errors.h" #include "node_external_reference.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 cdf063c035a5d3..e8a1500d2e9961 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 0e6672c47269b3..2b0c424587e420 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -23,7 +23,7 @@ #include "env-inl.h" #include "node.h" #include "node_external_reference.h" -#include "node_process.h" +#include "node_process-inl.h" namespace node {