Skip to content

Commit

Permalink
Merge pull request #71 from joe-carroll-lextech/master
Browse files Browse the repository at this point in the history
[NEW] base-class-force option that uses the provided base class name even if a super entity exists (base-class option still functions normally). (Joe Carroll)
  • Loading branch information
rentzsch committed Aug 29, 2011
2 parents 13e0c00 + 49824e8 commit d032e96
Show file tree
Hide file tree
Showing 3 changed files with 22 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
2 changes: 2 additions & 0 deletions mogenerator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
SDKROOT = macosx;
};
name = Debug;
};
1DEB927A08733DD40010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
SDKROOT = macosx;
};
name = Release;
};
Expand Down

0 comments on commit d032e96

Please sign in to comment.