Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #135 from davidAtGVC/master

[NEW] --base-class-import option to specify base classes that are in another location (subproject). David Aspinall
  • Loading branch information...
commit 6746f9602a767aebb01ae0e375f372786f09f50d 2 parents 2742b2e + 7d2e730
@rentzsch authored
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
1  mogenerator.h
@@ -59,6 +59,7 @@
NSManagedObjectModel *model;
NSString *configuration;
NSString *baseClass;
+ NSString *baseClassImport;
NSString *baseClassForce;
NSString *includem;
NSString *includeh;
View
13 mogenerator.m
@@ -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;
View
2  templates/machine.h.motemplate
@@ -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$>
Please sign in to comment.
Something went wrong with that request. Please try again.