Status: New
Owner: ----

New issue 837 by brickysam26: SetInternalFieldCount for InstanceTemplate of FunctionTemplate fails
http://code.google.com/p/v8/issues/detail?id=837

I am unable to set the InternalFieldCount on the InstanceTemplate of a FunctionTemplate and have that value carry over to a Function created using FunctionTemplate::GetFunction.

Maybe I am doing something wrong here, it works fine on an ObjectTemplate that is not the instance template of a FunctionTemplate.

I have tried adding an Accessor for the template, as well as setting the internal field count of the prototype template, neither of which have any effect on the InternalFieldCount of a Function.


{{{
Local<FunctionTemplate> temp = FunctionTemplate::New(New, proxyHandler);

    Local<ObjectTemplate> instance = temp->InstanceTemplate();

    instance->SetNamedPropertyHandler(GetNamedProperty,
                                      SetNamedProperty,
// different versions of V8 require different return types
// 0.1.97 is where the switch occurred in v8,
// but NODE_*_VERSION wasn't added until 0.1.100
#ifndef NODE_MAJOR_VERSION
                                      QueryNamedProperty,
#elif PROXY_NODE_VERSION_AT_LEAST(0, 1, 98)
                                      QueryNamedPropertyInteger,
#else
                                      QueryNamedProperty,
#endif
                                      DeleteNamedProperty,
                                      EnumerateNamedProperties);

    instance->SetIndexedPropertyHandler(GetIndexedProperty,
                                        SetIndexedProperty,
// different versions of V8 require different return types
// 0.2.0 is where the switch occurred
#ifndef NODE_MAJOR_VERSION
                                  QueryIndexedProperty,
#elif PROXY_NODE_VERSION_AT_LEAST(0, 2, 0)
                                  QueryIndexedPropertyInteger,
#else
                                  QueryIndexedProperty,
#endif
                                        DeleteIndexedProperty);


        //instance->SetAccessor(String::New("__crazy__"), GetNamedProperty);
        instance->SetInternalFieldCount(1);
        
        //Local<ObjectTemplate> proto = temp->PrototypeTemplate();
        //proto->SetInternalFieldCount(1);
        //proto->SetAccessor(String::New("__crazy__"), GetNamedProperty);

    Local<Function> fn = temp->GetFunction();
        //Local<Object> fn = instance->NewInstance();
        assert(fn->InternalFieldCount() > 0);
}}}

source code: http://github.com/brickysam26/node-proxy

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

Reply via email to