Skip to content

Commit

Permalink
src: change env.h includes for forward declarations
Browse files Browse the repository at this point in the history
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: #27531

PR-URL: #30133
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
  • Loading branch information
alferpal authored and targos committed Nov 11, 2019
1 parent a71f210 commit c52b292
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/connection_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename WrapType, typename UVType>
class ConnectionWrap : public LibuvStreamWrap {
public:
Expand Down
4 changes: 2 additions & 2 deletions src/diagnosticfilename-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/inspector/main_thread_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/inspector_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/js_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object> target,
Expand Down
4 changes: 3 additions & 1 deletion src/node_crypto_bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/node_dtrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "env.h"
#include "v8.h"

extern "C" {
Expand Down Expand Up @@ -76,6 +75,8 @@ typedef struct {

namespace node {

class Environment;

void InitDTrace(Environment* env);

} // namespace node
Expand Down
4 changes: 3 additions & 1 deletion src/node_perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "node.h"
#include "node_perf_common.h"
#include "env.h"
#include "base_object-inl.h"
#include "histogram-inl.h"

Expand All @@ -15,6 +14,9 @@
#include <string>

namespace node {

class Environment;

namespace performance {

using v8::FunctionCallbackInfo;
Expand Down
3 changes: 2 additions & 1 deletion src/node_stat_watcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object> target);
Expand Down
1 change: 0 additions & 1 deletion src/node_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

#include "node.h"
#include "env.h"

#include <string>

Expand Down
3 changes: 2 additions & 1 deletion src/pipe_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@

#include "async_wrap.h"
#include "connection_wrap.h"
#include "env.h"

namespace node {

class Environment;

class PipeWrap : public ConnectionWrap<PipeWrap, uv_pipe_t> {
public:
enum SocketType {
Expand Down
3 changes: 2 additions & 1 deletion src/req_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -13,6 +12,7 @@
namespace node {

// Forward declarations
class Environment;
class ShutdownWrap;
class WriteWrap;
class StreamBase;
Expand Down
4 changes: 2 additions & 2 deletions src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object> target,
Expand Down
3 changes: 2 additions & 1 deletion src/tcp_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TCPWrap, uv_tcp_t> {
public:
enum SocketType {
Expand Down
2 changes: 1 addition & 1 deletion src/tls_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "node_crypto.h" // SSLWrap

#include "async_wrap.h"
#include "env.h"
#include "stream_wrap.h"
#include "v8.h"

Expand All @@ -38,6 +37,7 @@
namespace node {

// Forward-declarations
class Environment;
class WriteWrap;
namespace crypto {
class SecureContext;
Expand Down
3 changes: 2 additions & 1 deletion src/tty_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object> target,
Expand Down
3 changes: 2 additions & 1 deletion src/udp_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c52b292

Please sign in to comment.