That also sounds like reasonable behavior for something called cast<>() to me.
Sent from my iPhone > On Oct 2, 2014, at 5:01 PM, Benjamin Poulain <benja...@webkit.org> wrote: > > downcast<> fails if you do a useless cast/upcast. > > Benjamin > >> On 10/2/14, 4:47 PM, Sam Weinig wrote: >> This all looks wonderful! >> >> One question though, why downcast<>(…)? Will we be adding an upcast<>() >> function? Since the answer is probably no, could we just call this >> cast<>(…)? >> >> - Sam >> >>> On Sep 25, 2014, at 11:11 AM, Chris Dumez <cdu...@apple.com >>> <mailto:cdu...@apple.com>> wrote: >>> >>> Hi all, >>> >>> I started working on automatically generating the type *casting* >>> helpers for HTML/SVG/MathML Elements (e.g. toHTMLDivElement()). Until >>> now, we were generating only the type *checking* helpers using >>> make_names.pl (e.g. isHTMLDivElement()). The type *casting* helpers >>> had to be manually defined using NODE_TYPE_CASTS() macro. >>> >>> The type casting helpers are now automatically generated for most >>> types. Part of the solution involved using a templated function for >>> type casting because the types are forward-declared and we needed to >>> do a static_cast<>() (a reinterpret_cast<>() could be used with >>> forward declarations but wouldn’t be safe due to multiple inheritance). >>> >>> I initially had macros in place so that toHTMLDivElement() would still >>> work and would be equivalent to downcast<HTMLDivElement>(). The >>> feedback I received is that we should get rid of these macros and just >>> use is<HTMLDivElement>() / downcast<HTMLDivElement>() everywhere. >>> The new style is very close to C++’s is_class<T>() and Boost’s >>> polymorphic_downcast<T>(). >>> >>> I actually started updating the code to do this but I should have >>> emailed webkit-dev about this beforehand. I apologize for sending this >>> message a bit late. >>> >>> Please let me know if you have feedback / concerns / questions about >>> this change. I hope that this email gives you a better understanding >>> of why I am making this change. >>> >>> As I said before, the code base is not fully ported yet so the current >>> situation is not necessarily pretty. I will try and go through the >>> transition as fast as I can, provided that people don’t raise any >>> concerns about this. >>> >>> Please also note that these new helpers still catch unnecessary type >>> checks / casts. As a matter of fact, those are now caught at build >>> time instead of linking time and should give you a nice “Unnecessary >>> type check” / “Unnecessary type cast” static assertion. >>> >>> Also note that the plan is to get rid of TYPE_CAST_BASE() macro >>> entirely and extend is<>() / downcast<>() to all types, not just Nodes. >>> >>> Kr, >>> -- >>> Chris Dumez - Apple Inc. >>> Cupertino, CA >>> >>> >>> >>> >>> _______________________________________________ >>> webkit-dev mailing list >>> webkit-dev@lists.webkit.org <mailto:webkit-dev@lists.webkit.org> >>> https://lists.webkit.org/mailman/listinfo/webkit-dev > _______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev