Skip to content

Instantly share code, notes, and snippets.

@iddar
Created January 19, 2015 20:27
Show Gist options
  • Select an option

  • Save iddar/c22968e11172578d5a22 to your computer and use it in GitHub Desktop.

Select an option

Save iddar/c22968e11172578d5a22 to your computer and use it in GitHub Desktop.
Modulo nativos en node.js
var addon = require('./build/Release/hello');
console.log("hola " + addon.hello()); // Salida: 'Hola noders'
{
"targets": [
{
"target_name": "hello",
"sources": [ "hello.cc" ]
}
]
}
#include <node.h>
#include <v8.h>
using namespace v8;
// Methid: Retorna un string "Noders"
Handle<Value> Method(const Arguments& args) {
HandleScope scope;
return scope.Close(String::New("Noders"));
}
void init(Handle<Object> exports) {
exports->Set(String::NewSymbol("hello"),
FunctionTemplate::New(Method)->GetFunction());
}
NODE_MODULE(hello, init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment