Thanks :)   Yeah, I create that function that knows about the types in my
system at compile time from types provided by the user, so it ends up
pretty flexible.

--Zac

On Mon, Feb 15, 2016 at 2:04 AM, Jochen Eisinger <[email protected]>
wrote:

> ah yes, in chromium (and v8) we compile without RTTI, so we can't rely on
> dynamic_cast. But yes, you can store a AnyBase* in the internal field and
> then use a huge type switch to figure out the actual class.
>
> Note that you still need a function that knows about all types you
> possible have in your system (the typeswitch)..
>
> On Fri, Feb 5, 2016 at 1:53 PM Zac Hansen <[email protected]> wrote:
>
>> I think I did find it in WrapperTypeInfo.h.   And while I don't
>> understand exactly how it works, I'm guessing it requires each class that
>> contains a static WrapperTypeInfo to configure it in such a way that it can
>> retrieve information like what derived classes are and such?
>>
>> I'm trying to write something that can work with arbitrary classes.. my
>> current solution is to allow users to make an explicit list if which
>> classes can be substituted in when a certain type is wanted.   It uses
>> sfinae to make sure the specified types are derived types.
>>
>> Basically wrap_class_for_js<MyClass>().add_compatible_types<MyClassChild,
>> MyClassGrandChild>();
>>
>> so when you say "some_function(new MyClassChild())" in javascript, my
>> callback says "Is the GetInternalField of the v8::Object a MyClass?   No?
>> Then let me try the compatible types.   Is it a MyClassChild?  Yes.  Ok,
>> send the pointer in".   If it makes it to the end of the compatible type
>> list without a match, it throws an exception (which is wrapped in a
>> isoalte->ThrowException() before control returns to V8).
>>
>> The thing I put int the InternalField v8::External is actually an
>> "AnyBase*" which is a base class of all Any<T> objects.. so I can use
>> dynamic_cast to do the testing of whether the type is a desired type or not.
>>
>> --
>> --
>> 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