diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index 8d6d23b6..cc827781 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -33,27 +33,29 @@ void arcSafeRelease( NSObject* obj ); id performOptionalSelector( id obj, SEL sel ); #if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) -{ - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) -{ - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; -} + inline void arcSafeRelease( NSObject* obj ) + { + [obj release]; + } + 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" - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; -#pragma clang diagnostic pop - return nil; -} + 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 + 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++ ) diff --git a/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj b/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj index 2c30f383..3e5f8aee 100644 --- a/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/OCTest/OCTest.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 4A63D2C314E454CC00F615CB /* OCTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCTest.mm; sourceTree = ""; }; 4A63D2C414E454CC00F615CB /* TestObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObj.h; sourceTree = ""; }; 4A63D2C514E454CC00F615CB /* TestObj.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObj.m; sourceTree = ""; }; + 4AA0D951154C0A7A004B4193 /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_objc.hpp; path = ../../../include/internal/catch_objc.hpp; sourceTree = ""; }; /* 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 = ""; }; + 4AA0D94F154C0A63004B4193 /* Catch */ = { + isa = PBXGroup; + children = ( + 4AA0D951154C0A7A004B4193 /* catch_objc.hpp */, + ); + name = Catch; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ diff --git a/projects/XCode4/OCTest/OCTest/TestObj.h b/projects/XCode4/OCTest/OCTest/TestObj.h index 26e59286..388e9a8d 100644 --- a/projects/XCode4/OCTest/OCTest/TestObj.h +++ b/projects/XCode4/OCTest/OCTest/TestObj.h @@ -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 +#import @interface TestObj : NSObject { diff --git a/single_include/catch.hpp b/single_include/catch.hpp index e51e1897..add422ff 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -3063,27 +3063,29 @@ void arcSafeRelease( NSObject* obj ); id performOptionalSelector( id obj, SEL sel ); #if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) -{ - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) -{ - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; -} + inline void arcSafeRelease( NSObject* obj ) + { + [obj release]; + } + 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" - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; -#pragma clang diagnostic pop - return nil; -} + 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 + 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++ )