mirror of https://github.com/catchorg/Catch2.git
Conditionally compile __unsafe_unretained
Addresses, and hopefully fixes, issue #77.
This commit is contained in:
parent
8fdf7f3a09
commit
861a1e79cf
|
@ -33,27 +33,29 @@ void arcSafeRelease( NSObject* obj );
|
|||
id performOptionalSelector( id obj, SEL sel );
|
||||
|
||||
#if !CATCH_ARC_ENABLED
|
||||
inline void arcSafeRelease( NSObject* obj )
|
||||
{
|
||||
inline void arcSafeRelease( NSObject* obj )
|
||||
{
|
||||
[obj release];
|
||||
}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
if( [obj respondsToSelector: sel] )
|
||||
return [obj performSelector: sel];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#define CATCH_UNSAFE_UNRETAINED
|
||||
#else
|
||||
inline void arcSafeRelease( NSObject* ){}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
inline void arcSafeRelease( NSObject* ){}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
if( [obj respondsToSelector: sel] )
|
||||
return [obj performSelector: sel];
|
||||
#pragma clang diagnostic pop
|
||||
#pragma clang diagnostic pop
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -171,7 +173,7 @@ namespace Catch
|
|||
size_t noTestMethods = 0;
|
||||
int noClasses = objc_getClassList( NULL, 0 );
|
||||
|
||||
Class* classes = (__unsafe_unretained Class *)malloc( sizeof(Class) * noClasses);
|
||||
Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
|
||||
objc_getClassList( classes, noClasses );
|
||||
|
||||
for( int c = 0; c < noClasses; c++ )
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
4A63D2C314E454CC00F615CB /* OCTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCTest.mm; sourceTree = "<group>"; };
|
||||
4A63D2C414E454CC00F615CB /* TestObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObj.h; sourceTree = "<group>"; };
|
||||
4A63D2C514E454CC00F615CB /* TestObj.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObj.m; sourceTree = "<group>"; };
|
||||
4AA0D951154C0A7A004B4193 /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_objc.hpp; path = ../../../include/internal/catch_objc.hpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -55,6 +56,7 @@
|
|||
4A63D29A14E3C1A900F615CB = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4AA0D94F154C0A63004B4193 /* Catch */,
|
||||
4A63D2BF14E4544700F615CB /* Foundation.framework */,
|
||||
4A63D2A814E3C1A900F615CB /* OCTest */,
|
||||
4A63D2A614E3C1A900F615CB /* Products */,
|
||||
|
@ -83,6 +85,14 @@
|
|||
path = OCTest;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4AA0D94F154C0A63004B4193 /* Catch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4AA0D951154C0A7A004B4193 /* catch_objc.hpp */,
|
||||
);
|
||||
name = Catch;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
@interface TestObj : NSObject {
|
||||
|
|
|
@ -3063,27 +3063,29 @@ void arcSafeRelease( NSObject* obj );
|
|||
id performOptionalSelector( id obj, SEL sel );
|
||||
|
||||
#if !CATCH_ARC_ENABLED
|
||||
inline void arcSafeRelease( NSObject* obj )
|
||||
{
|
||||
inline void arcSafeRelease( NSObject* obj )
|
||||
{
|
||||
[obj release];
|
||||
}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
if( [obj respondsToSelector: sel] )
|
||||
return [obj performSelector: sel];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#define CATCH_UNSAFE_UNRETAINED
|
||||
#else
|
||||
inline void arcSafeRelease( NSObject* ){}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
inline void arcSafeRelease( NSObject* ){}
|
||||
inline id performOptionalSelector( id obj, SEL sel )
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
if( [obj respondsToSelector: sel] )
|
||||
return [obj performSelector: sel];
|
||||
#pragma clang diagnostic pop
|
||||
#pragma clang diagnostic pop
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3201,7 +3203,7 @@ namespace Catch
|
|||
size_t noTestMethods = 0;
|
||||
int noClasses = objc_getClassList( NULL, 0 );
|
||||
|
||||
Class* classes = (__unsafe_unretained Class *)malloc( sizeof(Class) * noClasses);
|
||||
Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);
|
||||
objc_getClassList( classes, noClasses );
|
||||
|
||||
for( int c = 0; c < noClasses; c++ )
|
||||
|
|
Loading…
Reference in New Issue