The reason for this behavior is that Context::Global() will actually return the global proxy instead of the global object itself as the comments above this method explain. The actual global object itself will have the correct internal field count as the following lines should verify.
v8::Handle<v8::Object> globalProxy = v8::Context::GetCurrent()->Global(); v8::Handle<v8::Object> globalObject = globalProxy->GetPrototype()->ToObject(); std::cout << "Internal Fields via Global: " << globalObject->->InternalFieldCount() << std::endl; Best regards, Michael On Mon, Jun 3, 2013 at 7:24 PM, Joe Wood <[email protected]> wrote: > The InternalFieldCount seems to be ignored when used in through an > ObjectTemplate passed as a parameter to Context::New. The following code > shows the problem: > > v8::Local<v8::ObjectTemplate> templte = v8::ObjectTemplate::New(); > templte->Set( "Prop", v8::String::New("Value")); > templte->SetInternalFieldCount(1); > > > // create object view context, access instance via Context->Global > v8::Handle<v8::Context> context = > v8::Context::New(v8::Isolate::GetCurrent(),NULL, templte); > context->Enter(); > v8::Context::Scope context_scope(context); > std::cout << "Internal Fields via Global: " << > v8::Context::GetCurrent()->Global()->InternalFieldCount() << std::endl; > > > // create object directly from template > v8::Local<v8::Object> instt = templte->NewInstance(); > std::cout << "Internal Fields via Instance: " << > instt->InternalFieldCount() << std::endl; > > > The output from the abiove yields: > > Internal Fields via Global: 0 > Internal Fields via Instance: 1 > > > Is this expected behavior or a bug? > > Thanks > > Joe Wood > > -- > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
