Permalink
Browse files

Added command line option for --base-class-import

The objective was to specify a base class that was being loaded from a static library project rather than the local project.  This was the
--base-class GVCManagedObject \
--base-class-import "<GVCCoreData/GVCManagedObject.h>"
  • Loading branch information...
davidAtGVC committed Oct 26, 2012
1 parent 2742b2e commit 7d2e730cff765fef00499b2a33dc719c07702c13
Showing with 14 additions and 2 deletions.
  1. +1 −0 mogenerator.h
  2. +12 −1 mogenerator.m
  3. +1 −1 templates/machine.h.motemplate
View
@@ -59,6 +59,7 @@
NSManagedObjectModel *model;
NSString *configuration;
NSString *baseClass;
+ NSString *baseClassImport;
NSString *baseClassForce;
NSString *includem;
NSString *includeh;
View
@@ -10,6 +10,7 @@
static NSString * const kTemplateVar = @"TemplateVar";
NSString *gCustomBaseClass;
+NSString *gCustomBaseClassImport;
NSString *gCustomBaseClassForced;
@interface NSEntityDescription (fetchedPropertiesAdditions)
@@ -72,6 +73,12 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString *)configuration
@implementation NSEntityDescription (customBaseClass)
+- (BOOL)hasCustomBaseCaseImport {
+ return gCustomBaseClassImport == nil ? NO : YES;
+}
+- (NSString *)baseClassImport {
+ return gCustomBaseClassImport;
+}
- (BOOL)hasCustomSuperentity {
NSString *forcedBaseClass = [self forcedCustomBaseClass];
if (!forcedBaseClass) {
@@ -499,7 +506,8 @@ - (void) application: (DDCliApplication *) app
// Long Short Argument options
{@"model", 'm', DDGetoptRequiredArgument},
{@"configuration", 'C', DDGetoptRequiredArgument},
- {@"base-class", 0, DDGetoptRequiredArgument},
+ {@"base-class", 0, DDGetoptRequiredArgument},
+ {@"base-class-import", 0, DDGetoptRequiredArgument},
{@"base-class-force", 0, DDGetoptRequiredArgument},
// For compatibility:
{@"baseClass", 0, DDGetoptRequiredArgument},
@@ -530,6 +538,7 @@ - (void) printUsage;
" -m, --model MODEL Path to model\n"
" -C, --configuration CONFIG Only consider entities included in the named configuration\n"
" --base-class CLASS Custom base class\n"
+ " --base-class-import TEXT Imports base class as #import TEXT\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"
@@ -695,8 +704,10 @@ - (int) application: (DDCliApplication *) app
if(baseClassForce) {
gCustomBaseClassForced = [baseClassForce retain];
gCustomBaseClass = gCustomBaseClassForced;
+ gCustomBaseClassImport = [baseClassImport retain];
} else {
gCustomBaseClass = [baseClass retain];
+ gCustomBaseClassImport = [baseClassImport retain];
}
NSString * mfilePath = includem;
@@ -2,7 +2,7 @@
// Make changes to <$managedObjectClassName$>.h instead.
#import <CoreData/CoreData.h>
-<$if hasCustomSuperentity$>#import "<$customSuperentity$>.h"<$endif$>
+<$if hasCustomSuperentity$>#import <$if hasCustomBaseCaseImport$><$baseClassImport$><$else$>"<$customSuperentity$>.h"<$endif$><$endif$>
extern const struct <$managedObjectClassName$>Attributes {<$foreach Attribute noninheritedAttributes do$>
<$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Attribute.name$>;<$endforeach do$>

0 comments on commit 7d2e730

Please sign in to comment.