On Tue, Aug 3, 2010 at 12:29 AM, christy <[email protected]> wrote:
> I have a question can FunctionTemplates be used like an
> ObjectTemplate?
>
> In other words it is possible for a FunctionTemplate to do something
> like this...
>
> V8FunctionTemplateHandle functionTemplateHandle =
> V8FunctionTemplate::New(InternalConstructor, external);
> V8ObjectTemplateHandle instanceTemplate = new functionTemplateHandle-
>>InstanceTemplate();
> V8ObjectHandle instance = instanceTemplate->NewInstance();
> instance->SetInternalField(0, external);
> global->Set(V8Converter::ToV8String(Name), v8Instance);
>
> Essentially what I want to do is register a single instance of the
> Function Template and "hide" the constructor by not registering it in
> the context.

Absolutely. FunctionTemplate#getFunction#newInstance and
FunctionTemplate#getInstanceTemplate#newInstance are equivalent.

But note that the "constructor" property of the object will still be
available to JS code to call.

>
> Since I'm registering a single instance to the context it seems to me
> the instance should behave as if I used an ObjectTemplate.
>
> If this behavior is supported than that would make coding for what I'm
> doing easier since I can internally treat all objects being created
> from FunctionTemplate.
>
> Thanks.
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

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

Reply via email to