Skip to content

Commit

Permalink
adding a base-class-force option that will use user provided base cla…
Browse files Browse the repository at this point in the history
…ss even if a super entity exists. Base-class will still function normally
  • Loading branch information
Joe Carroll committed Aug 28, 2011
1 parent 0a9bbd6 commit 49824e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions mogenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
NSString *tempMOMPath;
NSManagedObjectModel *model;
NSString *baseClass;
NSString *baseClassForce;
NSString *includem;
NSString *includeh;
NSString *templatePath;
Expand Down
25 changes: 19 additions & 6 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

static NSString *kTemplateVar = @"TemplateVar";
NSString *gCustomBaseClass;
NSString *gCustomBaseClassForced;

@interface NSEntityDescription (fetchedPropertiesAdditions)
- (NSDictionary *)fetchedPropertiesByName;
Expand Down Expand Up @@ -66,11 +67,15 @@ - (BOOL)hasCustomSuperentity {
}
}
- (NSString*)customSuperentity {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
return [superentity managedObjectClassName];
if(!gCustomBaseClassForced) {
NSEntityDescription *superentity = [self superentity];
if (superentity) {
return [superentity managedObjectClassName];
} else {
return gCustomBaseClass ? gCustomBaseClass : @"NSManagedObject";
}
} else {
return gCustomBaseClass ? gCustomBaseClass : @"NSManagedObject";
return gCustomBaseClassForced;
}
}
/** @TypeInfo NSAttributeDescription */
Expand Down Expand Up @@ -361,6 +366,7 @@ - (void) application: (DDCliApplication *) app
// Long Short Argument options
{@"model", 'm', DDGetoptRequiredArgument},
{@"base-class", 0, DDGetoptRequiredArgument},
{@"base-class-force", 0, DDGetoptRequiredArgument},
// For compatibility:
{@"baseClass", 0, DDGetoptRequiredArgument},
{@"includem", 0, DDGetoptRequiredArgument},
Expand Down Expand Up @@ -389,6 +395,7 @@ - (void) printUsage;
printf("\n"
" -m, --model MODEL Path to model\n"
" --base-class CLASS Custom base class\n"
" --base-class-force CLASS Same as --base-class except will force all entities to have the specified base class. Even if a super entity exists\n"
" --includem FILE Generate aggregate include file for .m files for both human and machine generated source files\n"
" --includeh FILE Generate aggregate include file for .h files for human generated source files only\n"
" --template-path PATH Path to templates (absolute or relative to model path)\n"
Expand Down Expand Up @@ -531,8 +538,14 @@ - (int) application: (DDCliApplication *) app
printf("mogenerator 1.23. By Jonathan 'Wolf' Rentzsch + friends.\n");
return EXIT_SUCCESS;
}

gCustomBaseClass = [baseClass retain];

if(baseClassForce) {
gCustomBaseClassForced = [baseClassForce retain];
gCustomBaseClass = gCustomBaseClassForced;
} else {
gCustomBaseClass = [baseClass retain];
}

NSString * mfilePath = includem;
NSString * hfilePath = includeh;

Expand Down

0 comments on commit 49824e8

Please sign in to comment.