标签:nodejs
#include <node.h>
#include <v8.h>
using namespace v8;
Handle<Value> SayHello(const Arguments& args) {
HandleScope scope;
return scope.Close(String::New("Hello world!"));
}
void Init_Hello(Handle<Object> target) {
target->Set(String::NewSymbol("SayHello"),FunctionTemplate::New(SayHello)->GetFunction());
}
NODE_MODULE(hello,Init_Hello)
{
'targets':[
{
'target_name':'hello',
'sources':['src/hello.cc'],
}]
}var hello = require('./build/Release/hello.node');
console.log(hello.SayHello());标签:nodejs
原文地址:http://blog.csdn.net/rainlesvio/article/details/41527865