annotate 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
rev   line source
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #include <stdio.h>
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
2 #include <v8.h>
546
249bcbf07eb0 Reuse and adapt X_supp.c by implmeneting X_supp_njs.c
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
4 using namespace v8;
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
5
548
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
6 Handle<Value>
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
7 hello_func(const Arguments &args) {
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
8 HandleScope scope;
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
9
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
10 return String::Concat(String::New("World"), args[0]->ToString());
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
11 }
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
12
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
13 extern "C" void
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
14 init(Handle<Object> target) {
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
15 HandleScope scope;
548
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
16 Handle<FunctionTemplate> func;
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
17
548
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
18 func = FunctionTemplate::New(hello_func);
f69b0814ef3c Test FunctionTemplate
Thinker K.F. Li <thinker@branda.to>
parents: 547
diff changeset
19 target->Set(String::New("Hello"), func->GetFunction());
547
371690a166df Remove hello.c and initial plugin at mbfly_njs.cc
Thinker K.F. Li <thinker@branda.to>
parents: 546
diff changeset
20 }