Created
August 23, 2015 22:08
-
-
Save gabrielschulhof/bd017094cd8aeb2e463c to your computer and use it in GitHub Desktop.
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 <nan.h> | |
#include <node.h> | |
#include <v8.h> | |
using namespace v8; | |
int counter = 0; | |
NAN_METHOD( bind_OCProcess ) { | |
NanScope(); | |
counter++; | |
if ( counter >= 5 ) { | |
NanThrowError( "Some error" ); | |
} | |
NanReturnValue( NanNew<String>( "return value" ) ); | |
} | |
void Init(Handle<Object> exports, Handle<Object> module) { | |
exports->Set( NanNew<String>( "OCProcess" ), | |
NanNew<FunctionTemplate>( bind_OCProcess )->GetFunction() ); | |
} | |
NODE_MODULE( addonexample, Init ) |
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": "addonexample", | |
"sources": [ "addonexample.cc" ], | |
"include_dirs" : [ | |
"<!(node -e \"require('nan')\")" | |
] | |
} | |
], | |
} |
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( "bindings" )( "addonexample" ); | |
setInterval( function() { | |
addon.OCProcess(); | |
}, 1000 ); |
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
{ | |
"name": "addonexample", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"bindings": "^1.2.1", | |
"nan": "^1.8.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment