On Thu, Jul 2, 2009 at 10:23 PM, Dean McNamee<[email protected]> wrote:
>
> The easiest thing to do would be to keep around your original function
> template (the one you're using to configure Points), and to call
> HasInstance on that.
In principle, the callback "data" of the call handler would be the
right place for this, i.e.
SetCallHandler(ConstructPoint, _classTemplate);
and
ConstructPoint(args) {
template =3D Handle<FunctionTemplate>::Cast(args.Data())
...
}
Unfortunately, a FunctionTemplate is not a v8::Value, but (in the
current implementation of v8) it is actually safe to do a cast here
(it is just overly restrictive typing of the embedding API):
SetCallHandler(ConstructPoint,
Handle<Value>(reinterpret_cast<Value*>(*_classTemplate)));
...
and
Handle<FunctionTemplate>
template(reinterpret_cast<FunctionTemplate*>(*args.Data())));
HTH
Matthias
>
> For example, the Chromium DOM bindings keep a static persistent handle
> to the function template for every wrapper type.
>
> On Thu, Jul 2, 2009 at 8:33 PM, zolee<[email protected]> wrote:
>>
>> Yes, I already found this but I have a little casting problem:
>>
>> v8::Local<v8::Value> _v = args[0];
>> if (_v->IsObject())
>> {
>> v8::Local<v8::Object> _o = _v->ToObject();
>>
>> v8::Local<v8::Context> _context = v8::Context::GetCurrent();
>> v8::Local<v8::Value> _ft = _context->Global()->Get(v8::String::New
>> ("Point"));
>>
>> // How to cast _ft to FunctionTemplate (the Point is a
>> FunctionTemplate)?
>> }
>> >
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---