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.

Reply via email to