Browse Source

Merge branch 'master' into net2

Conflicts:
	test/simple/test-event-emitter-modify-in-emit.js
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
903977d5e8
  1. 4
      AUTHORS
  2. 13
      ChangeLog
  3. 2
      doc/api.txt
  4. 4
      doc/index.html
  5. 4
      src/node.cc
  6. 23
      src/node.js
  7. 3
      src/node_events.cc
  8. 23
      test/simple/test-event-emitter-modify-in-emit.js
  9. 32
      wscript

4
AUTHORS

@ -59,3 +59,7 @@ Kris Kowal <kris.kowal@cixar.com>
Jacek Becela <jacek.becela@gmail.com>
Rob Ellis <kazoomer@gmail.com>
Tim-Smart <timehAndGod@gmail.com>
Herbert Vojčík <herby@mailbox.sk>
Krishna Rajendran <krishna@emptybox.org>
pyrotechnick <pyrotechnick@feistystudios.com>
Carson McDonald <carson@ioncannon.net>

13
ChangeLog

@ -1,4 +1,15 @@
2010.03.12, Version 0.1.32
2010.03.19, Version 0.1.33
* Include lib/ directory in node executable. Compile on demand.
* evalcx clean ups (Isaac Z. Schlueter, Tim-Smart)
* Various fixes, clean ups
* V8 upgraded to 2.1.5
2010.03.12, Version 0.1.32, 61c801413544a50000faa7f58376e9b33ba6254f
* Optimize event emitter for single listener

2
doc/api.txt

@ -1,7 +1,7 @@
NODE(1)
=======
Ryan Dahl <ry@tinyclouds.org>
Version, 0.1.32, 2010.03.12
Version, 0.1.33, 2010.03.19
== NAME

4
doc/index.html

@ -96,8 +96,8 @@ server.listen(7000, "localhost");</pre>
<a href="http://github.com/ry/node/tree/master">git repo</a>
</p>
<p>
2010.03.12
<a href="http://nodejs.org/dist/node-v0.1.32.tar.gz">node-v0.1.32.tar.gz</a>
2010.03.19
<a href="http://nodejs.org/dist/node-v0.1.33.tar.gz">node-v0.1.33.tar.gz</a>
</p>
<h2 id="build">Build</h2>

4
src/node.cc

@ -872,6 +872,8 @@ Handle<Value> EvalCX(const Arguments& args) {
Local<String> code = args[0]->ToString();
Local<Object> sandbox = args.Length() > 1 ? args[1]->ToObject()
: Object::New();
Local<String> filename = args.Length() > 2 ? args[2]->ToString()
: String::New("evalcx");
// Create the new context
Persistent<Context> context = Context::New();
@ -891,7 +893,7 @@ Handle<Value> EvalCX(const Arguments& args) {
// Catch errors
TryCatch try_catch;
Local<Script> script = Script::Compile(code, String::New("evalcx"));
Local<Script> script = Script::Compile(code, filename);
Handle<Value> result;
if (script.IsEmpty()) {

23
src/node.js

@ -79,14 +79,19 @@ function createInternalModule (id, constructor) {
// Like, natives.fs is the contents of lib/fs.js
var natives = process.binding('natives');
function requireNative (id) {
if (internalModuleCache[id]) return internalModuleCache[id].exports;
if (!natives[id]) throw new Error('No such native module ' + id);
function loadNative (id) {
var m = new Module(id);
internalModuleCache[id] = m;
var e = m._compile(natives[id], id);
if (e) throw e;
return m.exports;
m.loaded = true;
return m;
}
function requireNative (id) {
if (internalModuleCache[id]) return internalModuleCache[id].exports;
if (!natives[id]) throw new Error('No such native module ' + id);
return loadNative(id).exports;
}
@ -167,7 +172,7 @@ process.mixin = function() {
var eventsModule = createInternalModule('events', function (exports) {
exports.EventEmitter = process.EventEmitter;
// process.EventEmitter is defined in src/events.cc
// process.EventEmitter is defined in src/node_events.cc
// process.EventEmitter.prototype.emit() is also defined there.
process.EventEmitter.prototype.addListener = function (type, listener) {
if (!(listener instanceof Function)) {
@ -531,10 +536,7 @@ function loadModule (request, parent, callback) {
// Try to compile from native modules
if (natives[id]) {
debug('load native module ' + id);
cachedModule = new Module(id);
var e = cachedModule._compile(natives[id], id);
if (e) throw e;
internalModuleCache[id] = cachedModule;
cachedModule = loadNative(id);
}
}
@ -713,9 +715,6 @@ Module.prototype._compile = function (content, filename) {
Module.prototype._loadScriptSync = function (filename) {
var content = requireNative('fs').readFileSync(filename);
// remove shebang
content = content.replace(/^\#\!.*/, '');
var e = this._compile(content, filename);
if (e) {
throw e;

3
src/node_events.cc

@ -50,7 +50,6 @@ static bool ReallyEmit(Handle<Object> self,
Local<Object> events = events_v->ToObject();
Local<Value> listeners_v = events->Get(event);
Local<Function> listener;
TryCatch try_catch;
@ -66,7 +65,7 @@ static bool ReallyEmit(Handle<Object> self,
}
} else if (listeners_v->IsArray()) {
Local<Array> listeners = Local<Array>::Cast(listeners_v);
Local<Array> listeners = Local<Array>::Cast(listeners_v->ToObject()->Clone());
for (uint32_t i = 0; i < listeners->Length(); i++) {
Local<Value> listener_v = listeners->Get(i);

23
test/simple/test-event-emitter-modify-in-emit.js

@ -8,6 +8,7 @@ var e = new events.EventEmitter();
function callback1() {
callbacks_called.push("callback1");
e.addListener("foo", callback2);
e.addListener("foo", callback3);
e.removeListener("foo", callback1);
}
@ -16,23 +17,39 @@ function callback2() {
e.removeListener("foo", callback2);
}
function callback3() {
callbacks_called.push("callback3");
e.removeListener("foo", callback3);
}
e.addListener("foo", callback1);
assert.equal(1, e.listeners("foo").length);
e.emit("foo");
assert.equal(1, e.listeners("foo").length);
assert.equal(2, e.listeners("foo").length);
assert.deepEqual(["callback1"], callbacks_called);
e.emit("foo");
assert.equal(0, e.listeners("foo").length);
assert.deepEqual(["callback1", "callback2"], callbacks_called);
assert.deepEqual(["callback1", "callback2", "callback3"], callbacks_called);
e.emit("foo");
assert.equal(0, e.listeners("foo").length);
assert.deepEqual(["callback1", "callback2"], callbacks_called);
assert.deepEqual(["callback1", "callback2", "callback3"], callbacks_called);
e.addListener("foo", callback1);
e.addListener("foo", callback2);
assert.equal(2, e.listeners("foo").length)
e.removeAllListeners("foo")
assert.equal(0, e.listeners("foo").length)
// Verify that removing callbacks while in emit allows emits to propagate to
// all listeners
callbacks_called = [ ];
e.addListener("foo", callback2);
e.addListener("foo", callback3);
assert.equal(2, e.listeners("foo").length)
e.emit("foo");
assert.deepEqual(["callback2", "callback3"], callbacks_called);
assert.equal(0, e.listeners("foo").length)

32
wscript

@ -7,7 +7,7 @@ from os.path import join, dirname, abspath
from logging import fatal
cwd = os.getcwd()
VERSION="0.1.32"
VERSION="0.1.33"
APPNAME="node.js"
import js2c
@ -337,10 +337,37 @@ def build(bld):
coupling.clone("debug")
### src/native.cc
def make_macros(loc, content):
f = open(loc, 'w')
f.write(content)
f.close
macros_loc_debug = join(
bld.srcnode.abspath(bld.env_of_name("debug")),
"macros.py"
)
macros_loc_default = join(
bld.srcnode.abspath(bld.env_of_name("default")),
"macros.py"
)
make_macros(macros_loc_debug, "") # leave debug(x) as is in debug build
# replace debug(x) with nothing in release build
make_macros(macros_loc_default, "macro debug(x) = ;\n")
def javascript_in_c(task):
env = task.env
source = map(lambda x: x.srcpath(env), task.inputs)
targets = map(lambda x: x.srcpath(env), task.outputs)
source.append(macros_loc_default)
js2c.JS2C(source, targets)
def javascript_in_c_debug(task):
env = task.env
source = map(lambda x: x.srcpath(env), task.inputs)
targets = map(lambda x: x.srcpath(env), task.outputs)
source.append(macros_loc_debug)
js2c.JS2C(source, targets)
native_cc = bld.new_task_gen(
@ -356,7 +383,8 @@ def build(bld):
# where.)
if bld.env["USE_DEBUG"]:
native_cc_debug = native_cc.clone("debug")
native_cc_debug.rule = javascript_in_c
native_cc_debug.rule = javascript_in_c_debug
native_cc.rule = javascript_in_c
### node lib

Loading…
Cancel
Save