Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 75db199

Browse files
committed
Don't conflict with V8's Script class
Closes GH-203.
1 parent 4cc0a08 commit 75db199

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lib/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
var NativeModule = require('native_module');
23-
var Script = process.binding('evals').Script;
23+
var Script = process.binding('evals').NodeScript;
2424
var runInThisContext = Script.runInThisContext;
2525
var runInNewContext = Script.runInNewContext;
2626
var assert = require('assert').ok;

lib/vm.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
var binding = process.binding('evals');
2323

24-
exports.Script = binding.Script;
24+
exports.Script = binding.NodeScript;
2525
exports.createScript = function(code, ctx, name) {
2626
return new exports.Script(code, ctx, name);
2727
};
2828

29-
exports.createContext = binding.Script.createContext;
30-
exports.runInContext = binding.Script.runInContext;
31-
exports.runInThisContext = binding.Script.runInThisContext;
32-
exports.runInNewContext = binding.Script.runInNewContext;
29+
exports.createContext = binding.NodeScript.createContext;
30+
exports.runInContext = binding.NodeScript.runInContext;
31+
exports.runInThisContext = binding.NodeScript.runInThisContext;
32+
exports.runInNewContext = binding.NodeScript.runInNewContext;

src/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
// core modules found in lib/*.js. All core modules are compiled into the
350350
// node binary, so they can be loaded faster.
351351

352-
var Script = process.binding('evals').Script;
352+
var Script = process.binding('evals').NodeScript;
353353
var runInThisContext = Script.runInThisContext;
354354

355355
function NativeModule(id) {

src/node_script.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ void WrappedScript::Initialize(Handle<Object> target) {
150150
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedScript::New);
151151
constructor_template = Persistent<FunctionTemplate>::New(t);
152152
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
153-
constructor_template->SetClassName(String::NewSymbol("Script"));
153+
// Note: We use 'NodeScript' instead of 'Script' so that we do not
154+
// conflict with V8's Script class defined in v8/src/messages.js
155+
// See GH-203 https://github.com/joyent/node/issues/203
156+
constructor_template->SetClassName(String::NewSymbol("NodeScript"));
154157

155158
NODE_SET_PROTOTYPE_METHOD(constructor_template,
156159
"createContext",
@@ -184,7 +187,7 @@ void WrappedScript::Initialize(Handle<Object> target) {
184187
"runInNewContext",
185188
WrappedScript::CompileRunInNewContext);
186189

187-
target->Set(String::NewSymbol("Script"),
190+
target->Set(String::NewSymbol("NodeScript"),
188191
constructor_template->GetFunction());
189192
}
190193

0 commit comments

Comments
 (0)