Skip to content

Commit

Permalink
Merge pull request #31 from nickhutchinson/support-arc-matchers
Browse files Browse the repository at this point in the history
Support writing custom matchers under ARC
  • Loading branch information
petejkim committed Jul 23, 2013
2 parents a424368 + 1813cf7 commit e4a173b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ExpectaSupport.h
Expand Up @@ -12,6 +12,15 @@ void EXP_match(EXPBoolBlock block);
void EXP_failureMessageForTo(EXPStringBlock block);
void EXP_failureMessageForNotTo(EXPStringBlock block);

#if __has_feature(objc_arc)
#define _EXP_release(x)
#define _EXP_autorelease(x) (x)

#else
#define _EXP_release(x) [x release]
#define _EXP_autorelease(x) [x autorelease]
#endif

// workaround for the categories bug: http://developer.apple.com/library/mac/#qa/qa1490/_index.html
#define EXPFixCategoriesBug(name) \
__attribute__((constructor)) static void EXPFixCategoriesBug##name() {}
Expand Down Expand Up @@ -41,7 +50,7 @@ EXPFixCategoriesBug(EXPMatcher##matcherName##Matcher); \
} \
[self applyMatcher:matcher to:&actual]; \
}; \
[matcher release]; \
return [[matcherBlock copy] autorelease]; \
_EXP_release(matcher); \
return _EXP_autorelease([matcherBlock copy]); \
} \
@end

0 comments on commit e4a173b

Please sign in to comment.