mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
req_wrap: share process_symbol, domain_symbol
Share persistent strings process_symbol and domain_symbol across compilation units. Avoids redefinition errors when src/node.cc includes src/req_wrap.h.
This commit is contained in:
11
src/node.cc
11
src/node.cc
@@ -20,6 +20,7 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "node.h"
|
||||
#include "handle_wrap.h" // HandleWrap::GetActiveHandles()
|
||||
|
||||
#include "uv.h"
|
||||
|
||||
@@ -90,6 +91,9 @@ extern char **environ;
|
||||
|
||||
namespace node {
|
||||
|
||||
// declared in req_wrap.h
|
||||
Persistent<String> process_symbol;
|
||||
Persistent<String> domain_symbol;
|
||||
|
||||
static Persistent<Object> process;
|
||||
|
||||
@@ -106,7 +110,6 @@ static Persistent<String> listeners_symbol;
|
||||
static Persistent<String> uncaught_exception_symbol;
|
||||
static Persistent<String> emit_symbol;
|
||||
|
||||
static Persistent<String> domain_symbol;
|
||||
static Persistent<String> enter_symbol;
|
||||
static Persistent<String> exit_symbol;
|
||||
static Persistent<String> disposed_symbol;
|
||||
@@ -1019,8 +1022,7 @@ MakeCallback(const Handle<Object> object,
|
||||
|
||||
TryCatch try_catch;
|
||||
|
||||
if (domain_symbol.IsEmpty()) {
|
||||
domain_symbol = NODE_PSYMBOL("domain");
|
||||
if (enter_symbol.IsEmpty()) {
|
||||
enter_symbol = NODE_PSYMBOL("enter");
|
||||
exit_symbol = NODE_PSYMBOL("exit");
|
||||
disposed_symbol = NODE_PSYMBOL("_disposed");
|
||||
@@ -2866,6 +2868,9 @@ int Start(int argc, char *argv[]) {
|
||||
Persistent<Context> context = Context::New();
|
||||
Context::Scope context_scope(context);
|
||||
|
||||
process_symbol = NODE_PSYMBOL("process");
|
||||
domain_symbol = NODE_PSYMBOL("domain");
|
||||
|
||||
// Use original argv, as we're just copying values out of it.
|
||||
Handle<Object> process_l = SetupProcessObject(argc, argv);
|
||||
v8_typed_array::AttachBindings(context->Global());
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
|
||||
namespace node {
|
||||
|
||||
static v8::Persistent<v8::String> process_symbol;
|
||||
static v8::Persistent<v8::String> domain_symbol;
|
||||
// defined in node.cc
|
||||
extern v8::Persistent<v8::String> process_symbol;
|
||||
extern v8::Persistent<v8::String> domain_symbol;
|
||||
|
||||
template <typename T>
|
||||
class ReqWrap {
|
||||
@@ -34,12 +35,6 @@ class ReqWrap {
|
||||
v8::HandleScope scope;
|
||||
object_ = v8::Persistent<v8::Object>::New(v8::Object::New());
|
||||
|
||||
// TODO: grab a handle to the current process.domain
|
||||
if (process_symbol.IsEmpty()) {
|
||||
process_symbol = NODE_PSYMBOL("process");
|
||||
domain_symbol = NODE_PSYMBOL("domain");
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> domain = v8::Context::GetCurrent()
|
||||
->Global()
|
||||
->Get(process_symbol)
|
||||
|
||||
Reference in New Issue
Block a user