By naming a scope I mean to say that whether we can define a name for a scope. For example there are two scope scope1 and scope2 and i want to create scope2 inside scope1,how can i do that. Also whether it is possible to name these scopes.
As in other jsengines like spidermonkey we can have different names for different scope by creating a new object inside other and defining a property (name) for the same.Is there some API in V8 which functions the same way. I have gone through the test programs but i was not able to find any such tests. eg. If there are two scopes "session" and "application". and each have one JS variable sess1 and app1 respectively. I can access sess1 and app1 irrespective of the scope that i currently am using session.sess1 or application.app1.Also if application is created inside the session then we can access app1 using session.application.app1. On Aug 7, 11:53 am, Søren Gjesse <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
