Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-05-24 17:27:03 +0300
committerMyles Borins <mylesborins@google.com>2018-05-24 20:19:15 +0300
commit0b1ba20fc07158896c09a9dc219d8f933a99d98d (patch)
treeb6146892002f7e1af67d4a1e1043dd4603d948e7
parent52f21fbfbcfc61b36ad46e73c338ab002b669b50 (diff)
src: re-integrate headers into node.h
Alternative to https://github.com/nodejs/node/pull/20938 (clean revert) and https://github.com/nodejs/node/pull/20925 (adding the headers to the release tarball). The changes to `src/node.h` are a clean revert in the same ways as https://github.com/nodejs/node/pull/20938 does it, the difference being that the new `.cc` files are kept here. This has the advantage of not being another large diff that other PRs will have to rebase against, especially since the split into `callback_scope.cc` and `exceptions.cc` is something that we want to keep in the long run. This essentialy implements bnoordhuis’s suggestion from https://github.com/nodejs/node/pull/20925. PR-URL: https://github.com/nodejs/node/pull/20939 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com>
-rw-r--r--node.gyp2
-rw-r--r--src/callback_scope.cc1
-rw-r--r--src/callback_scope.h47
-rw-r--r--src/core.h44
-rw-r--r--src/exceptions.cc1
-rw-r--r--src/exceptions.h76
-rw-r--r--src/node.h140
7 files changed, 137 insertions, 174 deletions
diff --git a/node.gyp b/node.gyp
index a40206944f8..48945acaca8 100644
--- a/node.gyp
+++ b/node.gyp
@@ -365,12 +365,10 @@
'src/async_wrap-inl.h',
'src/base_object.h',
'src/base_object-inl.h',
- 'src/callback_scope.h',
'src/connection_wrap.h',
'src/connect_wrap.h',
'src/env.h',
'src/env-inl.h',
- 'src/exceptions.h',
'src/handle_wrap.h',
'src/js_stream.h',
'src/module_wrap.h',
diff --git a/src/callback_scope.cc b/src/callback_scope.cc
index 5539d77c70c..5e7a27cf01f 100644
--- a/src/callback_scope.cc
+++ b/src/callback_scope.cc
@@ -1,5 +1,4 @@
#include "node.h"
-#include "callback_scope.h"
#include "async_wrap.h"
#include "async_wrap-inl.h"
#include "env.h"
diff --git a/src/callback_scope.h b/src/callback_scope.h
deleted file mode 100644
index 7f199aaea22..00000000000
--- a/src/callback_scope.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef SRC_CALLBACK_SCOPE_H_
-#define SRC_CALLBACK_SCOPE_H_
-
-#include "core.h"
-#include "v8.h"
-
-namespace node {
-
-typedef double async_id;
-struct async_context {
- ::node::async_id async_id;
- ::node::async_id trigger_async_id;
-};
-
-class InternalCallbackScope;
-
-/* This class works like `MakeCallback()` in that it sets up a specific
- * asyncContext as the current one and informs the async_hooks and domains
- * modules that this context is currently active.
- *
- * `MakeCallback()` is a wrapper around this class as well as
- * `Function::Call()`. Either one of these mechanisms needs to be used for
- * top-level calls into JavaScript (i.e. without any existing JS stack).
- *
- * This object should be stack-allocated to ensure that it is contained in a
- * valid HandleScope.
- */
-class NODE_EXTERN CallbackScope {
- public:
- CallbackScope(v8::Isolate* isolate,
- v8::Local<v8::Object> resource,
- async_context asyncContext);
- ~CallbackScope();
-
- private:
- InternalCallbackScope* private_;
- v8::TryCatch try_catch_;
-
- void operator=(const CallbackScope&) = delete;
- void operator=(CallbackScope&&) = delete;
- CallbackScope(const CallbackScope&) = delete;
- CallbackScope(CallbackScope&&) = delete;
-};
-
-} // namespace node
-
-#endif // SRC_CALLBACK_SCOPE_H_
diff --git a/src/core.h b/src/core.h
deleted file mode 100644
index 0dbce4f3f8f..00000000000
--- a/src/core.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SRC_CORE_H_
-#define SRC_CORE_H_
-
-#ifdef _WIN32
-# ifndef BUILDING_NODE_EXTENSION
-# define NODE_EXTERN __declspec(dllexport)
-# else
-# define NODE_EXTERN __declspec(dllimport)
-# endif
-#else
-# define NODE_EXTERN /* nothing */
-#endif
-
-#define NODE_MAKE_VERSION(major, minor, patch) \
- ((major) * 0x1000 + (minor) * 0x100 + (patch))
-
-#ifdef __clang__
-# define NODE_CLANG_AT_LEAST(major, minor, patch) \
- (NODE_MAKE_VERSION(major, minor, patch) <= \
- NODE_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__))
-#else
-# define NODE_CLANG_AT_LEAST(major, minor, patch) (0)
-#endif
-
-#ifdef __GNUC__
-# define NODE_GNUC_AT_LEAST(major, minor, patch) \
- (NODE_MAKE_VERSION(major, minor, patch) <= \
- NODE_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
-#else
-# define NODE_GNUC_AT_LEAST(major, minor, patch) (0)
-#endif
-
-#if NODE_CLANG_AT_LEAST(2, 9, 0) || NODE_GNUC_AT_LEAST(4, 5, 0)
-# define NODE_DEPRECATED(message, declarator) \
- __attribute__((deprecated(message))) declarator
-#elif defined(_MSC_VER)
-# define NODE_DEPRECATED(message, declarator) \
- __declspec(deprecated) declarator
-#else
-# define NODE_DEPRECATED(message, declarator) \
- declarator
-#endif
-
-#endif // SRC_CORE_H_
diff --git a/src/exceptions.cc b/src/exceptions.cc
index 3068483bdf5..1bcc7651a28 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -2,7 +2,6 @@
#include "node_internals.h"
#include "env.h"
#include "env-inl.h"
-#include "exceptions.h"
#include "util.h"
#include "util-inl.h"
#include "v8.h"
diff --git a/src/exceptions.h b/src/exceptions.h
deleted file mode 100644
index 8a4a8ce99e8..00000000000
--- a/src/exceptions.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef SRC_EXCEPTIONS_H_
-#define SRC_EXCEPTIONS_H_
-
-#include "core.h"
-#include "v8.h"
-
-namespace node {
-
-NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
- int errorno,
- const char* syscall = nullptr,
- const char* message = nullptr,
- const char* path = nullptr);
-NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
- int errorno,
- const char* syscall = nullptr,
- const char* message = nullptr,
- const char* path = nullptr);
-NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
- int errorno,
- const char* syscall,
- const char* message,
- const char* path,
- const char* dest);
-
-NODE_DEPRECATED(
- "Use ErrnoException(isolate, ...)",
- inline v8::Local<v8::Value> ErrnoException(
- int errorno,
- const char* syscall = nullptr,
- const char* message = nullptr,
- const char* path = nullptr) {
- return ErrnoException(v8::Isolate::GetCurrent(),
- errorno,
- syscall,
- message,
- path);
-})
-
-inline v8::Local<v8::Value> UVException(int errorno,
- const char* syscall = nullptr,
- const char* message = nullptr,
- const char* path = nullptr) {
- return UVException(v8::Isolate::GetCurrent(),
- errorno,
- syscall,
- message,
- path);
-}
-
-#ifdef _WIN32
-NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
- v8::Isolate* isolate,
- int errorno,
- const char *syscall = nullptr,
- const char *msg = "",
- const char *path = nullptr);
-
-NODE_DEPRECATED(
- "Use WinapiErrnoException(isolate, ...)",
- inline v8::Local<v8::Value> WinapiErrnoException(
- int errorno,
- const char *syscall = nullptr,
- const char *msg = "",
- const char *path = nullptr) {
- return WinapiErrnoException(v8::Isolate::GetCurrent(),
- errorno,
- syscall,
- msg,
- path);
-})
-#endif
-
-} // namespace node
-
-#endif // SRC_EXCEPTIONS_H_
diff --git a/src/node.h b/src/node.h
index d4b93464516..44c89afdb71 100644
--- a/src/node.h
+++ b/src/node.h
@@ -22,6 +22,16 @@
#ifndef SRC_NODE_H_
#define SRC_NODE_H_
+#ifdef _WIN32
+# ifndef BUILDING_NODE_EXTENSION
+# define NODE_EXTERN __declspec(dllexport)
+# else
+# define NODE_EXTERN __declspec(dllimport)
+# endif
+#else
+# define NODE_EXTERN /* nothing */
+#endif
+
#ifdef BUILDING_NODE_EXTENSION
# undef BUILDING_V8_SHARED
# undef BUILDING_UV_SHARED
@@ -50,12 +60,39 @@
# define SIGKILL 9
#endif
-#include "core.h" // NOLINT(build/include_order)
#include "v8.h" // NOLINT(build/include_order)
#include "v8-platform.h" // NOLINT(build/include_order)
#include "node_version.h" // NODE_MODULE_VERSION
-#include "callback_scope.h"
-#include "exceptions.h"
+
+#define NODE_MAKE_VERSION(major, minor, patch) \
+ ((major) * 0x1000 + (minor) * 0x100 + (patch))
+
+#ifdef __clang__
+# define NODE_CLANG_AT_LEAST(major, minor, patch) \
+ (NODE_MAKE_VERSION(major, minor, patch) <= \
+ NODE_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__))
+#else
+# define NODE_CLANG_AT_LEAST(major, minor, patch) (0)
+#endif
+
+#ifdef __GNUC__
+# define NODE_GNUC_AT_LEAST(major, minor, patch) \
+ (NODE_MAKE_VERSION(major, minor, patch) <= \
+ NODE_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__))
+#else
+# define NODE_GNUC_AT_LEAST(major, minor, patch) (0)
+#endif
+
+#if NODE_CLANG_AT_LEAST(2, 9, 0) || NODE_GNUC_AT_LEAST(4, 5, 0)
+# define NODE_DEPRECATED(message, declarator) \
+ __attribute__((deprecated(message))) declarator
+#elif defined(_MSC_VER)
+# define NODE_DEPRECATED(message, declarator) \
+ __declspec(deprecated) declarator
+#else
+# define NODE_DEPRECATED(message, declarator) \
+ declarator
+#endif
// Forward-declare libuv loop
struct uv_loop_s;
@@ -69,6 +106,47 @@ class TracingController;
// terminally confused when it's done in node_internals.h
namespace node {
+NODE_EXTERN v8::Local<v8::Value> ErrnoException(v8::Isolate* isolate,
+ int errorno,
+ const char* syscall = nullptr,
+ const char* message = nullptr,
+ const char* path = nullptr);
+NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
+ int errorno,
+ const char* syscall = nullptr,
+ const char* message = nullptr,
+ const char* path = nullptr);
+NODE_EXTERN v8::Local<v8::Value> UVException(v8::Isolate* isolate,
+ int errorno,
+ const char* syscall,
+ const char* message,
+ const char* path,
+ const char* dest);
+
+NODE_DEPRECATED("Use ErrnoException(isolate, ...)",
+ inline v8::Local<v8::Value> ErrnoException(
+ int errorno,
+ const char* syscall = nullptr,
+ const char* message = nullptr,
+ const char* path = nullptr) {
+ return ErrnoException(v8::Isolate::GetCurrent(),
+ errorno,
+ syscall,
+ message,
+ path);
+})
+
+inline v8::Local<v8::Value> UVException(int errorno,
+ const char* syscall = nullptr,
+ const char* message = nullptr,
+ const char* path = nullptr) {
+ return UVException(v8::Isolate::GetCurrent(),
+ errorno,
+ syscall,
+ message,
+ path);
+}
+
/*
* These methods need to be called in a HandleScope.
*
@@ -373,6 +451,26 @@ NODE_DEPRECATED("Use DecodeWrite(isolate, ...)",
return DecodeWrite(v8::Isolate::GetCurrent(), buf, buflen, val, encoding);
})
+#ifdef _WIN32
+NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
+ v8::Isolate* isolate,
+ int errorno,
+ const char *syscall = nullptr,
+ const char *msg = "",
+ const char *path = nullptr);
+
+NODE_DEPRECATED("Use WinapiErrnoException(isolate, ...)",
+ inline v8::Local<v8::Value> WinapiErrnoException(int errorno,
+ const char *syscall = nullptr, const char *msg = "",
+ const char *path = nullptr) {
+ return WinapiErrnoException(v8::Isolate::GetCurrent(),
+ errorno,
+ syscall,
+ msg,
+ path);
+})
+#endif
+
const char *signo_string(int errorno);
@@ -495,6 +593,12 @@ typedef void (*promise_hook_func) (v8::PromiseHookType type,
v8::Local<v8::Value> parent,
void* arg);
+typedef double async_id;
+struct async_context {
+ ::node::async_id async_id;
+ ::node::async_id trigger_async_id;
+};
+
/* Registers an additional v8::PromiseHook wrapper. This API exists because V8
* itself supports only a single PromiseHook. */
NODE_EXTERN void AddPromiseHook(v8::Isolate* isolate,
@@ -543,6 +647,36 @@ NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
async_context asyncContext);
+class InternalCallbackScope;
+
+/* This class works like `MakeCallback()` in that it sets up a specific
+ * asyncContext as the current one and informs the async_hooks and domains
+ * modules that this context is currently active.
+ *
+ * `MakeCallback()` is a wrapper around this class as well as
+ * `Function::Call()`. Either one of these mechanisms needs to be used for
+ * top-level calls into JavaScript (i.e. without any existing JS stack).
+ *
+ * This object should be stack-allocated to ensure that it is contained in a
+ * valid HandleScope.
+ */
+class NODE_EXTERN CallbackScope {
+ public:
+ CallbackScope(v8::Isolate* isolate,
+ v8::Local<v8::Object> resource,
+ async_context asyncContext);
+ ~CallbackScope();
+
+ private:
+ InternalCallbackScope* private_;
+ v8::TryCatch try_catch_;
+
+ void operator=(const CallbackScope&) = delete;
+ void operator=(CallbackScope&&) = delete;
+ CallbackScope(const CallbackScope&) = delete;
+ CallbackScope(CallbackScope&&) = delete;
+};
+
/* An API specific to emit before/after callbacks is unnecessary because
* MakeCallback will automatically call them for you.
*