Created
January 19, 2015 20:27
-
-
Save iddar/c22968e11172578d5a22 to your computer and use it in GitHub Desktop.
Modulo nativos en node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var addon = require('./build/Release/hello'); | |
| console.log("hola " + addon.hello()); // Salida: 'Hola noders' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "targets": [ | |
| { | |
| "target_name": "hello", | |
| "sources": [ "hello.cc" ] | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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