Merge remote branch 'origin/v0.6'

pull/22966/head
Ben Noordhuis 2011-11-17 20:06:50 +00:00
commit bed405cfea
9 changed files with 98 additions and 13 deletions

View File

@ -3,4 +3,11 @@
'../../build/common.gypi',
'v8.gyp'
],
'target_defaults': {
'conditions': [
[ 'OS=="solaris"', {
'defines': [ '__C99FEATURES__=1' ],
}],
],
},
}

View File

@ -641,6 +641,13 @@
],
}
],
['OS=="solaris"', {
'sources': [
'../../src/platform-solaris.cc',
'../../src/platform-posix.cc'
],
}
],
['OS=="mac"', {
'sources': [
'../../src/platform-macos.cc',

View File

@ -22,8 +22,8 @@ Node statically compiles all its dependencies into the executable. When
compiling your module, you don't need to worry about linking to any of these
libraries.
To get started let's make a small Addon which does the following except in
C++:
To get started let's make a small Addon which is the C++ equivalent of
the following Javascript code:
exports.hello = function() { return 'world'; };
@ -40,11 +40,18 @@ To get started we create a file `hello.cc`:
}
void init(Handle<Object> target) {
NODE_SET_METHOD(target, "method", Method);
NODE_SET_METHOD(target, "hello", Method);
}
NODE_MODULE(hello, init)
This source code needs to be built into `hello.node`, the binary Addon. To
Note that all Node addons must export an initialization function:
void Initialize (Handle<Object> target);
NODE_MODULE(module_name, Initialize)
There is no semi-colon after `NODE_MODULE` as it's not a function (see `node.h`).
The source code needs to be built into `hello.node`, the binary Addon. To
do this we create a file called `wscript` which is python code and looks
like this:
@ -70,10 +77,12 @@ Running `node-waf configure build` will create a file
`node-waf` is just [WAF](http://code.google.com/p/waf), the python-based build system. `node-waf` is
provided for the ease of users.
All Node addons must export an initialization function:
You can now use the binary addon in a Node project `hello.js` by pointing `require` to
the recently built module:
void Initialize (Handle<Object> target);
NODE_MODULE(hello, Initialize)
var addon = require('./build/Release/hello');
console.log(addon.hello()); // 'world'
For the moment, that is all the documentation on addons. Please see
<https://github.com/ry/node_postgres> for a real example.

View File

@ -849,15 +849,13 @@ function Server(/* [options], listener */) {
passphrase: self.passphrase,
cert: self.cert,
ca: self.ca,
ciphers: self.ciphers,
ciphers: self.ciphers || 'RC4-SHA:AES128-SHA:AES256-SHA',
secureProtocol: self.secureProtocol,
secureOptions: self.secureOptions,
crl: self.crl,
sessionIdContext: self.sessionIdContext
});
sharedCreds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
// constructor call
net.Server.call(this, function(socket) {
var creds = crypto.createCredentials(null, sharedCreds.context);
@ -1017,7 +1015,6 @@ exports.connect = function(port /* host, options, cb */) {
var socket = new net.Stream();
var sslcontext = crypto.createCredentials(options);
//sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
convertNPNProtocols(options.NPNProtocols, this);
var pair = new SecurePair(sslcontext, false, true, false,

View File

@ -62,6 +62,7 @@
#include <v8.h>
#include <sys/types.h> /* struct stat */
#include <sys/stat.h>
#include <assert.h>
#include <node_object_wrap.h>

View File

@ -63,7 +63,7 @@ namespace node {
*/
class Buffer : public ObjectWrap {
class NODE_EXTERN Buffer: public ObjectWrap {
public:
static bool HasInstance(v8::Handle<v8::Value> val);

View File

@ -22,12 +22,13 @@
#ifndef object_wrap_h
#define object_wrap_h
#include <node.h>
#include <v8.h>
#include <assert.h>
namespace node {
class ObjectWrap {
class NODE_EXTERN ObjectWrap {
public:
ObjectWrap ( ) {
refs_ = 0;

View File

@ -0,0 +1,61 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var tls = require('tls');
var fs = require('fs');
if (process.platform === 'win32') {
console.log("Skipping test, you probably don't have openssl installed.");
process.exit();
}
var options = {
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'),
ciphers: 'NULL-MD5' // it's ultra-fast!
};
var reply = 'I AM THE WALRUS'; // something recognizable
var nconns = 0;
var response = '';
process.on('exit', function() {
assert.equal(nconns, 1);
assert.notEqual(response.indexOf(reply), -1);
});
var server = tls.createServer(options, function(conn) {
conn.end(reply);
nconns++;
});
server.listen(common.PORT, '127.0.0.1', function() {
var cmd = 'openssl s_client -cipher NULL-MD5 -connect 127.0.0.1:' + common.PORT;
exec(cmd, function(err, stdout, stderr) {
if (err) throw err;
response = stdout;
server.close();
});
});

View File

@ -37,6 +37,8 @@ if /i "%1"=="test-all" set test=test-all&goto arg-ok
if /i "%1"=="test" set test=test&goto arg-ok
if /i "%1"=="msi" set msi=1&goto arg-ok
if /i "%1"=="upload" set upload=1&goto arg-ok
:arg-ok
shift
goto next-arg