From 48452838b379b167a2aff5786d53c07e5f8bbcdc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 5 Dec 2009 18:25:07 +0100 Subject: [PATCH] Clean up context creation --- src/node.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/node.cc b/src/node.cc index e722fbe..cadb552 100644 --- a/src/node.cc +++ b/src/node.cc @@ -734,13 +734,17 @@ static void ExecuteNativeJS(const char *filename, const char *data) { static Local Load(int argc, char *argv[]) { HandleScope scope; + Local global = Context::GetCurrent()->Global(); + + // Assign the global object to it's place as 'GLOBAL' + global->Set(String::NewSymbol("GLOBAL"), global); + Local process_template = FunctionTemplate::New(); node::EventEmitter::Initialize(process_template); process = Persistent::New(process_template->GetFunction()->NewInstance()); // Assign the process object to its place. - Local global = Context::GetCurrent()->Global(); global->Set(String::NewSymbol("process"), process); // process.version @@ -949,17 +953,10 @@ int main(int argc, char *argv[]) { "Use 'd8 --remote_debugger' to access it.\n"); } - // Create the 'GLOBAL' object's FunctionTemplate. - Local global_template = FunctionTemplate::New(); - // Create the one and only Context. - Persistent context = Context::New(NULL, - global_template->InstanceTemplate()); + Persistent context = Context::New(); Context::Scope context_scope(context); - // Actually assign the global object to it's place as 'GLOBAL' - context->Global()->Set(String::NewSymbol("GLOBAL"), context->Global()); - // Create all the objects, load modules, do everything. // so your next reading stop should be node::Load()! node::Load(argc, argv); -- 2.7.4