aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-08-01 20:30:07 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-08-01 20:30:07 +0000
commit24483183e727acc8daf490ea9f288ee7546991a6 (patch)
tree818092d8ed6130d03c7ca29262c47d0ce79c843c
parent0f81b5483f17785f06a8ad4c4d56de227f983f87 (diff)
General fixes for GTM.
a) only define GTM_IPHONE_USE_SENTEST if it hasn't been defined on Mac. It's a horrible name, but it does control us using SENTEST instead of XCTest. b) Object is now found in the runtime on both iOS and MacOS c) MethodCheck had a potential memory leak DELTA=47 (18 added, 5 deleted, 24 changed) DELTA_BY_EXTENSION=h=30,m=12
-rw-r--r--DebugUtils/GTMMethodCheck.m2
-rw-r--r--Foundation/GTMObjC2Runtime.m16
-rw-r--r--UnitTesting/GTMSenTestCase.h57
3 files changed, 44 insertions, 31 deletions
diff --git a/DebugUtils/GTMMethodCheck.m b/DebugUtils/GTMMethodCheck.m
index c18ada8..09cadc9 100644
--- a/DebugUtils/GTMMethodCheck.m
+++ b/DebugUtils/GTMMethodCheck.m
@@ -49,8 +49,8 @@ static BOOL ConformsToNSObjectProtocol(Class cls) {
|| (strcmp(className, "__IncompleteProtocol") == 0)
|| (strcmp(className, "__ARCLite__") == 0)
|| (strcmp(className, "WebMIMETypeRegistry") == 0)
-#if GTM_IPHONE_SDK
|| (strcmp(className, "Object") == 0)
+#if GTM_IPHONE_SDK
|| (strcmp(className, "UIKeyboardCandidateUtilities") == 0)
|| (strcmp(className, "JSExport") == 0)
#endif
diff --git a/Foundation/GTMObjC2Runtime.m b/Foundation/GTMObjC2Runtime.m
index f284542..e1af2bb 100644
--- a/Foundation/GTMObjC2Runtime.m
+++ b/Foundation/GTMObjC2Runtime.m
@@ -18,7 +18,8 @@
#import "GTMObjC2Runtime.h"
-#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
+#if GTM_MACOS_SDK && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !__OBJC2__
+#import <objc/objc-runtime.h>
#import <stdlib.h>
#import <string.h>
@@ -73,11 +74,16 @@ Method *class_copyMethodList(Class cls, unsigned int *outCount) {
while ( (mlist = class_nextMethodList(cls, &iterator)) ) {
if (mlist->method_count == 0) continue;
- methods = (Method *)realloc(methods,
- sizeof(Method) * (count + mlist->method_count + 1));
- if (!methods) {
+ Method *new_methods = (Method *)realloc(methods,
+ sizeof(Method) * (count + mlist->method_count + 1));
+ if (!new_methods) {
+ // COV_NF_START
//Memory alloc failed, so what can we do?
- return NULL; // COV_NF_LINE
+ free(methods);
+ return NULL;
+ // COV_NF_END
+ } else {
+ methods = new_methods;
}
for (int i = 0; i < mlist->method_count; i++) {
methods[i + count] = &mlist->method_list[i];
diff --git a/UnitTesting/GTMSenTestCase.h b/UnitTesting/GTMSenTestCase.h
index a5fa2ed..e3a7a33 100644
--- a/UnitTesting/GTMSenTestCase.h
+++ b/UnitTesting/GTMSenTestCase.h
@@ -53,31 +53,38 @@
#import "GTMDefines.h"
-// XCTest didn't exist before Xcode 5. Xcode 5 uses clang 5.
-#if (__clang_major__ < 5) || GTM_IPHONE_USE_SENTEST
-#import <SenTestingKit/SenTestingKit.h>
-#elif GTM_USING_XCTEST
-#import <XCTest/XCTest.h>
-#else
-#import <Foundation/Foundation.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined __clang__
-// gcc and gcc-llvm do not allow you to use STAssert(blah, nil) with nil
-// as a description if you have the NS_FORMAT_FUNCTION on.
-// clang however will not compile without warnings if you don't have it.
-NSString *STComposeString(NSString *, ...) NS_FORMAT_FUNCTION(1, 2);
-#else
-NSString *STComposeString(NSString *, ...);
-#endif // __clang__
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+#if GTM_MACOS_SDK
+ #if GTM_USING_XCTEST
+ #import <XCTest/XCTest.h>
+ #else
+ #import <SenTestingKit/SenTestingKit.h>
+ #endif // GTM_USING_XCTEST
+ // We don't support our built in testing on MacOS since its always had sentest.
+#elif GTM_IPHONE_SDK
+ #if GTM_IPHONE_USE_SENTEST
+ #import <SenTestingKit/SenTestingKit.h>
+ #elif GTM_USING_XCTEST
+ #import <XCTest/XCTest.h>
+ #else
+ #import <Foundation/Foundation.h>
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+ #if defined __clang__
+ // gcc and gcc-llvm do not allow you to use STAssert(blah, nil) with nil
+ // as a description if you have the NS_FORMAT_FUNCTION on.
+ // clang however will not compile without warnings if you don't have it.
+ NSString *STComposeString(NSString *, ...) NS_FORMAT_FUNCTION(1, 2);
+ #else
+ NSString *STComposeString(NSString *, ...);
+ #endif // __clang__
+
+ #ifdef __cplusplus
+ }
+ #endif
+ #endif // GTM_IPHONE_USE_SENTEST
+#endif // GTM_MACOS_SDK
#if GTM_USING_XCTEST