Created
January 25, 2010 20:26
-
-
Save zimbatm/286206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without patch: | |
$ ./node test.js | |
Error: Unhandled emitError: ["moo"] | |
at node.js:257:15 | |
at IdleWatcher.callback (node.js:347:5) | |
at node.js:985:1 | |
at node.js:989:1 | |
# With patch: | |
$ ./node test.js | |
Error: Unhandled emitError: ["moo"] | |
at <error: Error: GLOBAL was renamed to global> | |
at IdleWatcher.callback (node.js:349:5) | |
at <error: Error: GLOBAL was renamed to global> | |
at <error: Error: GLOBAL was renamed to global> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/node.cc b/src/node.cc | |
index 8796047..82d1cfb 100644 | |
--- a/src/node.cc | |
+++ b/src/node.cc | |
@@ -910,8 +910,8 @@ static Local<Object> Load(int argc, char *argv[]) { | |
Local<Object> global = Context::GetCurrent()->Global(); | |
- // Assign the global object to it's place as 'GLOBAL' | |
- global->Set(String::NewSymbol("GLOBAL"), global); | |
+ // Assign the global object to it's place as 'global' | |
+ global->Set(String::NewSymbol("global"), global); | |
Local<FunctionTemplate> process_template = FunctionTemplate::New(); | |
node::EventEmitter::Initialize(process_template); | |
diff --git a/src/node.js b/src/node.js | |
index 2ac3b54..127a3d3 100644 | |
--- a/src/node.js | |
+++ b/src/node.js | |
@@ -8,15 +8,15 @@ function removed (reason) { | |
} | |
} | |
-GLOBAL.__module = removed("'__module' has been renamed to 'module'"); | |
-GLOBAL.include = removed("include(module) has been removed. Use process.mixin(GLOBAL, require(module)) to get the same effect."); | |
-GLOBAL.puts = removed("puts() has moved. Use require('sys') to bring it back."); | |
-GLOBAL.print = removed("print() has moved. Use require('sys') to bring it back."); | |
-GLOBAL.p = removed("p() has moved. Use require('sys') to bring it back."); | |
+global.__module = removed("'__module' has been renamed to 'module'"); | |
+global.include = removed("include(module) has been removed. Use process.mixin(global, require(module)) to get the same effect."); | |
+global.puts = removed("puts() has moved. Use require('sys') to bring it back."); | |
+global.print = removed("print() has moved. Use require('sys') to bring it back."); | |
+global.p = removed("p() has moved. Use require('sys') to bring it back."); | |
process.debug = removed("process.debug() has moved. Use require('sys') to bring it back."); | |
process.error = removed("process.error() has moved. Use require('sys') to bring it back."); | |
-GLOBAL.node = {}; | |
+global.node = {}; | |
node.createProcess = removed("node.createProcess() has been changed to process.createChildProcess() update your code"); | |
node.exec = removed("process.exec() has moved. Use require('sys') to bring it back."); | |
@@ -33,6 +33,8 @@ node.tcp.createConnection = removed("node.tcp.createConnection() has moved. Use | |
node.dns = {}; | |
node.dns.createConnection = removed("node.dns.createConnection() has moved. Use require('dns') to access it."); | |
+global.__defineGetter__("GLOBAL", removed("GLOBAL was renamed to global")); | |
+ | |
/**********************************************************************/ | |
// Module | |
@@ -122,7 +124,7 @@ process.mixin = function() { | |
// mixin process itself if only one argument is passed | |
if ( length == i ) { | |
- target = GLOBAL; | |
+ target = global; | |
--i; | |
} | |
@@ -461,27 +463,27 @@ function addTimerListener (callback) { | |
} | |
} | |
-GLOBAL.setTimeout = function (callback, after) { | |
+global.setTimeout = function (callback, after) { | |
var timer = new process.Timer(); | |
addTimerListener.apply(timer, arguments); | |
timer.start(after, 0); | |
return timer; | |
}; | |
-GLOBAL.setInterval = function (callback, repeat) { | |
+global.setInterval = function (callback, repeat) { | |
var timer = new process.Timer(); | |
addTimerListener.apply(timer, arguments); | |
timer.start(repeat, repeat); | |
return timer; | |
}; | |
-GLOBAL.clearTimeout = function (timer) { | |
+global.clearTimeout = function (timer) { | |
if (timer instanceof process.Timer) { | |
timer.stop(); | |
} | |
}; | |
-GLOBAL.clearInterval = GLOBAL.clearTimeout; | |
+global.clearInterval = global.clearTimeout; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
throw 'moo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment