From 636add246ca78be5c374cfd951c76de7f1010fb9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 27 Apr 2012 18:58:30 +0200 Subject: [PATCH] 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. --- src/node.cc | 11 ++++++++--- src/req_wrap.h | 11 +++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/node.cc b/src/node.cc index 5afeb55faf..bca0ea28eb 100644 --- a/src/node.cc +++ b/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 process_symbol; +Persistent domain_symbol; static Persistent process; @@ -106,7 +110,6 @@ static Persistent listeners_symbol; static Persistent uncaught_exception_symbol; static Persistent emit_symbol; -static Persistent domain_symbol; static Persistent enter_symbol; static Persistent exit_symbol; static Persistent disposed_symbol; @@ -1019,8 +1022,7 @@ MakeCallback(const Handle 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::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 process_l = SetupProcessObject(argc, argv); v8_typed_array::AttachBindings(context->Global()); diff --git a/src/req_wrap.h b/src/req_wrap.h index c478ce0cdb..11c7d12044 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -24,8 +24,9 @@ namespace node { -static v8::Persistent process_symbol; -static v8::Persistent domain_symbol; +// defined in node.cc +extern v8::Persistent process_symbol; +extern v8::Persistent domain_symbol; template class ReqWrap { @@ -34,12 +35,6 @@ class ReqWrap { v8::HandleScope scope; object_ = v8::Persistent::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 domain = v8::Context::GetCurrent() ->Global() ->Get(process_symbol)