Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Unified Diff: class-dump/src/NSString-Extensions.m

Issue 7793008: Add the 3.3.3 sources for class-dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « class-dump/src/NSString-Extensions.h ('k') | class-dump/src/Tests/doTests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: class-dump/src/NSString-Extensions.m
===================================================================
--- class-dump/src/NSString-Extensions.m (revision 0)
+++ class-dump/src/NSString-Extensions.m (revision 0)
@@ -0,0 +1,126 @@
+// -*- mode: ObjC -*-
+
+// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
+// Copyright (C) 1997-1998, 2000-2001, 2004-2010 Steve Nygard.
+
+#import "NSString-Extensions.h"
+
+#import "NSData-CDExtensions.h"
+
+@implementation NSString (CDExtensions)
+
++ (NSString *)stringWithFileSystemRepresentation:(const char *)str;
+{
+ // 2004-01-16: I'm don't understand why we need to pass in the length.
+ return [[NSFileManager defaultManager] stringWithFileSystemRepresentation:str length:strlen(str)];
+}
+
++ (NSString *)spacesIndentedToLevel:(NSUInteger)level;
+{
+ return [self spacesIndentedToLevel:level spacesPerLevel:4];
+}
+
++ (NSString *)spacesIndentedToLevel:(NSUInteger)level spacesPerLevel:(NSUInteger)spacesPerLevel;
+{
+ NSString *spaces = @" ";
+ NSString *levelSpaces;
+ NSMutableString *str;
+ NSUInteger l;
+
+ NSParameterAssert(spacesPerLevel <= [spaces length]);
+ levelSpaces = [spaces substringToIndex:spacesPerLevel];
+
+ str = [NSMutableString string];
+ for (l = 0; l < level; l++)
+ [str appendString:levelSpaces];
+
+ return str;
+}
+
++ (NSString *)stringWithUnichar:(unichar)character;
+{
+ return [NSString stringWithCharacters:&character length:1];
+}
+
+- (BOOL)isFirstLetterUppercase;
+{
+ NSRange letterRange;
+
+ letterRange = [self rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]];
+ if (letterRange.length == 0)
+ return NO;
+
+ return [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:letterRange.location]];
+}
+
+- (void)print;
+{
+ NSData *data;
+
+ data = [self dataUsingEncoding:NSUTF8StringEncoding];
+ [(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput] writeData:data];
+}
+
+- (NSString *)executablePathForFilename;
+{
+ NSBundle *bundle;
+ NSString *path;
+
+ // I give up, all the methods dealing with paths seem to resolve symlinks with a vengence.
+ bundle = [NSBundle bundleWithPath:self];
+ if (bundle != nil) {
+ if ([bundle executablePath] == nil)
+ return nil;
+
+ path = [[[bundle executablePath] stringByResolvingSymlinksInPath] stringByStandardizingPath];
+ } else {
+ path = [[self stringByResolvingSymlinksInPath] stringByStandardizingPath];
+ }
+
+ return path;
+}
+
+- (NSString *)SHA1DigestString;
+{
+ return [[[self decomposedStringWithCanonicalMapping] dataUsingEncoding:NSUTF8StringEncoding] SHA1DigestString];
+}
+
+- (BOOL)hasUnderscoreCapitalPrefix;
+{
+ if ([self length] < 2)
+ return NO;
+
+ return [self hasPrefix:@"_"] && [[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:1]];
+}
+
+- (NSString *)capitalizeFirstCharacter;
+{
+ if ([self length] < 2)
+ return [self capitalizedString];
+
+ return [NSString stringWithFormat:@"%@%@", [[self substringToIndex:1] capitalizedString], [self substringFromIndex:1]];
+}
+
+@end
+
+@implementation NSMutableString (CDExtensions)
+
+- (void)appendSpacesIndentedToLevel:(NSUInteger)level;
+{
+ [self appendSpacesIndentedToLevel:level spacesPerLevel:4];
+}
+
+- (void)appendSpacesIndentedToLevel:(NSUInteger)level spacesPerLevel:(NSUInteger)spacesPerLevel;
+{
+ NSString *spaces = @" ";
+ NSString *levelSpaces;
+ NSUInteger l;
+
+ NSParameterAssert(spacesPerLevel <= [spaces length]);
+ levelSpaces = [spaces substringToIndex:spacesPerLevel];
+
+ for (l = 0; l < level; l++)
+ [self appendString:levelSpaces];
+}
+
+@end
Property changes on: class-dump/src/NSString-Extensions.m
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « class-dump/src/NSString-Extensions.h ('k') | class-dump/src/Tests/doTests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698