view nodejs/mbfly_njs.cc @ 548:f69b0814ef3c Android_Skia

Test FunctionTemplate
author Thinker K.F. Li <thinker@branda.to>
date Sun, 06 Jun 2010 13:45:25 +0800
parents 371690a166df
children c9d23f7279a4
line wrap: on
line source

#include <stdio.h>
#include <v8.h>

using namespace v8;

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

    return String::Concat(String::New("World"), args[0]->ToString());
}

extern "C" void
init(Handle<Object> target) {
    HandleScope scope;
    Handle<FunctionTemplate> func;

    func = FunctionTemplate::New(hello_func);
    target->Set(String::New("Hello"), func->GetFunction());
}