Skip to content

Commit

Permalink
Updating to latest from 'upstream/master
Browse files Browse the repository at this point in the history
  • Loading branch information
rtircher committed Mar 15, 2013
2 parents 69fedfa + 5556c1b commit d6f9840
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@end

@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomClass;
- (BOOL)hasSuperentity;
- (BOOL)hasCustomSuperentity;
- (NSString*)customSuperentity;
Expand Down
22 changes: 16 additions & 6 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_
nsenumerate (allEntities, NSEntityDescription, entity) {
NSString *entityClassName = [entity managedObjectClassName];

if ([entityClassName isEqualToString:@"NSManagedObject"] || [entityClassName isEqualToString:@""] || [entityClassName isEqualToString:gCustomBaseClass]){
if ([entity hasCustomClass]){
[result addObject:entity];
} else {
if (verbose_) {
ddprintf(@"skipping entity %@ (%@) because it doesn't use a custom subclass.\n",
entity.name, entityClassName);
}
} else {
[result addObject:entity];
}
}

Expand All @@ -77,6 +77,15 @@ - (BOOL)hasCustomBaseCaseImport {
- (NSString*)baseClassImport {
return gCustomBaseClassImport;
}

- (BOOL)hasCustomClass {
NSString *entityClassName = [self managedObjectClassName];
BOOL result = !([entityClassName isEqualToString:@"NSManagedObject"]
|| [entityClassName isEqualToString:@""]
|| [entityClassName isEqualToString:gCustomBaseClass]);
return result;
}

- (BOOL)hasSuperentity {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
Expand All @@ -90,14 +99,15 @@ - (BOOL)hasCustomSuperentity {
if (!forcedBaseClass) {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
return YES;
return [superentity hasCustomClass] ? YES : NO;
} else {
return gCustomBaseClass ? YES : NO;
}
} else {
return YES;
}
}

- (NSString*)customSuperentity {
NSString *forcedBaseClass = [self forcedCustomBaseClass];
if (!forcedBaseClass) {
Expand Down Expand Up @@ -969,13 +979,13 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
[fm removeItemAtPath:tempGeneratedMomFilePath error:nil];
}
bool mfileGenerated = NO;
if (mfilePath && ![mfileContent isEqualToString:@""]) {
if (mfilePath && ![mfileContent isEqualToString:@""] && (![fm regularFileExistsAtPath:mfilePath] || ![[NSString stringWithContentsOfFile:mfilePath encoding:NSUTF8StringEncoding error:nil] isEqualToString:mfileContent])) {
[mfileContent writeToFile:mfilePath atomically:NO encoding:NSUTF8StringEncoding error:nil];
mfileGenerated = YES;
}

bool hfileGenerated = NO;
if (hfilePath && ![hfileContent isEqualToString:@""]) {
if (hfilePath && ![hfileContent isEqualToString:@""] && (![fm regularFileExistsAtPath:hfilePath] || ![[NSString stringWithContentsOfFile:hfilePath encoding:NSUTF8StringEncoding error:nil] isEqualToString:hfileContent])) {
[hfileContent writeToFile:hfilePath atomically:NO encoding:NSUTF8StringEncoding error:nil];
hfileGenerated = YES;
}
Expand Down
Binary file modified test/test.xcdatamodel/elements
Binary file not shown.
Binary file modified test/test.xcdatamodel/layout
Binary file not shown.

0 comments on commit d6f9840

Please sign in to comment.