Fatal error in v8::Function::Cast()

24 views
Skip to first unread message

swathi jakkam

unread,
Apr 17, 2012, 7:30:26 AM4/17/12
to v8-users
Hi,

I am getting error in below line

v8::Local<v8::Function> func2 = v8::Local<v8::Function>::Cast(context-
>Global()->Get(v8::String::New("JS_dump")));

I am getting following error
I got Fatal error in v8::Function::Cast() Could not convert to
function

How to resolve the this type of error.Could you please any one tell
the solution.???????

Actually my code is

char *script_name = "tt.js";
char *script = ReadFile(script_name);
if(!script){
printf("Unable to execute script.js");
return false;
}

//convert the string with the script to a v8 string
v8::Handle<v8::String> source = v8::String::New(script,
strlen(script));
v8::Handle<v8::Script> script2 = v8::Script::Compile(source);
script2->Run();

v8::Local<v8::Function> func2 = v8::Local<v8::Function>::Cast(context-
>Global()->Get(v8::String::New("JS_dump")));
v8::Handle<v8::Value> result2 = func2->Call(func2, 0, NULL);

printf("Function result: %d\n", result2->Int32Value());
//end of the code

How to solve this issue.

thanks,
swathi.
Reply all
Reply to author
Forward
0 new messages