I am not sure what you mean with *suppose I have pushed a scope named "session" through v8 api*, but I suggest you take a look at the API tests (test/cctest/test-api-cc) where most ways of using the API is tested. Also I suggest that you check for exceptions after script->Run() by either checking for an empty handle on return or use a TryCatch construct from the API. Also remember to set up a HandleScope before using handles.
Regards, Søren On Fri, Aug 7, 2009 at 07:31, Manoj Kumar <[email protected]> wrote: > > Hi Anders, > First of all thank you for link. > Now, I have a question about creating object using v8 api. My question > is that I want to create a object by using V8 APIs and access it > through javascript code. e.g suppose I have pushed a scope named > "session" through v8 api means session should be an javascript object. > Now we compile and execute a js script like: > > const char *jsCode = "var a = 5; var b = session.a;" > Pesistent<Context> context = Context::New(); > Context::Scope context_scope(context); > Handle<String> source = String::New(jsCode); > Handle<Script> script = Script::Compile(source); > Handle<Value> result = script->Run(); > > Next I want to get the value of "b" using my code: > Context::Scope context_scope(context); > Handle<String> source = String::New("b"); > Handle<Value> result; > Handle<Script> script = Script::Compile(source); > Handle<Value> result = script->Run(); > if(result->IsInt32()) > fprintf(stderr, "Value of b = %d\n", result->Int32Value > ()); > > Please help me for doing above thing. If possible, please provide me > sample code. > > Thanks, > Manoj > > > > --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
