Thanks Chris for taking the initiative to do this! New <span></span>code looks much more pleasant to read now. <br><br>On Thursday, September 25, 2014, Chris Dumez <<a href="mailto:cdumez@apple.com">cdumez@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Hi all,</div><div><br></div><div>I started working on automatically generating the type <b>casting</b> helpers for HTML/SVG/MathML Elements (e.g. toHTMLDivElement()). Until now, we were generating only the type <b>checking</b> helpers using <a href="http://make_names.pl" target="_blank">make_names.pl</a> (e.g. isHTMLDivElement()). The type <b>casting</b> helpers had to be manually defined using NODE_TYPE_CASTS() macro.</div><div><br></div><div>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).</div><div><br></div><div>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.</div><div>The new style is very close to C++’s is_class<T>() and Boost’s polymorphic_downcast<T>().</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div>Kr,<br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div>--</div><div>Chris Dumez - Apple Inc.</div><div>Cupertino, CA</div><div><br></div></div><br><br>
</div>
<br></div></blockquote><br><br>-- <br>- R. Niwa<br>