Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Bodo Kaiser June 08, 2013
file 37 lines (25 sloc) 0.766 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include "v8.h"
#include "node.h"

using namespace v8;

Handle<Value> Create(const Arguments &args);
Handle<Value> Anonymous(const Arguments &args);

void
Initialize(Handle<Object> exports, Handle<Object> module) {
    module->Set(String::NewSymbol("exports"),
            FunctionTemplate::New(Create)->GetFunction());
}

Handle<Value>
Echo(const Arguments &args) {
    HandleScope scope;

    Local<String> str = String::New("Hello World");

    return scope.Close(str);
}

Handle<Value>
Create(const Arguments &args) {
    HandleScope scope;

    Local<FunctionTemplate> tpl = FunctionTemplate::New(Echo);
    Local<Function> fn = tpl->GetFunction();

    fn->SetName(String::NewSymbol("echo"));

    return scope.Close(fn);
}

NODE_MODULE(function, Initialize)
Something went wrong with that request. Please try again.