Thanks Chris for taking the initiative to do this! New code looks much more pleasant to read now.
On Thursday, September 25, 2014, Chris Dumez <[email protected]> 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 > > > > > -- - R. Niwa
_______________________________________________ webkit-dev mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-dev

