From 838b5c01ad2f3978ea98da9b37a219c50c3f5f75 Mon Sep 17 00:00:00 2001 From: David Aspinall Date: Wed, 14 Nov 2012 22:16:32 -0500 Subject: [PATCH] Small fix for when you have inheritance and a custom superclass that is not local to the project. --- mogenerator.h | 1 + mogenerator.m | 8 ++++++++ templates/machine.h.motemplate | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mogenerator.h b/mogenerator.h index fec9b113..6cff75dd 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -21,6 +21,7 @@ @end @interface NSEntityDescription (customBaseClass) +- (BOOL)hasSuperentity; - (BOOL)hasCustomSuperentity; - (NSString*)customSuperentity; - (NSString*)forcedCustomBaseClass; diff --git a/mogenerator.m b/mogenerator.m index acd25af5..02bfcd63 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -79,6 +79,14 @@ - (BOOL)hasCustomBaseCaseImport { - (NSString*)baseClassImport { return gCustomBaseClassImport; } +- (BOOL)hasSuperentity { + NSEntityDescription *superentity = [self superentity]; + if (superentity) { + return YES; + } + return NO; +} + - (BOOL)hasCustomSuperentity { NSString *forcedBaseClass = [self forcedCustomBaseClass]; if (!forcedBaseClass) { diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate index 33b2e61c..249b4671 100644 --- a/templates/machine.h.motemplate +++ b/templates/machine.h.motemplate @@ -2,7 +2,8 @@ // Make changes to <$managedObjectClassName$>.h instead. #import -<$if hasCustomSuperentity$>#import <$if hasCustomBaseCaseImport$><$baseClassImport$><$else$>"<$customSuperentity$>.h"<$endif$><$endif$> +<$if hasCustomSuperentity$><$if hasSuperentity$>#import "<$customSuperentity$>.h" +<$else$><$if hasCustomBaseCaseImport$>#import <$baseClassImport$><$else$>#import "<$customSuperentity$>.h"<$endif$><$endif$><$endif$> extern const struct <$managedObjectClassName$>Attributes {<$foreach Attribute noninheritedAttributes do$> <$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Attribute.name$>;<$endforeach do$>