facebookarchive / Shimmer

An easy way to add a simple, shimmering effect to any view in an iOS app.
Other
9.35k stars 1.11k forks source link

Fix shimmeringHighlightWidth documentation and deprecation attribute #56

Closed guillaumealgis closed 8 years ago

guillaumealgis commented 8 years ago

The property shimmeringHighlightWidth is causing 2 warnings with strict compiler flags.

The first one is because placing @deprecated right after @abstract in the documentation comment block causes the parser to think the @abstract is empty. This is fixed by moving @deprecated at the end of the comment block.

The second is caused by the method being documented as @deprecated but not marked as such with a compiler attribute. This is fixed by using the DEPRECATED_MSG_ATTRIBUTE macro.

facebook-github-bot commented 8 years ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

facebook-github-bot commented 8 years ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

grp commented 8 years ago

Thanks for the fix. Where does DEPRECATED_MSG_ATTRIBUTE come from?

guillaumealgis commented 8 years ago

DEPRECATED_MSG_ATTRIBUTE is defined by Apple in the iOS SDK AvailabilityMacros.h. Here's the full definition of the macro:

/*
 * only certain compilers support __attribute__((deprecated))
 */
#if defined(__has_feature) && defined(__has_attribute)
    #if __has_attribute(deprecated)
        #define DEPRECATED_ATTRIBUTE        __attribute__((deprecated))
        #if __has_feature(attribute_deprecated_with_message)
            #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
        #else
            #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated))
        #endif
    #else
        #define DEPRECATED_ATTRIBUTE
        #define DEPRECATED_MSG_ATTRIBUTE(s)
    #endif
#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
    #define DEPRECATED_ATTRIBUTE        __attribute__((deprecated))
    #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))
        #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s)))
    #else
        #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated))
    #endif
#else
    #define DEPRECATED_ATTRIBUTE
    #define DEPRECATED_MSG_ATTRIBUTE(s)
#endif

As far as I can tell, it has been around since the first version of the SDK.

Note that another option is to simply use DEPRECATED_ATTRIBUTE, but I thought providing a message with the replacement property name was helpful to the user.

grp commented 8 years ago

Cool, thanks! I had always seen __attribute__((deprecated)) used directly.