Skip to content

Commit

Permalink
Add support for ARC when writing custom matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhutchinson committed May 30, 2013
1 parent abc3d83 commit 1813cf7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ExpectaSupport.h
Original file line number Diff line number Diff line change
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) \
@interface EXPFixCategoriesBug##name; @end \
Expand Down Expand Up @@ -42,7 +51,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 1813cf7

Please sign in to comment.