can you point me to that code?

On Fri, Feb 5, 2016 at 12:11 AM, Jochen Eisinger <[email protected]>
wrote:

> In Blink, we store a pointer to a wrapper type info, and the void* on the
> object. The wrapper type info struct is used to determine the type of the
> void*. We also have some code that decides when you actually want to have
> type S* but the void* points to a T* whether it's safe to cast from T* to
> S*.
>
> hth
> -jochen
>
> On Fri, Feb 5, 2016 at 8:02 AM Zac Hansen <[email protected]> wrote:
>
>> Thinking more about this problem, I realize it's actually quite involved.
>>   Without some sort of type information about what's being stored, it
>> doesn't seem possible to see if something is a derived class of an
>> arbitrary type.
>>
>> Also, introducing some sort of templated pointer type to External would
>> require the whole stack to suddenly be templatized adn the concept of the
>> callback info object wouldn't work since it wouldn't be returning an array
>> of objects of the same type in it's operator[].
>>
>> I've settled on simply testing to see if it's exactly the right type as
>> what I'm trying to convert it to by wrapping it in a templated class with a
>> known base type and testing if the base type is dynamic_cast'able to the
>> specific type I want.   but that stops me from using parameters with
>> derived types which should be allowed.
>>
>> --Zac
>>
>>
>> On Thursday, February 4, 2016 at 9:09:54 PM UTC-8, Zac Hansen wrote:
>>>
>>> I'm in a FunctionTemplate callback and about to call a function that
>>> expects parameters of a certain type and I want to make sure that the
>>> variable backing the object is of the right type.  I know the type the
>>> function wants (T), but you can't call dynamic_cast<T>(my_void_ptr).
>>>
>>> Unless I'm missing something (which is entirely possible), it seems like
>>> it would be nice if v8::External were templated to take a pointer type.
>>> So I could say v8::External<T>::New(my_t_ptr) and then have
>>> my_local_external->Value() return a T* instead of a void *.   I'm not a
>>> template master, but I think you could make void * the default to not have
>>> any behavior change in the default case.
>>>
>>> I think a workaround for this is to make a templated wrapping class that
>>> inherits from a non-templated base class.. so I can say
>>> dynamic_cast<WrapperClass<T>>((WrapperBaseClass*)void_from_external) ==
>>> nullptr  and find out that way, but it doesn't seem like that workaround
>>> should be necessary.
>>>
>>> Anyone have a better way to do this (like something already in V8 I
>>> don't know about) or any thoughts on if v8::External could be made
>>> templated?   I'd be willing to write the patch, as it seems pretty trivial.
>>>
>>>
>>> Thank you!
>>>
>>> --Zac
>>>
>> --
>> --
>> 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/d/optout.
>>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/v8-users/rr4CkYpoZBY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
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/d/optout.

Reply via email to