Permalink
Browse files

Merge pull request #71 from joe-carroll-lextech/master

[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...
2 parents 13e0c00 + 49824e8 commit d032e96d28ae91f76375f35795c340a51aa15ac6 @rentzsch committed Aug 29, 2011
Showing with 22 additions and 6 deletions.
  1. +1 −0 mogenerator.h
  2. +19 −6 mogenerator.m
  3. +2 −0 mogenerator.xcodeproj/project.pbxproj
View
@@ -53,6 +53,7 @@
NSString *tempMOMPath;
NSManagedObjectModel *model;
NSString *baseClass;
+ NSString *baseClassForce;
NSString *includem;
NSString *includeh;
NSString *templatePath;
View
@@ -10,6 +10,7 @@
static NSString *kTemplateVar = @"TemplateVar";
NSString *gCustomBaseClass;
+NSString *gCustomBaseClassForced;
@interface NSEntityDescription (fetchedPropertiesAdditions)
- (NSDictionary *)fetchedPropertiesByName;
@@ -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 */
@@ -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},
@@ -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"
@@ -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;
@@ -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;
};

0 comments on commit d032e96

Please sign in to comment.