Bug 136809 - TYPE_CASTS_BASE needs to support both for pointer and reference argument by single expression
Summary: TYPE_CASTS_BASE needs to support both for pointer and reference argument by s...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 136773
  Show dependency treegraph
 
Reported: 2014-09-14 20:04 PDT by Gyuyoung Kim
Modified: 2014-09-16 09:03 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gyuyoung Kim 2014-09-14 20:04:54 PDT
As suggested in https://bugs.webkit.org/show_bug.cgi?id=136775#c3, TYPE_CASTS_BASE needs to support .get() globally.
Comment 1 Darin Adler 2014-09-14 22:30:38 PDT
If we really want to make toXXX(RefPtr) give us a raw pointer, then I think toXXX(Ref) and toXXX(PassRef) should give use a raw reference. A good way to do that is to make a template that can take any type and use getPtr to turn the pointer into a raw pointer. That will work on all smart pointer types that we overload getPtr for. Similarly, we could create a getReference to make this generic across all smart reference types. I think that’s better than something specific to RefPtr.
Comment 2 Gyuyoung Kim 2014-09-16 08:08:25 PDT
Darin, there are some specific use cases of TYPE_CASTS_BASE. For example, CSS_BASIC_SHAPES_TYPE_CASTS compares argument type to predicate argument. In this case, it is hard to convert a pointer to a reference using *(X) in the macro.

#define CSS_BASIC_SHAPES_TYPE_CASTS(ToValueTypeName, predicate) \
    TYPE_CASTS_BASE(ToValueTypeName, CSSBasicShape, basicShape, basicShape->type() == predicate, basicShape.type() == predicate) 

Any suggestion about those cases ?
Comment 3 Darin Adler 2014-09-16 09:03:34 PDT
(In reply to comment #2)
> Darin, there are some specific use cases of TYPE_CASTS_BASE. For example, CSS_BASIC_SHAPES_TYPE_CASTS compares argument type to predicate argument. In this case, it is hard to convert a pointer to a reference using *(X) in the macro.
> 
> #define CSS_BASIC_SHAPES_TYPE_CASTS(ToValueTypeName, predicate) \
>     TYPE_CASTS_BASE(ToValueTypeName, CSSBasicShape, basicShape, basicShape->type() == predicate, basicShape.type() == predicate) 
> 
> Any suggestion about those cases ?

I don’t see the problem you are talking about.

    a) basicShape->type() == predicate
    b) basicShape.type() == predicate
    c) (*basicShape).type() == predicate

It seems the macro could use (*x) to use the second expression only and not need (a). Maybe I could advise you on approach if you posted a partial unsuccessful attempt?