Skip to content

Commit b9136c0

Browse files
jasnellMyles Borins
authored and
Myles Borins
committed
src: add process.binding('config')
It turns out that userland likes to override process.config with their own stuff. If we want to be able to depend on it in any way, we need our own internal mechanism. This adds a new private process.binding('config') that is intended to serve as a container for internal flags and compile time configs that need to be passed on to the JS layer. PR-URL: #6266 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 9121e94 commit b9136c0

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

node.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
'src/js_stream.cc',
125125
'src/node.cc',
126126
'src/node_buffer.cc',
127+
'src/node_config.cc',
127128
'src/node_constants.cc',
128129
'src/node_contextify.cc',
129130
'src/node_file.cc',

src/node_config.cc

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "node.h"
2+
#include "env.h"
3+
#include "env-inl.h"
4+
#include "util.h"
5+
#include "util-inl.h"
6+
7+
8+
namespace node {
9+
10+
using v8::Context;
11+
using v8::Local;
12+
using v8::Object;
13+
using v8::Value;
14+
using v8::ReadOnly;
15+
16+
// The config binding is used to provide an internal view of compile or runtime
17+
// config options that are required internally by lib/*.js code. This is an
18+
// alternative to dropping additional properties onto the process object as
19+
// has been the practice previously in node.cc.
20+
21+
#define READONLY_BOOLEAN_PROPERTY(str) \
22+
do { \
23+
target->DefineOwnProperty(env->context(), \
24+
OneByteString(env->isolate(), str), \
25+
True(env->isolate()), ReadOnly).FromJust(); \
26+
} while (0)
27+
28+
void InitConfig(Local<Object> target,
29+
Local<Value> unused,
30+
Local<Context> context) {
31+
// Environment* env = Environment::GetCurrent(context);
32+
}
33+
34+
} // namespace node
35+
36+
NODE_MODULE_CONTEXT_AWARE_BUILTIN(config, node::InitConfig)

0 commit comments

Comments
 (0)