Browse files

Fixed a bunch of string formatting errors (thanks to clang 3.1 pointi…

…ng them out)
  • Loading branch information...
1 parent bb04611 commit 4916b194c47530ab5534502b03f7bbcdf68917be @ccgus committed May 14, 2012
View
34 jscocoa/JSCocoa/JSCocoaController.m
@@ -1411,7 +1411,7 @@ + (BOOL)addMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRe
SEL selector = NSSelectorFromString(methodName);
id keyForClassAndMethod = [NSString stringWithFormat:@"%@ %@", class, methodName];
- id keyForFunction = [NSString stringWithFormat:@"%x", valueAndContext.value];
+ id keyForFunction = [NSString stringWithFormat:@"%x", (unsigned int)valueAndContext.value];
id existingMethodForJSFunction = [closureHash valueForKey:keyForFunction];
if (existingMethodForJSFunction)
@@ -1433,7 +1433,7 @@ + (BOOL)addMethod:(NSString*)methodName class:(Class)class jsFunction:(JSValueRe
// Closure cleanup - dangerous as instances might still be around AND IF dealloc/release is overloaded
if (existingPrivateObject)
{
- id keyForExistingFunction = [NSString stringWithFormat:@"%x", [existingPrivateObject jsValueRef]];
+ id keyForExistingFunction = [NSString stringWithFormat:@"%x", (unsigned int)[existingPrivateObject jsValueRef]];
[closureHash removeObjectForKey:keyForExistingFunction];
[jsFunctionSelectors removeObjectForKey:keyForExistingFunction];
@@ -1754,7 +1754,7 @@ - (BOOL)isFunctionVariadic:(id)functionName
+ (JSObjectRef)boxedJSObject:(id)o inContext:(JSContextRef)ctx
{
- id key = [NSString stringWithFormat:@"%x", o];
+ id key = [NSString stringWithFormat:@"%x", (unsigned int)o];
id value = [boxedObjects valueForKey:key];
// If object is boxed, up its usage count and return it
if (value)
@@ -1796,7 +1796,7 @@ + (JSObjectRef)boxedJSObject:(id)o inContext:(JSContextRef)ctx
+ (void)downBoxedJSObjectCount:(id)o
{
- id key = [NSString stringWithFormat:@"%x", o];
+ id key = [NSString stringWithFormat:@"%x", (unsigned int)o];
id value = [boxedObjects valueForKey:key];
if (!value)
return;
@@ -1812,12 +1812,12 @@ + (id)boxedObjects
#pragma mark Helpers
- (id)selectorForJSFunction:(JSObjectRef)function
{
- return [jsFunctionSelectors valueForKey:[NSString stringWithFormat:@"%x", function]];
+ return [jsFunctionSelectors valueForKey:[NSString stringWithFormat:@"%x", (unsigned int)function]];
}
- (id)classForJSFunction:(JSObjectRef)function
{
- return [jsFunctionClasses valueForKey:[NSString stringWithFormat:@"%x", function]];
+ return [jsFunctionClasses valueForKey:[NSString stringWithFormat:@"%x", (unsigned int)function]];
}
//
@@ -1949,7 +1949,7 @@ - (int)runTests:(NSString*)path withSelector:(SEL)sel
}
if (!evaled)
{
- id error = [NSString stringWithFormat:@"test %@ failed (Ran %d out of %d tests)", file, count+1, [files count]];
+ id error = [NSString stringWithFormat:@"test %@ failed (Ran %d out of %ld tests)", file, count+1, (long)[files count]];
[JSCocoaController logAndSay:error];
return NO;
}
@@ -2003,7 +2003,7 @@ - (void)safeDeallocInstance:(id)sender
// This code might re-box the instance ...
[sender safeDealloc];
// So, clean it up
- [boxedObjects removeObjectForKey:[NSString stringWithFormat:@"%x", sender]];
+ [boxedObjects removeObjectForKey:[NSString stringWithFormat:@"%x", (unsigned int)sender]];
// sender is retained by performSelector, object will be destroyed upon function exit
}
@@ -3167,7 +3167,7 @@ static void jsCocoaObject_finalize(JSObjectRef object)
id boxedObject = [private object];
if (boxedObject)
{
- id key = [NSString stringWithFormat:@"%x", boxedObject];
+ id key = [NSString stringWithFormat:@"%x", (unsigned int)boxedObject];
// Object may have been already deallocated
id existingBoxedObject = [boxedObjects objectForKey:key];
if (existingBoxedObject)
@@ -3370,7 +3370,7 @@ static JSValueRef jsCocoaObject_getProperty(JSContextRef ctx, JSObjectRef object
// Make sure to not return hash value if it's native code (valueOf, toString)
if ([propertyName isEqualToString:@"valueOf"] || [propertyName isEqualToString:@"toString"])
{
- id script = [NSString stringWithFormat:@"return arguments[0].toString().indexOf('[native code]') != -1", propertyName];
+ id script = [NSString stringWithFormat:@"return arguments[0].toString().indexOf('[native code]') != -1"/*, propertyName*/];
JSStringRef scriptJS = JSStringCreateWithUTF8CString([script UTF8String]);
JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
JSValueRef result = JSObjectCallAsFunction(ctx, fn, NULL, 1, (JSValueRef*)&hashProperty, NULL);
@@ -4300,7 +4300,7 @@ static JSValueRef jsCocoaObject_callAsFunction_ffi(JSContextRef ctx, JSObjectRef
// Bail if not variadic
if (!isVariadic)
{
- return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %d, got %d", functionName ? functionName : methodName, callAddressArgumentCount, argumentCount]), NULL;
+ return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %ld, got %ld", functionName ? functionName : methodName, (long)callAddressArgumentCount, (long)argumentCount]), NULL;
}
// Sugar check : if last object is not NULL, account for it
if (isVariadic && callingObjC && argumentCount && !JSValueIsNull(ctx, arguments[argumentCount-1]))
@@ -4314,7 +4314,7 @@ static JSValueRef jsCocoaObject_callAsFunction_ffi(JSContextRef ctx, JSObjectRef
{
if (callAddressArgumentCount != argumentCount)
{
- return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %d, got %d", functionName ? functionName : methodName, callAddressArgumentCount, argumentCount]), NULL;
+ return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count in %@ : expected %ld, got %zd", functionName ? functionName : methodName, callAddressArgumentCount, argumentCount]), NULL;
}
}
@@ -4722,7 +4722,7 @@ static JSObjectRef jsCocoaObject_callAsConstructor(JSContextRef ctx, JSObjectRef
{
if (convertedValueCount != argumentCount)
{
- return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count when calling constructor on a struct : expected %d, got %d", convertedValueCount, argumentCount]), NULL;
+ return throwException(ctx, exception, [NSString stringWithFormat:@"Bad argument count when calling constructor on a struct : expected %ld, got %zd", convertedValueCount, argumentCount]), NULL;
}
}
@@ -4940,16 +4940,16 @@ - (JSObjectRef)jsObject
- (id)description
{
id boxedObject = [(JSCocoaPrivateObject*)JSObjectGetPrivate(jsObject) object];
- id retainCount = [NSString stringWithFormat:@"%d", [boxedObject retainCount]];
+ id retainCount = [NSString stringWithFormat:@"%ld", [boxedObject retainCount]];
#if !TARGET_OS_IPHONE
- retainCount = [NSGarbageCollector defaultCollector] ? @"Running GC" : [NSString stringWithFormat:@"%d", [boxedObject retainCount]];
+ retainCount = [NSGarbageCollector defaultCollector] ? @"Running GC" : [NSString stringWithFormat:@"%ld", [boxedObject retainCount]];
#endif
return [NSString stringWithFormat:@"<%@: %x holding %@ %@: %x (retainCount=%@)>",
[self class],
- self,
+ (unsigned int)self,
((id)self == (id)[self class]) ? @"Class" : @"",
[boxedObject class],
- boxedObject,
+ (unsigned int)boxedObject,
retainCount];
}
View
4 jscocoa/JSCocoa/JSCocoaFFIArgument.m
@@ -64,10 +64,10 @@ - (void)finalize
- (NSString*)description
{
- return [NSString stringWithFormat:@"JSCocoaFFIArgument %x typeEncoding=%c %@ isReturnValue=%d storage=%x", self,
+ return [NSString stringWithFormat:@"JSCocoaFFIArgument %x typeEncoding=%c %@ isReturnValue=%d storage=%x", (unsigned int)self,
typeEncoding,
(structureTypeEncoding ? structureTypeEncoding : @""),
- isReturnValue, ptr];
+ isReturnValue, (unsigned int)ptr];
}
+ (NSString*)typeDescriptionForTypeEncoding:(char)typeEncoding fullTypeEncoding:(NSString*)fullTypeEncoding
View
4 jscocoa/JSCocoa/JSCocoaPrivateObject.m
@@ -204,10 +204,10 @@ - (id)rawPointerEncoding
- (id)description
{
id extra = @"";
- if ([type isEqualToString:@"rawPointer"]) extra = [NSString stringWithFormat:@" (%x) %@", rawPointer, declaredType];
+ if ([type isEqualToString:@"rawPointer"]) extra = [NSString stringWithFormat:@" (%x) %@", (unsigned int)rawPointer, declaredType];
return [NSString stringWithFormat:@"<%@: %x holding %@%@>",
[self class],
- self,
+ (unsigned int)self,
type,
extra
];
View
1 plugins/voodoopadplugin/VPJSTalkPlugin.xcodeproj/project.pbxproj
@@ -256,7 +256,6 @@
"\"$(SRCROOT)\"",
/tmp/jstalk/build/Release,
);
- GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
View
2 src/JSTAppDelegate.m
@@ -135,7 +135,7 @@ - (void)loadExternalEditorPrefs {
- (void)openPanelDidEndForExternalEditor:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
if (returnCode) {
- NSString *path = [sheet filename];
+ NSString *path = [[sheet URL] path];
NSBundle *appBundle = [NSBundle bundleWithPath:path];
NSString *bundleId = [appBundle bundleIdentifier];
View
2 src/JSTDocument.m
@@ -257,7 +257,7 @@ - (void)preprocessCodeAction:(id)sender {
- (void)savePanelDidEndForApplicationSave:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo {
- NSString *fileName = [sheet filename];
+ NSString *fileName = [[sheet URL] path];
if (!fileName) {
return;
}
View
2 src/JSTPreprocessor.m
@@ -316,7 +316,7 @@ - (NSString*)description {
NSMutableString *ret = [NSMutableString stringWithString:@"jsobjc_msgSend"];
if ([methodArgs count]) {
- [ret appendFormat:@"%d", [methodArgs count]];
+ [ret appendFormat:@"%d", (int)[methodArgs count]];
}
[ret appendFormat:@"(%@, \"%@\"", target, selector];
View
2 src/NoodleLineNumberView.m
@@ -451,7 +451,7 @@ - (void)drawHashMarksAndLabelsInRect:(NSRect)aRect
}
// Line numbers are internally stored starting at 0
- labelText = [NSString stringWithFormat:@"%d", line + 1];
+ labelText = [NSString stringWithFormat:@"%ld", (long)(line + 1)];
stringSize = [labelText sizeWithAttributes:textAttributes];
View
16 src/todparsekit/TDAssembly.m
@@ -70,49 +70,49 @@ - (id)copyWithZone:(NSZone *)zone {
- (id)next {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return nil;
}
- (BOOL)hasMore {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return NO;
}
- (NSString *)consumedObjectsJoinedByString:(NSString *)delimiter {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return nil;
}
- (NSString *)remainingObjectsJoinedByString:(NSString *)delimiter {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return nil;
}
- (NSUInteger)length {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return 0;
}
- (NSUInteger)objectsConsumed {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return 0;
}
- (NSUInteger)objectsRemaining {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return 0;
}
- (id)peek {
- NSAssert1(0, @"-[TDAssembly %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDAssembly %@] must be overriden", NSStringFromSelector(_cmd));
return nil;
}
View
2 src/todparsekit/TDCharacterAssembly.m
@@ -99,7 +99,7 @@ - (NSString *)description {
for (id obj in self.stack) {
if ([obj isKindOfClass:[NSNumber class]]) { // ***this is needed for Char Assemblies
- [s appendFormat:@"%C", [obj integerValue]];
+ [s appendFormat:@"%C", [obj unsignedShortValue]];
} else {
[s appendString:[obj description]];
}
View
2 src/todparsekit/TDCommentState.m
@@ -102,7 +102,7 @@ - (TDToken *)nextTokenFromReader:(TDReader *)r startingWith:(NSInteger)cin token
for ( ; i < symbol.length - 1; i++) {
[r unread];
}
- return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[NSString stringWithFormat:@"%C", cin] floatValue:0.0];
+ return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[NSString stringWithFormat:@"%C", (unsigned short)cin] floatValue:0.0];
}
}
View
4 src/todparsekit/TDParser.m
@@ -44,7 +44,7 @@ - (void)setAssembler:(id)a selector:(SEL)sel {
- (NSSet *)allMatchesFor:(NSSet *)inAssemblies {
- NSAssert1(0, @"-[TDParser %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDParser %@] must be overriden", NSStringFromSelector(_cmd));
return nil;
}
@@ -71,7 +71,7 @@ - (NSSet *)matchAndAssemble:(NSSet *)inAssemblies {
NSParameterAssert(inAssemblies);
NSSet *outAssemblies = [self allMatchesFor:inAssemblies];
if (assembler) {
- NSAssert2([assembler respondsToSelector:selector], @"provided assembler %@ should respond to %s", assembler, selector);
+ NSAssert2([assembler respondsToSelector:selector], @"provided assembler %@ should respond to %@", assembler, NSStringFromSelector(selector));
for (TDAssembly *a in outAssemblies) {
[assembler performSelector:selector withObject:a];
}
View
2 src/todparsekit/TDRepetition.m
@@ -56,7 +56,7 @@ - (void)setPreassembler:(id)a selector:(SEL)sel {
- (NSSet *)allMatchesFor:(NSSet *)inAssemblies {
NSParameterAssert(inAssemblies);
if (preassembler) {
- NSAssert2([preassembler respondsToSelector:preassemblerSelector], @"provided preassembler %@ should respond to %s", preassembler, preassemblerSelector);
+ NSAssert2([preassembler respondsToSelector:preassemblerSelector], @"provided preassembler %@ should respond to %@", preassembler, NSStringFromSelector(preassemblerSelector));
for (TDAssembly *a in inAssemblies) {
[preassembler performSelector:preassemblerSelector withObject:a];
}
View
2 src/todparsekit/TDSpecificChar.m
@@ -16,7 +16,7 @@ + (id)specificCharWithChar:(NSInteger)c {
- (id)initWithSpecificChar:(NSInteger)c {
- self = [super initWithString:[NSString stringWithFormat:@"%C", c]];
+ self = [super initWithString:[NSString stringWithFormat:@"%C", (unsigned short)c]];
if (self) {
}
return self;
View
2 src/todparsekit/TDSymbolNode.m
@@ -30,7 +30,7 @@ - (id)initWithParent:(TDSymbolNode *)p character:(NSInteger)c {
// this private property is an optimization.
// cache the NSString for the char to prevent it being constantly recreated in -determinAncestry
- self.string = [NSString stringWithFormat:@"%C", character];
+ self.string = [NSString stringWithFormat:@"%C", (unsigned short)character];
[self determineAncestry];
}
View
2 src/todparsekit/TDSymbolRootNode.m
@@ -95,7 +95,7 @@ - (NSString *)nextSymbol:(TDReader *)r startingWith:(NSInteger)cin {
- (NSString *)nextWithFirst:(NSInteger)c rest:(TDReader *)r parent:(TDSymbolNode *)p {
NSParameterAssert(p);
- NSString *result = [NSString stringWithFormat:@"%C", c];
+ NSString *result = [NSString stringWithFormat:@"%C", (unsigned short)c];
// this also works.
// NSString *result = [[[NSString alloc] initWithCharacters:(const unichar *)&c length:1] autorelease];
View
2 src/todparsekit/TDSymbolState.m
@@ -48,7 +48,7 @@ - (TDToken *)nextTokenFromReader:(TDReader *)r startingWith:(NSInteger)cin token
for ( ; i < len - 1; i++) {
[r unread];
}
- return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[NSString stringWithFormat:@"%C", cin] floatValue:0.0];
+ return [TDToken tokenWithTokenType:TDTokenTypeSymbol stringValue:[NSString stringWithFormat:@"%C", (unsigned short)cin] floatValue:0.0];
}
}
View
2 src/todparsekit/TDTerminal.m
@@ -75,7 +75,7 @@ - (TDAssembly *)matchOneAssembly:(TDAssembly *)inAssembly {
- (BOOL)qualifies:(id)obj {
- NSAssert1(0, @"-[TDTerminal %s] must be overriden", _cmd);
+ NSAssert1(0, @"-[TDTerminal %@] must be overriden", NSStringFromSelector(_cmd));
return NO;
}
View
2 src/todparsekit/TDToken.m
@@ -202,7 +202,7 @@ - (NSString *)debugDescription {
} else if (self.isComment) {
typeString = @"Comment";
}
- return [NSString stringWithFormat:@"<%@ %C%@%C>", typeString, 0x00AB, self.value, 0x00BB];
+ return [NSString stringWithFormat:@"<%@ %C%@%C>", typeString, (unsigned short)0x00AB, self.value, (unsigned short)0x00BB];
}
View
2 src/todparsekit/TDTokenizerState.m
@@ -60,7 +60,7 @@ - (void)reset {
- (void)append:(NSInteger)c {
#if TD_USE_MUTABLE_STRING_BUF
- [stringbuf appendFormat:@"%C", c];
+ [stringbuf appendFormat:@"%C", (unsigned short)c];
#else
[self checkBufLength];
charbuf[index++] = c;

0 comments on commit 4916b19

Please sign in to comment.