From 488aff085b9d7b05593771ad2ef37463fce37f84 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 21 Aug 2010 01:19:39 -0700 Subject: [PATCH] Improve appendix markdown --- benchmark/buffer_creation.js | 2 +- benchmark/string_creation.js | 2 +- doc/api.markdown | 33 ++++++++++++++++----------------- src/node_buffer.cc | 19 +++++++++++++++++++ src/node_buffer.h | 1 + 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/benchmark/buffer_creation.js b/benchmark/buffer_creation.js index 3901f043fe..44ae32e315 100644 --- a/benchmark/buffer_creation.js +++ b/benchmark/buffer_creation.js @@ -1,6 +1,6 @@ -for (var i = 0; i < 9000000; i++) { +for (var i = 0; i < 9e7; i++) { b = new Buffer(10); b[1] = 2 } diff --git a/benchmark/string_creation.js b/benchmark/string_creation.js index f2b5d2cc00..7f81ec1090 100644 --- a/benchmark/string_creation.js +++ b/benchmark/string_creation.js @@ -1,6 +1,6 @@ -for (var i = 0; i < 9000000; i++) { +for (var i = 0; i < 9e7; i++) { s = '01234567890'; s[1] = "a"; } diff --git a/doc/api.markdown b/doc/api.markdown index 7196555461..4a41a2b562 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -3289,41 +3289,40 @@ For the moment, that is all the documentation on addons. Please see ## Appendix - Third Party Modules There are many third party modules for Node. At the time of writing, August -2010, the master repository of modules is the wiki page at - - http://github.com/ry/node/wiki/modules +2010, the master repository of modules is +http://github.com/ry/node/wiki/modules[the wiki page]. This appendix is intended as a SMALL guide to new-comers to help them quickly find what are considered to be quality modules. It is not intended to be a complete list. There may be better more complete modules found elsewhere. - Package System: NPM http://github.com/isaacs/npm +- Module Installer: [NPM](http://github.com/isaacs/npm) - HTML Parsing: HTML5 http://github.com/aredridel/html5 +- HTTP Middleware: [Connect](http://github.com/senchalabs/connect) - HTTP Middleware: Connect http://github.com/senchalabs/connect +- Web Framework: [Express](http://github.com/visionmedia/express) - Web Framework: Express http://github.com/visionmedia/express +- Web Sockets: [Socket.IO](http://github.com/LearnBoost/Socket.IO-node) - Web Sockets: Socket.IO http://github.com/LearnBoost/Socket.IO-node +- HTML Parsing: [HTML5](http://github.com/aredridel/html5) - mDNS/Zeroconf/Bonjour: mDNS http://github.com/agnat/node_mdns +- [mDNS/Zeroconf/Bonjour](http://github.com/agnat/node_mdns) - RabbitMQ, AMQP: http://github.com/ry/node-amqp +- [RabbitMQ, AMQP](http://github.com/ry/node-amqp) - MySQL: http://github.com/felixge/node-mysql +- [mysql](http://github.com/felixge/node-mysql) - Serialization: http://github.com/pgriess/node-msgpack +- Serialization: [msgpack](http://github.com/pgriess/node-msgpack) - Scraping: http://github.com/silentrob/Apricot +- Scraping: [Apricot](http://github.com/silentrob/Apricot) - Debugger: ndb http://github.com/smtlaissezfaire/ndb is a CLI debugger - Node-Inspector http://github.com/dannycoates/node-inspector is a web based +- Debugger: [ndb](http://github.com/smtlaissezfaire/ndb) is a CLI debugger + [inspector](http://github.com/dannycoates/node-inspector) is a web based tool. - pcap binding: http://github.com/mranney/node_pcap +- [pcap binding](http://github.com/mranney/node_pcap) - ncurses: http://github.com/mscdex/node-ncurses +- [ncurses](http://github.com/mscdex/node-ncurses) Patches to this list are welcome. diff --git a/src/node_buffer.cc b/src/node_buffer.cc index a26564ded9..a809ae96d5 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -701,6 +701,22 @@ Handle Buffer::ByteLength(const Arguments &args) { } +Handle Buffer::MakeFastBuffer(const Arguments &args) { + HandleScope scope; + + Buffer *buffer = ObjectWrap::Unwrap(args[0]->ToObject()); + Local fast_buffer = args[1]->ToObject();; + uint32_t offset = args[2]->Uint32Value(); + uint32_t length = args[3]->Uint32Value(); + + fast_buffer->SetIndexedPropertiesToPixelData((uint8_t*)buffer->data() + offset, + length); + + return Undefined(); +} + + + void Buffer::Initialize(Handle target) { HandleScope scope; @@ -731,6 +747,9 @@ void Buffer::Initialize(Handle target) { NODE_SET_METHOD(constructor_template->GetFunction(), "byteLength", Buffer::ByteLength); + NODE_SET_METHOD(constructor_template->GetFunction(), + "makeFastBuffer", + Buffer::MakeFastBuffer); target->Set(String::NewSymbol("Buffer"), constructor_template->GetFunction()); } diff --git a/src/node_buffer.h b/src/node_buffer.h index 61fecadaf2..e1c037120a 100644 --- a/src/node_buffer.h +++ b/src/node_buffer.h @@ -61,6 +61,7 @@ class Buffer : public ObjectWrap { static v8::Handle AsciiWrite(const v8::Arguments &args); static v8::Handle Utf8Write(const v8::Arguments &args); static v8::Handle ByteLength(const v8::Arguments &args); + static v8::Handle MakeFastBuffer(const v8::Arguments &args); static v8::Handle Unpack(const v8::Arguments &args); static v8::Handle Copy(const v8::Arguments &args);