Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused/unneeded header macros #973

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add new protocol `ASLocking` that extends `NSLocking` with `tryLock`, and allows taking multiple locks safely. [Adlai Holler](https://github.com/Adlai-Holler)
- Make the main thread ivar deallocation system available to other classes. Plus a little optimization. See `ASMainThreadDeallocation.h`. [Adlai Holler](https://github.com/Adlai-Holler) [#959](https://github.com/TextureGroup/Texture/pull/959)
- Reduce usage of autorelease pools. [Adlai Holler](https://github.com/Adlai-Holler) [#968](https://github.com/TextureGroup/Texture/pull/968)
- Clean up unused/unneeded header macros. [Adlai Holler](https://github.com/Adlai-Holler)

## 2.7
- Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877)
Expand Down
64 changes: 0 additions & 64 deletions Source/Base/ASBaseDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,6 @@
# endif
#endif

#ifndef ASDISPLAYNODE_HIDDEN
# if ASDISPLAYNODE_GNUC (4,0)
# define ASDISPLAYNODE_HIDDEN __attribute__ ((visibility ("hidden")))
# else
# define ASDISPLAYNODE_HIDDEN /* no hidden */
# endif
#endif

#ifndef ASDISPLAYNODE_PURE
# if ASDISPLAYNODE_GNUC (3, 0)
# define ASDISPLAYNODE_PURE __attribute__ ((pure))
# else
# define ASDISPLAYNODE_PURE /* no pure */
# endif
#endif

#ifndef ASDISPLAYNODE_CONST
# if ASDISPLAYNODE_GNUC (3, 0)
# define ASDISPLAYNODE_CONST __attribute__ ((const))
# else
# define ASDISPLAYNODE_CONST /* no const */
# endif
#endif

#ifndef ASDISPLAYNODE_WARN_UNUSED
# if ASDISPLAYNODE_GNUC (3, 4)
# define ASDISPLAYNODE_WARN_UNUSED __attribute__ ((warn_unused_result))
# else
# define ASDISPLAYNODE_WARN_UNUSED /* no warn_unused */
# endif
#endif

#ifndef ASDISPLAYNODE_WARN_DEPRECATED
# define ASDISPLAYNODE_WARN_DEPRECATED 1
#endif
Expand All @@ -101,12 +69,6 @@
# endif
#endif

#if defined (__cplusplus) && defined (__GNUC__)
# define ASDISPLAYNODE_NOTHROW __attribute__ ((nothrow))
#else
# define ASDISPLAYNODE_NOTHROW
#endif

#ifndef AS_ENABLE_TIPS
#define AS_ENABLE_TIPS 0
#endif
Expand All @@ -122,8 +84,6 @@
# define AS_SAVE_EVENT_BACKTRACES 0
#endif

#define ARRAY_COUNT(x) sizeof(x) / sizeof(x[0])

#ifndef __has_feature // Optional.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
Expand All @@ -132,14 +92,6 @@
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
#endif

#ifndef NS_CONSUMED
#if __has_feature(attribute_ns_consumed)
#define NS_CONSUMED __attribute__((ns_consumed))
#else
#define NS_CONSUMED
#endif
#endif

#ifndef NS_RETURNS_RETAINED
#if __has_feature(attribute_ns_returns_retained)
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
Expand All @@ -156,22 +108,6 @@
#endif
#endif

#ifndef ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER
#define ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER() \
do { \
NSAssert2(NO, @"%@ is not the designated initializer for instances of %@.", NSStringFromSelector(_cmd), NSStringFromClass([self class])); \
return nil; \
} while (0)
#endif // ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER

// It's hard to pass quoted strings via xcodebuild preprocessor define arguments, so we'll convert
// the preprocessor values to strings here.
//
// It takes two steps to do this in gcc as per
// http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define ASDISPLAYNODE_TO_STRING(str) #str
#define ASDISPLAYNODE_TO_UNICODE_STRING(str) @ASDISPLAYNODE_TO_STRING(str)

#ifndef ASDISPLAYNODE_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define ASDISPLAYNODE_REQUIRES_SUPER __attribute__((objc_requires_super))
Expand Down
3 changes: 3 additions & 0 deletions Source/Details/ASPhotosFrameworkImageRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ API_AVAILABLE(ios(8.0), tvos(10.0))
*/
@property (nonatomic, readonly) NSURL *url;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
7 changes: 0 additions & 7 deletions Source/Details/ASPhotosFrameworkImageRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@

@implementation ASPhotosFrameworkImageRequest

- (instancetype)init
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
self = [self initWithAssetIdentifier:@""];
return nil;
}

- (instancetype)initWithAssetIdentifier:(NSString *)assetIdentifier
{
self = [super init];
Expand Down
10 changes: 5 additions & 5 deletions Source/Details/ASThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace ASDN {
public:
#if !TIME_LOCKER

Locker (T &l) ASDISPLAYNODE_NOTHROW : _l (l) {
Locker (T &l) noexcept : _l (l) {
Copy link
Contributor

@maicki maicki Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not pretty sure if we compile Texture with C++14 at the moment as you mention in the description, that said I think it was introduced in C++11 though. Can you double check when it was introduced and if 14 what we are building with please. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this is from c++11 but glad I double-checked.

_l.lock ();
}

Expand All @@ -174,7 +174,7 @@ namespace ASDN {

#else

Locker (T &l, const char *name = NULL) ASDISPLAYNODE_NOTHROW : _l (l), _name(name) {
Locker (T &l, const char *name = NULL) noexcept : _l (l), _name(name) {
_ti = CACurrentMediaTime();
_l.lock ();
}
Expand Down Expand Up @@ -204,7 +204,7 @@ namespace ASDN {
public:
#if !TIME_LOCKER

SharedLocker (std::shared_ptr<T> const& l) ASDISPLAYNODE_NOTHROW : _l (l) {
SharedLocker (std::shared_ptr<T> const& l) noexcept : _l (l) {
ASDisplayNodeCAssertTrue(_l != nullptr);
_l->lock ();
}
Expand All @@ -219,7 +219,7 @@ namespace ASDN {

#else

SharedLocker (std::shared_ptr<T> const& l, const char *name = NULL) ASDISPLAYNODE_NOTHROW : _l (l), _name(name) {
SharedLocker (std::shared_ptr<T> const& l, const char *name = NULL) noexcept : _l (l), _name(name) {
_ti = CACurrentMediaTime();
_l->lock ();
}
Expand All @@ -241,7 +241,7 @@ namespace ASDN {
{
T &_l;
public:
Unlocker (T &l) ASDISPLAYNODE_NOTHROW : _l (l) { _l.unlock (); }
Unlocker (T &l) noexcept : _l (l) { _l.unlock (); }
~Unlocker () {_l.lock ();}
Unlocker(Unlocker<T>&) = delete;
Unlocker &operator=(Unlocker<T>&) = delete;
Expand Down
24 changes: 12 additions & 12 deletions Source/Private/_ASCoreAnimationExtras.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,29 @@ extern void ASDisplayNodeSetResizableContents(id<ASResizableContents> obj, UIIma

NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode)
{
for (int i=0; i< ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
if (UIContentModeDescriptionLUT[i].contentMode == contentMode) {
return UIContentModeDescriptionLUT[i].string;
for (auto &e : UIContentModeDescriptionLUT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a better variable name as e in this cases ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think e is short for entry and maybe there's a better name out there but I don't really want to wait for CI to rebuild.

if (e.contentMode == contentMode) {
return e.string;
}
}
return [NSString stringWithFormat:@"%d", (int)contentMode];
}

UIViewContentMode ASDisplayNodeUIContentModeFromNSString(NSString *string)
{
for (int i=0; i < ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
if (ASObjectIsEqual(UIContentModeDescriptionLUT[i].string, string)) {
return UIContentModeDescriptionLUT[i].contentMode;
for (auto &e : UIContentModeDescriptionLUT) {
if (ASObjectIsEqual(e.string, string)) {
return e.contentMode;
}
}
return UIViewContentModeScaleToFill;
}

NSString *const ASDisplayNodeCAContentsGravityFromUIContentMode(UIViewContentMode contentMode)
{
for (int i=0; i < ARRAY_COUNT(UIContentModeCAGravityLUT); i++) {
if (UIContentModeCAGravityLUT[i].contentMode == contentMode) {
return UIContentModeCAGravityLUT[i].string;
for (auto &e : UIContentModeCAGravityLUT) {
if (e.contentMode == contentMode) {
return e.string;
}
}
ASDisplayNodeCAssert(contentMode == UIViewContentModeRedraw, @"Encountered an unknown contentMode %zd. Is this a new version of iOS?", contentMode);
Expand All @@ -140,9 +140,9 @@ UIViewContentMode ASDisplayNodeUIContentModeFromCAContentsGravity(NSString *cons
return cachedModes[foundCacheIndex];
}

for (int i = 0; i < ARRAY_COUNT(UIContentModeCAGravityLUT); i++) {
if (ASObjectIsEqual(UIContentModeCAGravityLUT[i].string, contentsGravity)) {
UIViewContentMode foundContentMode = UIContentModeCAGravityLUT[i].contentMode;
for (auto &e : UIContentModeCAGravityLUT) {
if (ASObjectIsEqual(e.string, contentsGravity)) {
UIViewContentMode foundContentMode = e.contentMode;

if (currentCacheIndex < ContentModeCacheSize) {
// Cache the input value. This is almost always a different pointer than in our LUT and will frequently
Expand Down