My favorites | Sign in
v8
Project Home Downloads Wiki Issues Source Code Search
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 435 attachment: main.cc (913 bytes)

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
#include <v8.h>

using namespace v8;

Handle<Value> testCallback(const Arguments& args)
{
return Undefined();
}

int main(int argc, char* argv[])
{
HandleScope handleScope;
Persistent<Context> context = Context::New();
Context::Scope contextScope(context);

Handle<FunctionTemplate> templ1 = FunctionTemplate::New(testCallback);
Handle<Function> fun1 = templ1->GetFunction();
fun1->Set(String::New("length"), Integer::New(2));

Handle<FunctionTemplate> args[2];
Handle<Signature> signature = Signature::New(Handle<FunctionTemplate>(), 2, args);
Handle<FunctionTemplate> templ2 = FunctionTemplate::New(testCallback, Handle<Value>(), signature);
Handle<Function> fun2 = templ2->GetFunction();

printf("fun1.length = %ld\n", Integer::Cast(*fun1->Get(String::New("length")))->Value());
printf("fun2.length = %ld\n", Integer::Cast(*fun2->Get(String::New("length")))->Value());

return 0;
}
Powered by Google Project Hosting