Ok, I think your problem is that you want to replace the global object
of context, right?

I suggest you could create the context with a customized global_object
that point to a stub object, which will redirect any getter/setter/
call to your document object later. Because any v8 javascript object
must belongs to a context, so, you could create a stub object from C
side, and create document object ASAP after create context, and set
the stub object redirect the remaining call.

class V8EXPORT Context {
  /** Creates a new context. */
  static Persistent<Context> New(
      ExtensionConfiguration* extensions = 0,
      Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>
(),
      Handle<Value> global_object = Handle<Value>());

The __proto__ doesn't work because for your scene.

On 1月22日, 下午10时47分, Andrey Semashev <[email protected]> wrote:
> I'll explain more closely to the code. Let's assume my scope hierarchy
> is initialized the way I presented in my post. I have this script:
>
>   var x = 10;
>
> and I want to execute it in the document scope. So the sequence should
> be like this:
>
>   [set the current scope to session.application.document]
>   v8::Script::Run(); // run the script
>   [restore scope to the root object]
>
> so that then I have "typeof(session.application.document.x) ==
> number", and "typeof(x) == undefined".
>
> On 22 янв, 17:31, Flier Lu <[email protected]> wrote:
>
> > So, what's your expected? As you know, any object you create in global
> > name space will be accessible as a property of global object.
>
> > On 1月22日, 下午10时21分, Andrey Semashev <[email protected]> wrote:
>
> > > BTW, this is how I create the needed scope hierarchy:
>
> > >   var Session = new Function();
> > >   var Application = new Function();
> > >   var Document = new Function();
> > >   var Dialog = new Function();
>
> > >   var session = new Session();
> > >   Application.prototype = session;
>
> > >   session.application = new Application();
> > >   Document.prototype = session.application;
>
> > >   session.application.document = new Document();
> > >   Dialog.prototype = session.application.document;
>
> > >   session.application.document.dialog = new Dialog();

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to