Skip to content

Commit

Permalink
Clean up white space
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Sep 26, 2024
1 parent 79aa7a3 commit fa8ddfa
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 44 deletions.
47 changes: 23 additions & 24 deletions Tools/pc2xc/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
{
filename = [filename stringByAppendingPathExtension: ext];
}

PBXFileReference *fileRef = AUTORELEASE([[PBXFileReference alloc] initWithPath: filename]);
[result addObject: fileRef];
[result addObject: fileRef];
}

return result;
Expand Down Expand Up @@ -66,10 +66,10 @@
[projectName stringByAppendingPathExtension: ext];
PBXFileReference *productFileRef = AUTORELEASE([[PBXFileReference alloc] initWithPath: path]);
NSMutableArray *children = [NSMutableArray arrayWithObject: productFileRef];

[group setChildren: children];
[group setName: @"Products"];

return group;
}

Expand All @@ -79,7 +79,7 @@
NSMutableArray *buildGroupFiles = buildFileReferences(files, nil);
PBXGroup *buildFileGroup = AUTORELEASE([[PBXGroup alloc] init]);
[buildFileGroup setChildren: buildGroupFiles];

NSMutableArray *mainGroupChildren = [NSMutableArray arrayWithObjects: buildFileGroup,
productReferenceGroup, nil];
[mainGroup setChildren: mainGroupChildren];
Expand All @@ -89,10 +89,10 @@

void buildPhase(NSArray *items, PBXBuildPhase *phase)
{
NSMutableArray *sources = [NSMutableArray arrayWithCapacity: [items count]];
NSMutableArray *sources = [NSMutableArray arrayWithCapacity: [items count]];
NSEnumerator *en = [items objectEnumerator];
NSString *item = nil;

while ((item = [en nextObject]) != nil)
{
PBXFileReference *fileRef = AUTORELEASE([[PBXFileReference alloc] initWithPath: item]);
Expand Down Expand Up @@ -122,7 +122,7 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
buildPhase(resources, resourcePhase);

// PBXFrameworksBuildPhase *frameworksPhase = AUTORELEASE([[PBXFrameworksBuildPhase alloc] init]);
// buildPhase(frameworks, frameworksPhase);
// buildPhase(frameworks, frameworksPhase);

PBXFileReference *productRef = [[prodRefGroup children] objectAtIndex: 0];
NSMutableArray *phases = [NSMutableArray arrayWithObjects: sourcePhase, resourcePhase, nil]; // frameworksPhase, nil];
Expand All @@ -131,9 +131,9 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
[target setName: projectName];
[target setProductName: [productRef path]];
[target setProductType: projectType];

[result addObject: target];

return result;
}

Expand All @@ -154,7 +154,7 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
NSMutableArray *configArray = [NSMutableArray arrayWithObjects: buildConfigDebug, buildConfigRelease, nil];
XCConfigurationList *configList = AUTORELEASE([[XCConfigurationList alloc] initWithConfigurations: configArray]);
NSString *type = typeForProjectType(projectType);

// Add all files to the main group...
[allFiles addObjectsFromArray: other];
[allFiles addObjectsFromArray: resources];
Expand All @@ -163,13 +163,13 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
PBXGroup *productRefGroup = productReferenceGroup(projectName, projectType); // AUTORELEASE([[PBXGroup alloc] init]);
PBXGroup *mainGroup = mainGroupBuild(allFiles, productRefGroup); // AUTORELEASE([[PBXGroup alloc] init]);
NSMutableArray *targets = buildTargets(projectName, type, allFiles, headers, resources, frameworks, productRefGroup);

[project setMainGroup: mainGroup];
[project setProductRefGroup: productRefGroup];
[project setBuildConfigurationList: configList];
// [project setContainer: container];
[project setTargets: targets];

return container;
}

Expand All @@ -188,7 +188,7 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
NSMutableArray *allResources = [NSMutableArray arrayWithArray: resources];

[allResources addObjectsFromArray: images];

return buildContainer(projectName, projectType, files, headers, allResources, other, frameworks);
}

Expand All @@ -205,13 +205,13 @@ void buildPhase(NSArray *items, PBXBuildPhase *phase)
NSMutableArray *allResources = [NSMutableArray arrayWithArray: resources];

[allResources addObjectsFromArray: images];

return buildContainer(projectName, projectType, files, headers, allResources, other, frameworks);
}

PBXContainer *convertGNUmakfile(NSString *inputString)
{

return nil;
}

Expand All @@ -226,20 +226,20 @@ BOOL buildXCodeProj(PBXContainer *container, NSString *dn)
attributes: NULL
error: &error];
BOOL result = NO;

if (created)
{
xcprintf("=== Saving Project %s%s%s%s -> %s%s%s\n",
BOLD, YELLOW, [fn cString], RESET, GREEN,
[dn cString], RESET);

// [container save]; // Setup to save...

// Save the project...
if (created && !error)
{
id dictionary = [PBXCoder archiveWithRootObject: container];

result = [dictionary writeToFile: fn atomically: YES];
if (result)
{
Expand All @@ -253,7 +253,7 @@ BOOL buildXCodeProj(PBXContainer *container, NSString *dn)
}
}
}

return result;
}

Expand All @@ -267,7 +267,7 @@ int main(int argc, const char *argv[])
NSString *output = [NSString stringWithUTF8String: argv[2]];
PBXContainer *container = nil;
NSDictionary *proj = nil;

if ([[input lastPathComponent] isEqualToString: @"PB.project"])
{
proj = [NSDictionary dictionaryWithContentsOfFile: input];
Expand All @@ -279,7 +279,7 @@ int main(int argc, const char *argv[])
{
NSString *path = [input stringByAppendingPathComponent: @"PC.project"];

proj = [NSDictionary dictionaryWithContentsOfFile: path];
proj = [NSDictionary dictionaryWithContentsOfFile: path];
xcprintf("== Parsing a ProjectCenter project: %s -> %s\n",
[input UTF8String], [output UTF8String]);
container = convertPCProject(proj);
Expand Down Expand Up @@ -315,9 +315,8 @@ int main(int argc, const char *argv[])
{
xcprintf("== Not enough arguments");
}

[pool release];

return 0;
}

37 changes: 17 additions & 20 deletions XCode/NSObject+KeyExtraction.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ id moveContainerProperties(NSDictionary *input)
id key = nil;
id keyToChange = nil;

// NSLog(@"result = %@", result);
// Find the specific key/guid to change...
while ((key = [en nextObject]) != nil)
{
id d = [objects objectForKey: key];

if ([d isKindOfClass: [NSDictionary class]])
{
NSString *cn = [d objectForKey: @"isa"];
Expand All @@ -111,14 +111,12 @@ id moveContainerProperties(NSDictionary *input)
[containerDict removeObjectForKey: @"rootObject"];
[containerDict removeObjectForKey: @"isa"];
[containerDict removeObjectForKey: @"objects"];

[objects removeObjectForKey: keyToChange];
[result addEntriesFromDictionary: containerDict];
[result setObject: objects forKey: @"objects"];
}

// NSLog(@"result = %@", result);

return result;
}

Expand All @@ -127,7 +125,7 @@ id moveContainerProperties(NSDictionary *input)
NSString *guid = nil;
NSEnumerator *en = [objects keyEnumerator];
NSString *g = nil;

while ((g = [en nextObject]) != nil)
{
NSDictionary *d = [objects objectForKey: g];
Expand All @@ -148,24 +146,24 @@ id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString *
if ([propertyList isKindOfClass:[NSDictionary class]])
{
NSDictionary *dict = (NSDictionary *)propertyList;

// Check if the dictionary has an "isa" element
if ([dict objectForKey:@"isa"])
{
// Generate a GUID for this dictionary
NSString *guid = generateGUID();

// If the "isa" is "PBXProject", set the rootObjectGUID
if ([[dict objectForKey:@"isa"] isEqualToString:@"PBXProject"])
{
*rootObjectGUID = guid;
}

// Add the dictionary to the objects array with its GUID
NSMutableDictionary *flattenedDict = [NSMutableDictionary dictionary];
NSEnumerator *en = [dict keyEnumerator];
id key = nil;

while ((key = [en nextObject]) != nil)
{
[flattenedDict setObject: flattenPropertyList([dict objectForKey:key], objects, rootObjectGUID)
Expand All @@ -181,7 +179,7 @@ id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString *
{
[objects setObject:flattenedDict forKey:guid];
}

// Return the GUID to replace the dictionary
return guid;
}
Expand All @@ -206,7 +204,7 @@ id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString *
NSMutableArray *processedArray = [NSMutableArray array];
NSEnumerator *en = [propertyList objectEnumerator];
id item = nil;

while((item = [en nextObject]) != nil)
{
[processedArray addObject:flattenPropertyList(item, objects, rootObjectGUID)];
Expand All @@ -226,7 +224,7 @@ id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString *
NSMutableDictionary *objects = [NSMutableDictionary dictionary];
NSString *rootObjectGUID = nil;
NSMutableDictionary *results = [NSMutableDictionary dictionary];

// Flatten the property list and find the rootObjectGUID
flattenPropertyList(propertyList, objects, &rootObjectGUID);

Expand All @@ -235,7 +233,7 @@ id flattenPropertyList(id propertyList, NSMutableDictionary *objects, NSString *
forKey: @"rootObject"];
[results setObject: objects
forKey: @"objects"];

// Return the final structure
return results;
}
Expand All @@ -249,19 +247,19 @@ + (void) getAllMethodsForClass: (Class)cls
{
return;
}

unsigned int methodCount = 0;
Method *methods = class_copyMethodList(cls, &methodCount);
unsigned int i = 0;

for (i = 0; i < methodCount; i++)
{
Method method = methods[i];
[methodsArray addObject:NSStringFromSelector(method_getName(method))];
}

free(methods); // Don't forget to free the list

// Recursively call this method for the superclass
[self getAllMethodsForClass:class_getSuperclass(cls) intoArray:methodsArray];
}
Expand All @@ -287,7 +285,7 @@ - (NSArray *) keysForObject: (id)object
NSEnumerator *en = [methods objectEnumerator];
NSString *selectorName = nil;
NSMutableArray *result = [NSMutableArray arrayWithCapacity: [methods count]];

while ((selectorName = [en nextObject]) != nil)
{
if ([selectorName hasPrefix: @"set"] && [selectorName isEqualToString: @"settings"] == NO)
Expand Down Expand Up @@ -391,7 +389,6 @@ - (NSDictionary *) recursiveKeysAndValuesForObject: (id)object
}
}

// NSLog(@"missingKeys are %@", missingKeys);
return keysAndValues;
}

Expand Down

0 comments on commit fa8ddfa

Please sign in to comment.