From 7c38760f3c6cd83fe67663697f5f12d418add21d Mon Sep 17 00:00:00 2001 From: Alexandre Ferrando Date: Sat, 26 Oct 2019 16:59:34 +0200 Subject: [PATCH] src: change env.h includes for forward declarations Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: https://github.com/nodejs/node/issues/27531 --- src/connection_wrap.h | 3 ++- src/diagnosticfilename-inl.h | 4 ++-- src/inspector/main_thread_interface.h | 1 - src/inspector_profiler.h | 1 - src/js_stream.h | 3 ++- src/node_crypto_bio.h | 4 +++- src/node_dtrace.h | 3 ++- src/node_perf.h | 4 +++- src/node_stat_watcher.h | 3 ++- src/node_url.h | 1 - src/pipe_wrap.h | 3 ++- src/req_wrap.h | 3 ++- src/stream_base.h | 2 +- src/stream_wrap.h | 4 ++-- src/tcp_wrap.h | 3 ++- src/tls_wrap.h | 2 +- src/tty_wrap.h | 3 ++- src/udp_wrap.h | 3 ++- 18 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/connection_wrap.h b/src/connection_wrap.h index 5b114088760dad..db74dc5df4aa5b 100644 --- a/src/connection_wrap.h +++ b/src/connection_wrap.h @@ -3,12 +3,13 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "env.h" #include "stream_wrap.h" #include "v8.h" namespace node { +class Environment; + template class ConnectionWrap : public LibuvStreamWrap { public: diff --git a/src/diagnosticfilename-inl.h b/src/diagnosticfilename-inl.h index 58a3a933acc605..a0d44fd56bcd60 100644 --- a/src/diagnosticfilename-inl.h +++ b/src/diagnosticfilename-inl.h @@ -4,10 +4,10 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "node_internals.h" -#include "env-inl.h" - namespace node { +class Environment; + inline DiagnosticFilename::DiagnosticFilename( Environment* env, const char* prefix, diff --git a/src/inspector/main_thread_interface.h b/src/inspector/main_thread_interface.h index bcea19f3f3937e..78337a25e43808 100644 --- a/src/inspector/main_thread_interface.h +++ b/src/inspector/main_thread_interface.h @@ -5,7 +5,6 @@ #error("This header can only be used when inspector is enabled") #endif -#include "env.h" #include "inspector_agent.h" #include "node_mutex.h" diff --git a/src/inspector_profiler.h b/src/inspector_profiler.h index 4a21eb3a2d3383..187bc0d1c49a16 100644 --- a/src/inspector_profiler.h +++ b/src/inspector_profiler.h @@ -7,7 +7,6 @@ #error("This header can only be used when inspector is enabled") #endif -#include "env.h" #include "inspector_agent.h" namespace node { diff --git a/src/js_stream.h b/src/js_stream.h index 8198a6bb36a4e1..460ac23bc98b21 100644 --- a/src/js_stream.h +++ b/src/js_stream.h @@ -4,12 +4,13 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap.h" -#include "env.h" #include "stream_base.h" #include "v8.h" namespace node { +class Environment; + class JSStream : public AsyncWrap, public StreamBase { public: static void Initialize(v8::Local target, diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h index fef91750d541e1..5de943806a9642 100644 --- a/src/node_crypto_bio.h +++ b/src/node_crypto_bio.h @@ -26,11 +26,13 @@ #include "node_crypto.h" #include "openssl/bio.h" -#include "env.h" #include "util.h" #include "v8.h" namespace node { + +class Environment; + namespace crypto { // This class represents buffers for OpenSSL I/O, implemented as a singly-linked diff --git a/src/node_dtrace.h b/src/node_dtrace.h index cbabe905597cb0..b887542abfc9cf 100644 --- a/src/node_dtrace.h +++ b/src/node_dtrace.h @@ -24,7 +24,6 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "env.h" #include "v8.h" extern "C" { @@ -76,6 +75,8 @@ typedef struct { namespace node { +class Environment; + void InitDTrace(Environment* env); } // namespace node diff --git a/src/node_perf.h b/src/node_perf.h index e8441e3bb72444..c5e45261c2c6fd 100644 --- a/src/node_perf.h +++ b/src/node_perf.h @@ -5,7 +5,6 @@ #include "node.h" #include "node_perf_common.h" -#include "env.h" #include "base_object-inl.h" #include "histogram-inl.h" @@ -15,6 +14,9 @@ #include namespace node { + +class Environment; + namespace performance { using v8::FunctionCallbackInfo; diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index 3d819b45787e98..9669806ce796c9 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -26,12 +26,13 @@ #include "node.h" #include "handle_wrap.h" -#include "env.h" #include "uv.h" #include "v8.h" namespace node { +class Environment; + class StatWatcher : public HandleWrap { public: static void Initialize(Environment* env, v8::Local target); diff --git a/src/node_url.h b/src/node_url.h index e85ca6e7129f6a..963273f988c983 100644 --- a/src/node_url.h +++ b/src/node_url.h @@ -4,7 +4,6 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "node.h" -#include "env.h" #include diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 473179a4f6fba0..53008b0d165044 100644 --- a/src/pipe_wrap.h +++ b/src/pipe_wrap.h @@ -26,10 +26,11 @@ #include "async_wrap.h" #include "connection_wrap.h" -#include "env.h" namespace node { +class Environment; + class PipeWrap : public ConnectionWrap { public: enum SocketType { diff --git a/src/req_wrap.h b/src/req_wrap.h index c20912cc95e22f..36eeb1cbc24005 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -4,12 +4,13 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap.h" -#include "env.h" #include "util.h" #include "v8.h" namespace node { +class Environment; + class ReqWrapBase { public: explicit inline ReqWrapBase(Environment* env); diff --git a/src/stream_base.h b/src/stream_base.h index 3bfdaedb791ca9..3df9e99f6e438e 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -3,7 +3,6 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "env.h" #include "async_wrap-inl.h" #include "node.h" #include "util.h" @@ -13,6 +12,7 @@ namespace node { // Forward declarations +class Environment; class ShutdownWrap; class WriteWrap; class StreamBase; diff --git a/src/stream_wrap.h b/src/stream_wrap.h index 19366ff4fba2c4..37f5af46066181 100644 --- a/src/stream_wrap.h +++ b/src/stream_wrap.h @@ -25,14 +25,14 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "stream_base.h" - -#include "env.h" #include "handle_wrap.h" #include "string_bytes.h" #include "v8.h" namespace node { +class Environment; + class LibuvStreamWrap : public HandleWrap, public StreamBase { public: static void Initialize(v8::Local target, diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index 0467a1c3f3bf20..0099eedb4bc629 100644 --- a/src/tcp_wrap.h +++ b/src/tcp_wrap.h @@ -25,11 +25,12 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap.h" -#include "env.h" #include "connection_wrap.h" namespace node { +class Environment; + class TCPWrap : public ConnectionWrap { public: enum SocketType { diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 631ef8e7c3d8db..14b7327e7d8259 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -27,7 +27,6 @@ #include "node_crypto.h" // SSLWrap #include "async_wrap.h" -#include "env.h" #include "stream_wrap.h" #include "v8.h" @@ -38,6 +37,7 @@ namespace node { // Forward-declarations +class Environment; class WriteWrap; namespace crypto { class SecureContext; diff --git a/src/tty_wrap.h b/src/tty_wrap.h index df0c4b7c145612..fdf07e4242c1f8 100644 --- a/src/tty_wrap.h +++ b/src/tty_wrap.h @@ -24,12 +24,13 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "env.h" #include "uv.h" #include "stream_wrap.h" namespace node { +class Environment; + class TTYWrap : public LibuvStreamWrap { public: static void Initialize(v8::Local target, diff --git a/src/udp_wrap.h b/src/udp_wrap.h index f79fdd9109fd0d..6375ac2d1b8c80 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -25,13 +25,14 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap.h" -#include "env.h" #include "handle_wrap.h" #include "uv.h" #include "v8.h" namespace node { +class Environment; + class UDPWrap: public HandleWrap { public: enum SocketType {