Skip to content

Commit

Permalink
Update bits of code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Feb 11, 2014
1 parent c3aed96 commit a0a8284
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Source/CDClassDumpVisitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ - (void)visitObjectiveCProcessor:(CDObjectiveCProcessor *)processor;
[self.resultString appendString:@"#pragma mark -\n\n"];
[self.resultString appendString:@"//\n"];
[self.resultString appendFormat:@"// File: %@\n", machOFile.filename];
if (machOFile.UUID) {
if (machOFile.UUID != nil) {
[self.resultString appendFormat:@"// UUID: %@\n", [machOFile.UUID UUIDString]];
}
[self.resultString appendString:@"//\n"];
Expand Down
14 changes: 7 additions & 7 deletions Source/CDClassFrameworkVisitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,28 @@ - (void)willVisitClass:(CDOCClass *)aClass;

// We only need to add superclasses for external classes - classes defined in this binary will be visited on their own
CDOCClassReference *superClassRef = [aClass superClassRef];
if ([superClassRef isExternalClass] && superClassRef.classSymbol) {
if ([superClassRef isExternalClass] && superClassRef.classSymbol != nil) {
[self addClassForExternalSymbol:superClassRef.classSymbol];
}
}

- (void)willVisitProtocol:(CDOCProtocol *)protocol
- (void)willVisitProtocol:(CDOCProtocol *)protocol;
{
// TODO: (2012-02-28) Figure out what frameworks use each protocol, and try to pick the correct one. More difficult because, for example, NSCopying is found in many frameworks, and picking the last one isn't good enough. Perhaps a topological sort of the dependancies would be better.
[self addProtocolName:protocol.name referencedInFramework:self.frameworkName];
}

- (void)willVisitCategory:(CDOCCategory *)category
- (void)willVisitCategory:(CDOCCategory *)category;
{
CDOCClassReference *classRef = [category classRef];
if ([classRef isExternalClass] && classRef.classSymbol) {
if ([classRef isExternalClass] && classRef.classSymbol != nil) {
[self addClassForExternalSymbol:classRef.classSymbol];
}
}

#pragma mark -

- (void)addClassForExternalSymbol:(CDSymbol *)symbol
- (void)addClassForExternalSymbol:(CDSymbol *)symbol;
{
NSString *frameworkName = CDImportNameForPath([[symbol dylibLoadCommand] path]);
NSString *className = [CDSymbol classNameFromSymbolName:[symbol name]];
Expand All @@ -83,7 +83,7 @@ - (void)addClassName:(NSString *)name referencedInFramework:(NSString *)framewor
_frameworkNamesByClassName[name] = frameworkName;
}

- (void)addProtocolName:(NSString *)name referencedInFramework:(NSString *)frameworkName
- (void)addProtocolName:(NSString *)name referencedInFramework:(NSString *)frameworkName;
{
if (name != nil && frameworkName != nil)
_frameworkNamesByProtocolName[name] = frameworkName;
Expand All @@ -94,7 +94,7 @@ - (NSDictionary *)frameworkNamesByClassName;
return [_frameworkNamesByClassName copy];
}

- (NSDictionary *)frameworkNamesByProtocolName
- (NSDictionary *)frameworkNamesByProtocolName;
{
return [_frameworkNamesByProtocolName copy];
}
Expand Down
2 changes: 1 addition & 1 deletion Source/CDLCSymbolTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ - (void)loadSymbols;
[symbols addObject:symbol];

NSString *className = [CDSymbol classNameFromSymbolName:symbol.name];
if (className) {
if (className != nil) {
if (symbol.value != 0)
classSymbols[className] = symbol;
else
Expand Down
4 changes: 2 additions & 2 deletions Source/CDMachOFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,13 @@ - (Class)processorClass;
return [CDObjectiveC1Processor class];
}

- (CDLCDylib *)dylibLoadCommandForLibraryOrdinal:(NSUInteger)libraryOrdinal
- (CDLCDylib *)dylibLoadCommandForLibraryOrdinal:(NSUInteger)libraryOrdinal;
{
if (libraryOrdinal == SELF_LIBRARY_ORDINAL || libraryOrdinal >= MAX_LIBRARY_ORDINAL)
return nil;

NSArray *loadCommands = _dylibLoadCommands;
if (_dylibIdentifier) {
if (_dylibIdentifier != nil) {
// Remove our own ID (LC_ID_DYLIB) so that we calculate the correct offset
NSMutableArray *remainingLoadCommands = [loadCommands mutableCopy];
[remainingLoadCommands removeObject:_dylibIdentifier];
Expand Down
6 changes: 3 additions & 3 deletions Source/CDMultiFileVisitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ - (void)typeController:(CDTypeController *)typeController didReferenceClassName:
[self addReferenceToClassName:name];
}

- (void)typeController:(CDTypeController *)typeController didReferenceProtocolNames:(NSArray *)names
- (void)typeController:(CDTypeController *)typeController didReferenceProtocolNames:(NSArray *)names;
{
[self addWeakReferencesToProtocolNamesInArray:names];
}
Expand Down Expand Up @@ -258,7 +258,7 @@ - (NSArray *)referencedProtocolNamesSortedByName;
return [[self.referencedProtocolNames allObjects] sortedArrayUsingSelector:@selector(compare:)];
}

- (NSArray *)weaklyReferencedProtocolNamesSortedByName
- (NSArray *)weaklyReferencedProtocolNamesSortedByName;
{
return [[self.weaklyReferencedProtocolNames allObjects] sortedArrayUsingSelector:@selector(compare:)];
}
Expand All @@ -279,7 +279,7 @@ - (void)addReferencesToProtocolNamesInArray:(NSArray *)protocolNames;
[self.referencedProtocolNames addObjectsFromArray:protocolNames];
}

- (void)addWeakReferencesToProtocolNamesInArray:(NSArray *)protocolNames
- (void)addWeakReferencesToProtocolNamesInArray:(NSArray *)protocolNames;
{
[self.weaklyReferencedProtocolNames addObjectsFromArray:protocolNames];
}
Expand Down
2 changes: 1 addition & 1 deletion Source/CDOCClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (NSString *)description;

#pragma mark -

- (NSString *)superClassName
- (NSString *)superClassName;
{
return [_superClassRef className];
}
Expand Down
19 changes: 11 additions & 8 deletions Source/CDOCClassReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,46 @@

@implementation CDOCClassReference

- (instancetype)initWithClassSymbol:(CDSymbol *)symbol
- (instancetype)initWithClassSymbol:(CDSymbol *)symbol;
{
if ((self = [super init])) {
_classSymbol = symbol;
}

return self;
}

- (instancetype)initWithClassObject:(CDOCClass *)classObject
- (instancetype)initWithClassObject:(CDOCClass *)classObject;
{
if ((self = [super init])) {
_classObject = classObject;
}

return self;
}

- (instancetype)initWithClassName:(NSString *)className
- (instancetype)initWithClassName:(NSString *)className;
{
if ((self = [super init])) {
_className = [className copy];
}

return self;
}

- (NSString *)className
- (NSString *)className;
{
if (_className)
if (_className != nil)
return _className;
else if (_classObject)
else if (_classObject != nil)
return [_classObject name];
else if (_classSymbol)
else if (_classSymbol != nil)
return [CDSymbol classNameFromSymbolName:[_classSymbol name]];
else
return nil;
}

- (BOOL)isExternalClass
- (BOOL)isExternalClass;
{
return (!_classObject && (!_classSymbol || [_classSymbol isExternal]));
}
Expand Down
4 changes: 2 additions & 2 deletions Source/CDObjectiveC2Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ - (CDOCCategory *)loadCategoryAtAddress:(uint64_t)address;
category.classRef = [[CDOCClassReference alloc] initWithClassObject:aClass];
}

if (externalClassName) {
if (externalClassName != nil) {
CDSymbol *classSymbol = [[self.machOFile symbolTable] symbolForExternalClassName:externalClassName];
if (classSymbol)
if (classSymbol != nil)
category.classRef = [[CDOCClassReference alloc] initWithClassSymbol:classSymbol];
else
category.classRef = [[CDOCClassReference alloc] initWithClassName:externalClassName];
Expand Down
4 changes: 2 additions & 2 deletions Source/CDSymbol.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (NSString *)description;

#pragma mark -

+ (NSString *)classNameFromSymbolName:(NSString *)symbolName
+ (NSString *)classNameFromSymbolName:(NSString *)symbolName;
{
if ([symbolName hasPrefix:ObjCClassSymbolPrefix])
return [symbolName substringFromIndex:[ObjCClassSymbolPrefix length]];
Expand All @@ -90,7 +90,7 @@ - (uint64_t)value;
return _nlist.n_value;
}

- (CDSection *)section
- (CDSection *)section;
{
// We might be tempted to do [[self.machOFile segmentContainingAddress:nlist.n_value] sectionContainingAddress:nlist.n_value]
// but this does not work for __mh_dylib_header for example (n_value == 0, but it is in the __TEXT,__text section)
Expand Down
2 changes: 1 addition & 1 deletion Source/CDType.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ - (id)initIDType:(CDTypeName *)name;
return [self initIDType:name withProtocols:nil];
}

- (id)initIDType:(CDTypeName *)name withProtocols:(NSArray *)protocols
- (id)initIDType:(CDTypeName *)name withProtocols:(NSArray *)protocols;
{
if ((self = [self init])) {
if (name != nil) {
Expand Down
2 changes: 1 addition & 1 deletion Source/CDTypeController.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (void)typeFormatter:(CDTypeFormatter *)typeFormatter didReferenceClassName:(NS
[self.delegate typeController:self didReferenceClassName:name];
}

- (void)typeFormatter:(CDTypeFormatter *)typeFormatter didReferenceProtocolNames:(NSArray *)names
- (void)typeFormatter:(CDTypeFormatter *)typeFormatter didReferenceProtocolNames:(NSArray *)names;
{
if ([self.delegate respondsToSelector:@selector(typeController:didReferenceProtocolNames:)])
[self.delegate typeController:self didReferenceProtocolNames:names];
Expand Down
2 changes: 1 addition & 1 deletion Source/CDTypeFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ - (void)formattingDidReferenceClassName:(NSString *)name;
[self.typeController typeFormatter:self didReferenceClassName:name];
}

- (void)formattingDidReferenceProtocolNames:(NSArray *)names
- (void)formattingDidReferenceProtocolNames:(NSArray *)names;
{
[self.typeController typeFormatter:self didReferenceProtocolNames:names];
}
Expand Down

0 comments on commit a0a8284

Please sign in to comment.