Summary: | Add jsCast to replace static_cast | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Mark Hahnenberg <mhahnenberg> | ||||
Component: | JavaScriptCore | Assignee: | Mark Hahnenberg <mhahnenberg> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | abarth, barraclough, ggaren, japhet, oliver, webkit.review.bot | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
Mark Hahnenberg
2011-11-10 16:00:59 PST
Created attachment 114615 [details]
Patch
Comment on attachment 114615 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=114615&action=review r=me > Source/JavaScriptCore/runtime/JSCell.h:333 > + template <typename To, typename From> Should be no space before "<". (Think of template arguments just like function arguments.) > Source/JavaScriptCore/runtime/JSCell.h:336 > + ASSERT(from->classInfo() == &WTF::RemovePointer<To>::Type::s_info || from->inherits(&WTF::RemovePointer<To>::Type::s_info)); Since you're checking inherits(), I don't think you need to check ==. == is a subset of inherits(). (In reply to comment #0) > jsCast will behave like a static_cast when performance matters and a dynamic_cast using our own custom RTTI in our debug builds. Presumably you mean we'll ASSERT in debug builds? - I wouldn't make sense to change behavior in debug/ndebug - that would just mask bugs. > Presumably you mean we'll ASSERT in debug builds? - I wouldn't make sense to change behavior in debug/ndebug - that would just mask bugs.
Right. Since we're using an ASSERT, it will actually perform the check at runtime that the object is of the correct type in debug builds. Sorry about comparing to dynamic_cast, I just meant that we check dynamically. It won't return null or any of that stuff.
Committed r100006: <http://trac.webkit.org/changeset/100006> |