Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (19 sloc) 539 Bytes
#include <v8.h>
#include <node.h>
using namespace v8;
Handle<Value> Square(const Arguments &args) {
HandleScope scope;
int a = args[0]->Int32Value();
int sq = a * a;
return scope.Close(Integer::New(sq));
}
extern "C" {
static void Init(Handle<Object> target) {
HandleScope scope;
Handle<FunctionTemplate> squareTpl =
FunctionTemplate::New(Square);
target->Set(String::New("square"),
squareTpl->GetFunction());
}
NODE_MODULE(simplefunctions, Init)
}
Something went wrong with that request. Please try again.