Comment #1 on issue 162 by matt.seeg:  Internal field count of global  
template ignored during context creation
http://code.google.com/p/v8/issues/detail?id=162

It appears that this isn't actually broken.  The confusing thing seems to  
be that the
object created by the passed in global template is actually the prototype  
of the
global object of the context.

In code:

     // define a scope
     HandleScope scope_temp;
     // the global object template
     Handle<ObjectTemplate> template_global = ObjectTemplate::New();
     template_global->SetInternalFieldCount(1);
     // create the context using our template
     Handle<Context> context = Context::New(0, template_global);
     // this is 0
     cout << "global object internal field count: " << context->Global()-
> InternalFieldCount() << endl;
     // but this is 1
     cout << "global object prototype internal field count: " <<
Handle<Object>::Cast(context->Global()->GetPrototype())->InternalFieldCount()  
<<
endl;

The other thing that happens is that the prototype object of the global  
object is
what gets passed to any interceptor or accessor functions you attach to the  
object
template.  So even if one does the workaround suggested by kuesters, the  
object
passed to any callbacks won't have the data that you added to the global.   
You have
to add the data to the prototype anyway.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

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

Reply via email to