Revision: 545
Author: gtm.daemon
Date: Thu Jun 21 14:30:11 2012
Log: [Author: dmaclach]
Clean up some basic issues in GTM.
Also removes GTMUniqueFileObjectPathBasedOn which depended on mktemp which
is
bad.
R=thomasvl
DELTA=55 (6 added, 32 deleted, 17 changed)
http://code.google.com/p/google-toolbox-for-mac/source/detail?r=545
Modified:
/trunk/AppKit/GTMHotKeyTextField.m
/trunk/DebugUtils/GTMDebugSelectorValidation.h
/trunk/Foundation/GTMAbstractDOListener.m
/trunk/Foundation/GTMNSAppleEventDescriptor+Foundation.m
/trunk/Foundation/GTMNSAppleScript+Handler.m
/trunk/Foundation/GTMNSAppleScript+HandlerTest.m
/trunk/Foundation/GTMNSFileHandle+UniqueName.h
/trunk/Foundation/GTMNSFileHandle+UniqueName.m
/trunk/Foundation/GTMNSFileHandle+UniqueNameTest.m
/trunk/Foundation/GTMRegex.m
=======================================
--- /trunk/AppKit/GTMHotKeyTextField.m Wed Nov 10 12:36:02 2010
+++ /trunk/AppKit/GTMHotKeyTextField.m Thu Jun 21 14:30:11 2012
@@ -492,7 +492,7 @@
uchrChars);
if (err != noErr) {
// COV_NF_START
- _GTMDevLog(@"failed to translate the keycode, err=%d", err);
+ _GTMDevLog(@"failed to translate the keycode, err=%d", (int)err);
return nil;
// COV_NF_END
}
=======================================
--- /trunk/DebugUtils/GTMDebugSelectorValidation.h Fri Jun 13 12:21:50 2008
+++ /trunk/DebugUtils/GTMDebugSelectorValidation.h Thu Jun 21 14:30:11 2012
@@ -58,10 +58,10 @@
const char *foundArgType = [sig getArgumentTypeAtIndex:argCount];
_GTMDevAssert(0 == strncmp(foundArgType, expectedArgType,
strlen(expectedArgType)),
- @"\"%@\" selector \"%@\" argument %d should be
type %s",
+ @"\"%@\" selector \"%@\" argument %u should be
type %s",
NSStringFromClass([obj class]),
NSStringFromSelector(sel),
- (argCount - 2),
+ (uint32_t)(argCount - 2),
expectedArgType);
}
argCount++;
@@ -69,10 +69,10 @@
// check that the proper number of arguments are present in the
selector
_GTMDevAssert(argCount == [sig numberOfArguments],
- @"\"%@\" selector \"%@\" should have %d arguments",
+ @"\"%@\" selector \"%@\" should have %u arguments",
NSStringFromClass([obj class]),
NSStringFromSelector(sel),
- (argCount - 2));
+ (uint32_t)(argCount - 2));
// if asked, validate the return type
if (retType && (strcmp("gtm_skip_return_test", retType) != 0)) {
=======================================
--- /trunk/Foundation/GTMAbstractDOListener.m Mon Feb 1 15:04:09 2010
+++ /trunk/Foundation/GTMAbstractDOListener.m Thu Jun 21 14:30:11 2012
@@ -255,7 +255,7 @@
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
_GTMDevAssert(!connection_, @"Connection_ should not be set. Was this "
- @"listener already started? %@");
+ @"listener already started? %@", self);
connection_ = [[NSConnection alloc] initWithReceivePort:port_
sendPort:nil];
NSProtocolChecker *checker =
=======================================
--- /trunk/Foundation/GTMNSAppleEventDescriptor+Foundation.m Thu Feb 3
08:30:29 2011
+++ /trunk/Foundation/GTMNSAppleEventDescriptor+Foundation.m Thu Jun 21
14:30:11 2012
@@ -519,7 +519,7 @@
= [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&replyEvent]
autorelease];
if (err) {
isGood = NO;
- _GTMDevLog(@"Unable to send message: %@ %d", self, err);
+ _GTMDevLog(@"Unable to send message: %@ %d", self, (int)err);
}
if (isGood) {
NSAppleEventDescriptor *errorDesc = [replyDesc
descriptorForKeyword:keyErrorNumber];
=======================================
--- /trunk/Foundation/GTMNSAppleScript+Handler.m Fri Jun 4 08:35:57 2010
+++ /trunk/Foundation/GTMNSAppleScript+Handler.m Thu Jun 21 14:30:11 2012
@@ -222,7 +222,7 @@
}
if (!wasGood) {
_GTMDevLog(@"Unable to setValue:%@ forProperty:%@ from %@ (%d)",
- value, property, self, error);
+ value, property, self, (int)error);
}
return wasGood;
}
@@ -250,7 +250,7 @@
desc = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&result]
autorelease];
} else {
- _GTMDevLog(@"Unable to coerce script %d", error);
+ _GTMDevLog(@"Unable to coerce script %d", (int)error);
}
return desc;
}
@@ -264,7 +264,7 @@
kASHasOpenHandler,
&value);
if (error) {
- _GTMDevLog(@"Unable to get script info about open handler %d", error);
+ _GTMDevLog(@"Unable to get script info about open handler %d",
(int)error);
value = 0;
}
return value != 0;
@@ -346,7 +346,7 @@
}
if (error) {
_GTMDevLog(@"Unable to get valueForProperty:%@ from %@ (%d)",
- property, self, error);
+ property, self, (int)error);
}
return desc;
}
@@ -390,7 +390,7 @@
array = [desc gtm_objectValue];
}
if (error != noErr) {
- _GTMDevLog(@"Error getting handlers: %d", error); // COV_NF_LINE
+ _GTMDevLog(@"Error getting handlers: %d", (int)error); // COV_NF_LINE
}
return [NSSet setWithArray:array];
}
@@ -409,7 +409,7 @@
array = [desc gtm_objectValue];
}
if (error != noErr) {
- _GTMDevLog(@"Error getting properties: %d", error); // COV_NF_LINE
+ _GTMDevLog(@"Error getting properties: %d", (int)error); // COV_NF_LINE
}
return [NSSet setWithArray:array];
}
@@ -420,7 +420,7 @@
OSAID exactID = osaID;
OSAError error = OSARealToGenericID(genericComponent, &exactID,
component);
if (error != noErr) {
- _GTMDevLog(@"Unable to get real id script: %@ %d", self, error); //
COV_NF_LINE
+ _GTMDevLog(@"Unable to get real id script: %@ %d", self, (int)error);
// COV_NF_LINE
exactID = kOSANullScript; // COV_NF_LINE
}
return exactID;
@@ -462,7 +462,7 @@
}
}
if (err != noErr) {
- _GTMDevLog(@"Unable to create desc for id:%d (%d)", osaID, err); //
COV_NF_LINE
+ _GTMDevLog(@"Unable to create desc for id:%d (%d)", osaID, (int)err);
// COV_NF_LINE
}
return desc;
}
@@ -480,7 +480,7 @@
ComponentInstance genericComponent = [NSAppleScript
_defaultScriptingComponent];
OSAError error = OSAGenericToRealID(genericComponent, &genericID,
component);
if (error != noErr) {
- _GTMDevLog(@"Unable to get real id script: %@ %d", self, error); //
COV_NF_LINE
+ _GTMDevLog(@"Unable to get real id script: %@ %d", self, (int)error);
// COV_NF_LINE
genericID = kOSANullScript; // COV_NF_LINE
}
return genericID;
=======================================
--- /trunk/Foundation/GTMNSAppleScript+HandlerTest.m Mon Dec 14 05:00:42
2009
+++ /trunk/Foundation/GTMNSAppleScript+HandlerTest.m Thu Jun 21 14:30:11
2012
@@ -25,6 +25,12 @@
#import "GTMSystemVersion.h"
#import "GTMFourCharCode.h"
+@protocol ScriptInterface
+- (id)test;
+- (id)testReturnParam:(id)param;
+- (id)testAddParams:(id)param1 :(id)param2;
+@end
+
@interface GTMNSAppleScript_HandlerTest : GTMTestCase {
NSAppleScript *script_;
}
@@ -501,13 +507,6 @@
STAssertNotNil(script, nil);
STAssertTrue([script gtm_hasOpenDocumentsHandler], nil);
}
-
-
-@protocol ScriptInterface
-- (id)test;
-- (id)testReturnParam:(id)param;
-- (id)testAddParams:(id)param1 :(id)param2;
-@end
- (void)testForwarding {
id<ScriptInterface> foo = (id<ScriptInterface>)script_;
=======================================
--- /trunk/Foundation/GTMNSFileHandle+UniqueName.h Mon Jul 26 10:00:52 2010
+++ /trunk/Foundation/GTMNSFileHandle+UniqueName.h Thu Jun 21 14:30:11 2012
@@ -75,7 +75,3 @@
inDirectory:(NSSearchPathDirectory)directory
domainMask:(NSSearchPathDomainMask)mask;
@end
-
-// Same template as you would pass to mktemp. Note that this has the same
-// potential race conditions for use with file creation as mktemp does.
-GTM_EXTERN NSString *GTMUniqueFileObjectPathBasedOn(NSString
*pathTemplate);
=======================================
--- /trunk/Foundation/GTMNSFileHandle+UniqueName.m Mon Jul 26 10:00:52 2010
+++ /trunk/Foundation/GTMNSFileHandle+UniqueName.m Thu Jun 21 14:30:11 2012
@@ -17,17 +17,6 @@
//
#import "GTMNSFileHandle+UniqueName.h"
-#include <unistd.h>
-
-NSString *GTMUniqueFileObjectPathBasedOn(NSString *pathTemplate) {
- if (!pathTemplate) return nil;
- char *pathTemplateCString = strdup([pathTemplate
fileSystemRepresentation]);
- if (!pathTemplateCString) return nil;
- char *newCName = mktemp(pathTemplateCString);
- NSString *newName = newCName ? [NSString
stringWithUTF8String:newCName] : nil;
- free(pathTemplateCString);
- return newName;
-}
@implementation NSFileHandle (GTMFileHandleUniqueNameAdditions)
=======================================
--- /trunk/Foundation/GTMNSFileHandle+UniqueNameTest.m Thu Jun 14 05:00:23
2012
+++ /trunk/Foundation/GTMNSFileHandle+UniqueNameTest.m Thu Jun 21 14:30:11
2012
@@ -24,16 +24,6 @@
@implementation GTMNSFileHandle_UniqueNameTest
-- (void)testGTMUniqueFileObjectPathBasedOn {
- NSString *path = GTMUniqueFileObjectPathBasedOn(nil);
- STAssertNil(path, nil);
- path = GTMUniqueFileObjectPathBasedOn(@"/System");
- STAssertNil(path, nil);
- path = GTMUniqueFileObjectPathBasedOn(@"/Users/HappyXXXXXX");
- STAssertTrue([path hasPrefix:@"/Users/Happy"], nil);
- STAssertNotEqualObjects(path, @"/Users/HappyXXXXXX", nil);
-}
-
- (void)testFileHandleWithUniqueNameBasedOnFinalPath {
NSFileHandle *handle
= [NSFileHandle gtm_fileHandleWithUniqueNameBasedOn:nil
=======================================
--- /trunk/Foundation/GTMRegex.m Wed Jun 2 10:36:03 2010
+++ /trunk/Foundation/GTMRegex.m Thu Jun 21 14:30:11 2012
@@ -719,7 +719,7 @@
[NSMutableString stringWithFormat:@"%@<%p> { isMatch=\"%s\",
subPatterns=(",
[self class], self, (isMatch_ ? "YES" : "NO")];
for (NSUInteger x = 0; x <= numRegMatches_; ++x) {
- NSInteger length = (NSInteger)(regMatches_[x].rm_eo -
regMatches_[x].rm_so);
+ int length = (int)(regMatches_[x].rm_eo - regMatches_[x].rm_so);
const char* string
= (((const char*)[utf8StrBuf_ bytes]) + regMatches_[x].rm_so);
if (x == 0) {