src: reduce number of exported symbols

Use `static` definitions and anonymous namespaces to reduce the
number of symbols that are exported from the `node` binary.

PR-URL: https://github.com/nodejs/node/pull/12366
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen committed 2017-04-14 22:47:29 +02:00
1 parent f98db78f77
commit 9d522225e7
22 files changed
+118 -154

No files matched your search

-2
View File
@@ -222,8 +222,6 @@
'src/node_buffer.h',
'src/node_constants.h',
'src/node_debug_options.h',
'src/node_file.h',
'src/node_http_parser.h',
'src/node_internals.h',
'src/node_javascript.h',
'src/node_mutex.h',
+29 -27
View File
@@ -67,6 +67,7 @@ using v8::Object;
using v8::String;
using v8::Value;
namespace {
inline const char* ToErrorCodeString(int status) {
switch (status) {
@@ -114,7 +115,7 @@ GetAddrInfoReqWrap::GetAddrInfoReqWrap(Environment* env,
}
static void NewGetAddrInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
void NewGetAddrInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}
@@ -133,17 +134,17 @@ GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env,
}
static void NewGetNameInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
void NewGetNameInfoReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}
static void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}
static int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
if (a->sock < b->sock)
return -1;
if (a->sock > b->sock)
@@ -158,14 +159,14 @@ RB_GENERATE_STATIC(node_ares_task_list, node_ares_task, node, cmp_ares_tasks)
/* This is called once per second by loop->timer. It is used to constantly */
/* call back into c-ares for possibly processing timeouts. */
static void ares_timeout(uv_timer_t* handle) {
void ares_timeout(uv_timer_t* handle) {
Environment* env = Environment::from_cares_timer_handle(handle);
CHECK_EQ(false, RB_EMPTY(env->cares_task_list()));
ares_process_fd(env->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD);
}
static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher, watcher);
Environment* env = task->env;
@@ -186,7 +187,7 @@ static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
}
static void ares_poll_close_cb(uv_handle_t* watcher) {
void ares_poll_close_cb(uv_handle_t* watcher) {
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher,
reinterpret_cast<uv_poll_t*>(watcher));
free(task);
@@ -194,7 +195,7 @@ static void ares_poll_close_cb(uv_handle_t* watcher) {
/* Allocates and returns a new node_ares_task */
static node_ares_task* ares_task_create(Environment* env, ares_socket_t sock) {
node_ares_task* ares_task_create(Environment* env, ares_socket_t sock) {
auto task = node::UncheckedMalloc<node_ares_task>(1);
if (task == nullptr) {
@@ -216,10 +217,10 @@ static node_ares_task* ares_task_create(Environment* env, ares_socket_t sock) {
/* Callback from ares when socket operation is started */
static void ares_sockstate_cb(void* data,
ares_socket_t sock,
int read,
int write) {
void ares_sockstate_cb(void* data,
ares_socket_t sock,
int read,
int write) {
Environment* env = static_cast<Environment*>(data);
node_ares_task* task;
@@ -273,7 +274,7 @@ static void ares_sockstate_cb(void* data,
}
static Local<Array> HostentToAddresses(Environment* env, struct hostent* host) {
Local<Array> HostentToAddresses(Environment* env, struct hostent* host) {
EscapableHandleScope scope(env->isolate());
Local<Array> addresses = Array::New(env->isolate());
@@ -288,7 +289,7 @@ static Local<Array> HostentToAddresses(Environment* env, struct hostent* host) {
}
static Local<Array> HostentToNames(Environment* env, struct hostent* host) {
Local<Array> HostentToNames(Environment* env, struct hostent* host) {
EscapableHandleScope scope(env->isolate());
Local<Array> names = Array::New(env->isolate());
@@ -1105,7 +1106,7 @@ void AfterGetNameInfo(uv_getnameinfo_t* req,
}
static void IsIP(const FunctionCallbackInfo<Value>& args) {
void IsIP(const FunctionCallbackInfo<Value>& args) {
node::Utf8Value ip(args.GetIsolate(), args[0]);
char address_buffer[sizeof(struct in6_addr)];
@@ -1118,7 +1119,7 @@ static void IsIP(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(rc);
}
static void IsIPv4(const FunctionCallbackInfo<Value>& args) {
void IsIPv4(const FunctionCallbackInfo<Value>& args) {
node::Utf8Value ip(args.GetIsolate(), args[0]);
char address_buffer[sizeof(struct in_addr)];
@@ -1129,7 +1130,7 @@ static void IsIPv4(const FunctionCallbackInfo<Value>& args) {
}
}
static void IsIPv6(const FunctionCallbackInfo<Value>& args) {
void IsIPv6(const FunctionCallbackInfo<Value>& args) {
node::Utf8Value ip(args.GetIsolate(), args[0]);
char address_buffer[sizeof(struct in6_addr)];
@@ -1140,7 +1141,7 @@ static void IsIPv6(const FunctionCallbackInfo<Value>& args) {
}
}
static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsObject());
@@ -1188,7 +1189,7 @@ static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
}
static void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsObject());
@@ -1217,7 +1218,7 @@ static void GetNameInfo(const FunctionCallbackInfo<Value>& args) {
}
static void GetServers(const FunctionCallbackInfo<Value>& args) {
void GetServers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Local<Array> server_array = Array::New(env->isolate());
@@ -1246,7 +1247,7 @@ static void GetServers(const FunctionCallbackInfo<Value>& args) {
}
static void SetServers(const FunctionCallbackInfo<Value>& args) {
void SetServers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args[0]->IsArray());
@@ -1313,30 +1314,30 @@ static void SetServers(const FunctionCallbackInfo<Value>& args) {
}
static void StrError(const FunctionCallbackInfo<Value>& args) {
void StrError(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
const char* errmsg = ares_strerror(args[0]->Int32Value());
args.GetReturnValue().Set(OneByteString(env->isolate(), errmsg));
}
static void CaresTimerCloseCb(uv_handle_t* handle) {
void CaresTimerCloseCb(uv_handle_t* handle) {
Environment* env = Environment::from_cares_timer_handle(
reinterpret_cast<uv_timer_t*>(handle));
env->FinishHandleCleanup(handle);
}
static void CaresTimerClose(Environment* env,
void CaresTimerClose(Environment* env,
uv_handle_t* handle,
void* arg) {
uv_close(handle, CaresTimerCloseCb);
}
static void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
Environment* env = Environment::GetCurrent(context);
int r = ares_library_init(ARES_LIB_INIT_ALL);
@@ -1424,6 +1425,7 @@ static void Initialize(Local<Object> target,
qrw->GetFunction());
}
} // anonymous namespace
} // namespace cares_wrap
} // namespace node
+3
View File
@@ -43,6 +43,8 @@ using v8::Object;
using v8::String;
using v8::Value;
namespace {
class FSEventWrap: public HandleWrap {
public:
static void Initialize(Local<Object> target,
@@ -214,6 +216,7 @@ void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
HandleWrap::Close(args);
}
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(fs_event_wrap, node::FSEventWrap::Initialize)
+18 -14
View File
@@ -22,8 +22,6 @@
#include "node.h"
#include "node_buffer.h"
#include "node_constants.h"
#include "node_file.h"
#include "node_http_parser.h"
#include "node_javascript.h"
#include "node_version.h"
#include "node_internals.h"
@@ -1049,8 +1047,10 @@ void* ArrayBufferAllocator::Allocate(size_t size) {
return node::UncheckedMalloc(size);
}
static bool DomainHasErrorHandler(const Environment* env,
const Local<Object>& domain) {
namespace {
bool DomainHasErrorHandler(const Environment* env,
const Local<Object>& domain) {
HandleScope scope(env->isolate());
Local<Value> domain_event_listeners_v = domain->Get(env->events_string());
@@ -1071,7 +1071,7 @@ static bool DomainHasErrorHandler(const Environment* env,
return false;
}
static bool DomainsStackHasErrorHandler(const Environment* env) {
bool DomainsStackHasErrorHandler(const Environment* env) {
HandleScope scope(env->isolate());
if (!env->using_domains())
@@ -1096,7 +1096,7 @@ static bool DomainsStackHasErrorHandler(const Environment* env) {
}
static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
bool ShouldAbortOnUncaughtException(Isolate* isolate) {
HandleScope scope(isolate);
Environment* env = Environment::GetCurrent(isolate);
@@ -1226,6 +1226,8 @@ void SetupPromises(const FunctionCallbackInfo<Value>& args) {
FIXED_ONE_BYTE_STRING(args.GetIsolate(), "_setupPromises")).FromJust();
}
} // anonymous namespace
Local<Value> MakeCallback(Environment* env,
Local<Value> recv,
@@ -2274,7 +2276,7 @@ static void WaitForInspectorDisconnect(Environment* env) {
}
void Exit(const FunctionCallbackInfo<Value>& args) {
static void Exit(const FunctionCallbackInfo<Value>& args) {
WaitForInspectorDisconnect(Environment::GetCurrent(args));
exit(args[0]->Int32Value());
}
@@ -2291,7 +2293,7 @@ static void Uptime(const FunctionCallbackInfo<Value>& args) {
}
void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
size_t rss;
@@ -2319,7 +2321,7 @@ void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
}
void Kill(const FunctionCallbackInfo<Value>& args) {
static void Kill(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if (args.Length() != 2) {
@@ -2343,7 +2345,7 @@ void Kill(const FunctionCallbackInfo<Value>& args) {
// broken into the upper/lower 32 bits to be converted back in JS,
// because there is no Uint64Array in JS.
// The third entry contains the remaining nanosecond part of the value.
void Hrtime(const FunctionCallbackInfo<Value>& args) {
static void Hrtime(const FunctionCallbackInfo<Value>& args) {
uint64_t t = uv_hrtime();
Local<ArrayBuffer> ab = args[0].As<Uint32Array>()->Buffer();
@@ -2362,7 +2364,7 @@ void Hrtime(const FunctionCallbackInfo<Value>& args) {
// which are uv_timeval_t structs (long tv_sec, long tv_usec).
// Returns those values as Float64 microseconds in the elements of the array
// passed to the function.
void CPUUsage(const FunctionCallbackInfo<Value>& args) {
static void CPUUsage(const FunctionCallbackInfo<Value>& args) {
uv_rusage_t rusage;
// Call libuv to get the values we'll return.
@@ -2433,7 +2435,7 @@ struct node_module* get_linked_module(const char* name) {
// FIXME(bnoordhuis) Not multi-context ready. TBD how to resolve the conflict
// when two contexts try to load the same shared object. Maybe have a shadow
// cache that's a plain C list or hash table that's shared across contexts?
void DLOpen(const FunctionCallbackInfo<Value>& args) {
static void DLOpen(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
uv_lib_t lib;
@@ -2602,7 +2604,7 @@ void FatalException(Isolate* isolate, const TryCatch& try_catch) {
}
void OnMessage(Local<Message> message, Local<Value> error) {
static void OnMessage(Local<Message> message, Local<Value> error) {
// The current version of V8 sends messages for errors only
// (thus `error` is always set).
FatalException(Isolate::GetCurrent(), error, message);
@@ -3010,6 +3012,7 @@ static void DebugProcess(const FunctionCallbackInfo<Value>& args);
static void DebugPause(const FunctionCallbackInfo<Value>& args);
static void DebugEnd(const FunctionCallbackInfo<Value>& args);
namespace {
void NeedImmediateCallbackGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
@@ -3021,7 +3024,7 @@ void NeedImmediateCallbackGetter(Local<Name> property,
}
static void NeedImmediateCallbackSetter(
void NeedImmediateCallbackSetter(
Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info) {
@@ -3077,6 +3080,7 @@ void StopProfilerIdleNotifier(const FunctionCallbackInfo<Value>& args) {
.FromJust(); \
} while (0)
} // anonymous namespace
void SetupProcessObject(Environment* env,
int argc,
+5 -4
View File
@@ -17,9 +17,11 @@
#include "node_api.h"
#include "env-inl.h"
static
napi_status napi_set_last_error(napi_env env, napi_status error_code,
uint32_t engine_error_code = 0,
void* engine_reserved = nullptr);
static
void napi_clear_last_error(napi_env env);
struct napi_env__ {
@@ -100,6 +102,7 @@ struct napi_env__ {
(!try_catch.HasCaught() ? napi_ok \
: napi_set_last_error((env), napi_pending_exception))
namespace {
namespace v8impl {
// convert from n-api property attributes to v8::PropertyAttribute
@@ -126,10 +129,6 @@ static inline v8::PropertyAttribute V8PropertyAttributesFromDescriptor(
return static_cast<v8::PropertyAttribute>(attribute_flags);
}
v8::Isolate* V8IsolateFromJsEnv(napi_env e) {
return reinterpret_cast<v8::Isolate*>(e);
}
class HandleScopeWrapper {
public:
explicit HandleScopeWrapper(v8::Isolate* isolate) : scope(isolate) {}
@@ -660,6 +659,8 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,
mod->nm_priv);
}
} // end of anonymous namespace
#ifndef EXTERNAL_NAPI
namespace node {
// Indicates whether NAPI was enabled/disabled via the node command-line.
+5 -1
View File
@@ -87,6 +87,8 @@ using v8::Uint8Array;
using v8::Value;
using v8::WeakCallbackInfo;
namespace {
class CallbackInfo {
public:
static inline void Free(char* data, void* hint);
@@ -192,6 +194,7 @@ inline MUST_USE_RESULT bool ParseArrayIndex(Local<Value> arg,
return true;
}
} // anonymous namespace
// Buffer methods
@@ -434,6 +437,7 @@ MaybeLocal<Object> New(Environment* env, char* data, size_t length) {
return Local<Object>();
}
namespace {
void CreateFromString(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsString());
@@ -1285,7 +1289,7 @@ void Initialize(Local<Object> target,
Integer::New(env->isolate(), String::kMaxLength)).FromJust();
}
} // anonymous namespace
} // namespace Buffer
} // namespace node
+3 -3
View File
@@ -27,9 +27,9 @@ using v8::Value;
True(env->isolate()), ReadOnly).FromJust(); \
} while (0)
void InitConfig(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
static void InitConfig(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
Environment* env = Environment::GetCurrent(context);
#ifdef NODE_HAVE_I18N_SUPPORT
+4
View File
@@ -53,6 +53,8 @@ using v8::Object;
const char* default_cipher_list = DEFAULT_CIPHER_LIST_CORE;
#endif
namespace {
void DefineErrnoConstants(Local<Object> target) {
#ifdef E2BIG
NODE_DEFINE_CONSTANT(target, E2BIG);
@@ -1256,6 +1258,8 @@ void DefineZlibConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, Z_DEFAULT_LEVEL);
}
} // anonymous namespace
void DefineConstants(v8::Isolate* isolate, Local<Object> target) {
Environment* env = Environment::GetCurrent(isolate);
+2
View File
@@ -65,6 +65,7 @@ using v8::UnboundScript;
using v8::Value;
using v8::WeakCallbackInfo;
namespace {
class ContextifyContext {
protected:
@@ -963,6 +964,7 @@ void InitContextify(Local<Object> target,
ContextifyScript::Init(env, target);
}
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(contextify, node::InitContextify);
+7 -6
View File
@@ -20,7 +20,6 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "node.h"
#include "node_file.h"
#include "node_buffer.h"
#include "node_internals.h"
#include "node_stat_watcher.h"
@@ -46,6 +45,7 @@
#include <vector>
namespace node {
namespace {
using v8::Array;
using v8::ArrayBuffer;
@@ -148,16 +148,16 @@ void FSReqWrap::Dispose() {
}
static void NewFSReqWrap(const FunctionCallbackInfo<Value>& args) {
void NewFSReqWrap(const FunctionCallbackInfo<Value>& args) {
CHECK(args.IsConstructCall());
}
static inline bool IsInt64(double x) {
inline bool IsInt64(double x) {
return x == static_cast<double>(static_cast<int64_t>(x));
}
static void After(uv_fs_t *req) {
void After(uv_fs_t *req) {
FSReqWrap* req_wrap = static_cast<FSReqWrap*>(req->data);
CHECK_EQ(req_wrap->req(), req);
req_wrap->ReleaseEarly(); // Free memory that's no longer used now.
@@ -401,7 +401,7 @@ class fs_req_wrap {
#define SYNC_RESULT err
static void Access(const FunctionCallbackInfo<Value>& args) {
void Access(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
HandleScope scope(env->isolate());
@@ -423,7 +423,7 @@ static void Access(const FunctionCallbackInfo<Value>& args) {
}
static void Close(const FunctionCallbackInfo<Value>& args) {
void Close(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if (args.Length() < 1)
@@ -440,6 +440,7 @@ static void Close(const FunctionCallbackInfo<Value>& args) {
}
}
} // anonymous namespace
void FillStatsArray(double* fields, const uv_stat_t* s) {
fields[0] = s->st_dev;
-38
View File
@@ -1,38 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SRC_NODE_FILE_H_
#define SRC_NODE_FILE_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "node.h"
#include "v8.h"
namespace node {
void InitFs(v8::Local<v8::Object> target);
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_NODE_FILE_H_
+3 -1
View File
@@ -21,12 +21,12 @@
#include "node.h"
#include "node_buffer.h"
#include "node_http_parser.h"
#include "async-wrap.h"
#include "async-wrap-inl.h"
#include "env.h"
#include "env-inl.h"
#include "http_parser.h"
#include "stream_base.h"
#include "stream_base-inl.h"
#include "util.h"
@@ -49,6 +49,7 @@
namespace node {
namespace {
using v8::Array;
using v8::Boolean;
@@ -798,6 +799,7 @@ void InitHttpParser(Local<Object> target,
t->GetFunction());
}
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(http_parser, node::InitHttpParser)
-39
View File
@@ -1,39 +0,0 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SRC_NODE_HTTP_PARSER_H_
#define SRC_NODE_HTTP_PARSER_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "v8.h"
#include "http_parser.h"
namespace node {
void InitHttpParser(v8::Local<v8::Object> target);
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_NODE_HTTP_PARSER_H_
+8 -5
View File
@@ -93,6 +93,7 @@ using v8::String;
using v8::Value;
namespace i18n {
namespace {
template <typename T>
MaybeLocal<Object> ToBufferEndian(Environment* env, MaybeStackBuffer<T>* buf) {
@@ -344,7 +345,7 @@ void Transcode(const FunctionCallbackInfo<Value>&args) {
return args.GetReturnValue().Set(result.ToLocalChecked());
}
static void ICUErrorName(const FunctionCallbackInfo<Value>& args) {
void ICUErrorName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
UErrorCode status = static_cast<UErrorCode>(args[0]->Int32Value());
args.GetReturnValue().Set(
@@ -366,9 +367,9 @@ static void ICUErrorName(const FunctionCallbackInfo<Value>& args) {
* @param status ICU error status. If failure, assume result is undefined.
* @return version number, or NULL. May or may not be buf.
*/
static const char* GetVersion(const char* type,
char buf[U_MAX_VERSION_STRING_LENGTH],
UErrorCode* status) {
const char* GetVersion(const char* type,
char buf[U_MAX_VERSION_STRING_LENGTH],
UErrorCode* status) {
if (!strcmp(type, TYPE_ICU)) {
return U_ICU_VERSION;
} else if (!strcmp(type, TYPE_UNICODE)) {
@@ -387,7 +388,7 @@ static const char* GetVersion(const char* type,
return nullptr;
}
static void GetVersion(const FunctionCallbackInfo<Value>& args) {
void GetVersion(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
if ( args.Length() == 0 ) {
// With no args - return a comma-separated list of allowed values
@@ -414,6 +415,8 @@ static void GetVersion(const FunctionCallbackInfo<Value>& args) {
}
}
} // anonymous namespace
bool InitializeICUDirectory(const std::string& path) {
if (path.empty()) {
UErrorCode status = U_ZERO_ERROR;
+1 -1
View File
@@ -6,7 +6,7 @@ namespace node {
unsigned int reverted = 0;
const char* RevertMessage(const unsigned int cve) {
static const char* RevertMessage(const unsigned int cve) {
#define V(code, label, msg) case REVERT_ ## code: return label ": " msg;
switch (cve) {
REVERSIONS(V)
+3
View File
@@ -28,6 +28,8 @@ using v8::Value;
using v8::ValueDeserializer;
using v8::ValueSerializer;
namespace {
class SerializerContext : public BaseObject,
public ValueSerializer::Delegate {
public:
@@ -478,6 +480,7 @@ void InitializeSerdesBindings(Local<Object> target,
des->GetFunction(env->context()).ToLocalChecked()).FromJust();
}
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(serdes, node::InitializeSerdesBindings)
+3
View File
@@ -50,6 +50,8 @@ using v8::Number;
using v8::Object;
using v8::Value;
namespace {
enum node_zlib_mode {
NONE,
DEFLATE,
@@ -693,6 +695,7 @@ void InitZlib(Local<Object> target,
FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION));
}
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(zlib, node::InitZlib)
+3
View File
@@ -43,6 +43,8 @@ using v8::Object;
using v8::String;
using v8::Value;
namespace {
class ProcessWrap : public HandleWrap {
public:
static void Initialize(Local<Object> target,
@@ -273,6 +275,7 @@ class ProcessWrap : public HandleWrap {
};
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(process_wrap, node::ProcessWrap::Initialize)
+3
View File
@@ -39,6 +39,8 @@ using v8::Local;
using v8::Object;
using v8::Value;
namespace {
class SignalWrap : public HandleWrap {
public:
static void Initialize(Local<Object> target,
@@ -119,6 +121,7 @@ class SignalWrap : public HandleWrap {
};
} // anonymous namespace
} // namespace node
+10 -7
View File
@@ -46,6 +46,8 @@ using v8::Object;
using v8::String;
using v8::Value;
namespace {
template <typename ResourceType, typename TypeName>
class ExternString: public ResourceType {
public:
@@ -141,6 +143,7 @@ MaybeLocal<String> ExternTwoByteString::NewExternal(
return String::NewExternalTwoByte(isolate, h_str);
}
} // anonymous namespace
// supports regular and URL-safe base64
const int8_t unbase64_table[256] =
@@ -182,15 +185,15 @@ static const int8_t unhex_table[256] =
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
#define unhex(x) \
static_cast<unsigned>(unhex_table[static_cast<uint8_t>(x)])
static inline unsigned unhex(uint8_t x) {
return unhex_table[x];
}
template <typename TypeName>
size_t hex_decode(char* buf,
size_t len,
const TypeName* src,
const size_t srcLen) {
static size_t hex_decode(char* buf,
size_t len,
const TypeName* src,
const size_t srcLen) {
size_t i;
for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) {
unsigned a = unhex(src[i * 2 + 0]);
+2
View File
@@ -30,6 +30,7 @@
#include <stdint.h>
namespace node {
namespace {
using v8::Context;
using v8::FunctionCallbackInfo;
@@ -132,6 +133,7 @@ class TimerWrap : public HandleWrap {
};
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(timer_wrap, node::TimerWrap::Initialize)
+6 -6
View File
@@ -25,7 +25,7 @@
#include "env-inl.h"
namespace node {
namespace uv {
namespace {
using v8::Context;
using v8::FunctionCallbackInfo;
@@ -45,9 +45,9 @@ void ErrName(const FunctionCallbackInfo<Value>& args) {
}
void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
void InitializeUV(Local<Object> target,
Local<Value> unused,
Local<Context> context) {
Environment* env = Environment::GetCurrent(context);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"),
env->NewFunctionTemplate(ErrName)->GetFunction());
@@ -59,7 +59,7 @@ void Initialize(Local<Object> target,
}
} // namespace uv
} // anonymous namespace
} // namespace node
NODE_MODULE_CONTEXT_AWARE_BUILTIN(uv, node::uv::Initialize)
NODE_MODULE_CONTEXT_AWARE_BUILTIN(uv, node::InitializeUV)