Permalink
Browse files

mogenerator 1.0.2:

[FIX] Johan Kool pointed out if you had a custom superentity and weren't using a custom base class (-baseClass option), a necessary #import of the superentity's header file wasn't being generated. Fixed with Johan's code+template patch.


[FIX] Mason Mark pointed out an Apple design recommendation for unsupported persistent attribute types:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html>
mogenerator generated incorrect code for attributes with an undefined type (NSUndefinedAttributeType) like this:

 - (*)content;
 - (void)setContent:(*)value_;

Fixed with Mason's code+template patch: code is no longer generated for attributes with an undefined type. mogeneratorTestMule includes a hairColor/hairColorStorage example to test this case now.


[NEW] Add mogeneratorTestMule. The project+model is handy for testing mogenerator, and there's no reason to keep it to myself.


[CHANGE] No longer generate validation methods. They were always empty, so they just added code bloat. The only nice thing about them is that they wrote the validator method signature for you, so I keep the declaration in the machine .h file but comment it out.
  • Loading branch information...
1 parent 7fbd407 commit ac1c2f037bea4d886ee01da592b44bdb1538d996 @rentzsch committed Nov 10, 2006
Showing with 9,209 additions and 162 deletions.
  1. +5 −3 machine.h.motemplate
  2. +2 −9 machine.m.motemplate
  3. +10 −3 mogenerator.m
  4. +3 −97 mogenerator.xcodeproj/project.pbxproj
  5. +49 −39 mogenerator.xcodeproj/wolf.mode1
  6. +89 −11 mogenerator.xcodeproj/wolf.pbxuser
  7. BIN mogeneratorTestMule/English.lproj/InfoPlist.strings
  8. +13 −0 mogeneratorTestMule/English.lproj/MainMenu.nib/classes.nib
  9. +24 −0 mogeneratorTestMule/English.lproj/MainMenu.nib/info.nib
  10. +6,059 −0 mogeneratorTestMule/English.lproj/MainMenu.nib/keyedobjects.nib
  11. +30 −0 mogeneratorTestMule/Info.plist
  12. +5 −0 mogeneratorTestMule/MOs/ChildMO.h
  13. +7 −0 mogeneratorTestMule/MOs/ChildMO.m
  14. +8 −0 mogeneratorTestMule/MOs/HumanMO.h
  15. +13 −0 mogeneratorTestMule/MOs/HumanMO.m
  16. +5 −0 mogeneratorTestMule/MOs/ParentMO.h
  17. +7 −0 mogeneratorTestMule/MOs/ParentMO.m
  18. +43 −0 mogeneratorTestMule/MOs/_ChildMO.h
  19. +83 −0 mogeneratorTestMule/MOs/_ChildMO.m
  20. +28 −0 mogeneratorTestMule/MOs/_HumanMO.h
  21. +48 −0 mogeneratorTestMule/MOs/_HumanMO.m
  22. +141 −0 mogeneratorTestMule/MOs/_ParentMO.h
  23. +356 −0 mogeneratorTestMule/MOs/_ParentMO.m
  24. +6 −0 mogeneratorTestMule/MOs/include.m
  25. +10 −0 mogeneratorTestMule/MyBaseClass.h
  26. +13 −0 mogeneratorTestMule/MyBaseClass.m
  27. +14 −0 mogeneratorTestMule/main.m
  28. +4 −0 mogeneratorTestMule/mogenerate.command
  29. +309 −0 mogeneratorTestMule/mogeneratorTestMule.xcodeproj/project.pbxproj
  30. +1,336 −0 mogeneratorTestMule/mogeneratorTestMule.xcodeproj/wolf.mode1
  31. +293 −0 mogeneratorTestMule/mogeneratorTestMule.xcodeproj/wolf.pbxuser
  32. +26 −0 mogeneratorTestMule/mogeneratorTestMule_AppDelegate.h
  33. +149 −0 mogeneratorTestMule/mogeneratorTestMule_AppDelegate.m
  34. BIN mogeneratorTestMule/mogeneratorTestMule_DataModel.xcdatamodel/elements
  35. BIN mogeneratorTestMule/mogeneratorTestMule_DataModel.xcdatamodel/layout
  36. +7 −0 mogeneratorTestMule/mogeneratorTestMule_Prefix.pch
  37. +14 −0 mogeneratorTestMule/version.plist
View
@@ -2,21 +2,23 @@
// Make changes to <$managedObjectClassName$>.h instead.
#import <CoreData/CoreData.h>
-<$if hasCustomBaseClass$>#import "<$customSuperentity$>.h"<$endif$>
+<$if hasCustomBaseClass$>#import "<$customSuperentity$>.h"<$elseif hasCustomSuperentity$>#import "<$customSuperentity$>.h"<$endif$>
<$foreach Relationship relationshipsByName do$>
@class <$Relationship.destinationEntity.managedObjectClassName$>;
<$endforeach do$>
@interface _<$managedObjectClassName$> : <$customSuperentity$> {}
<$foreach Attribute attributesByName do$>
+<$if Attribute.hasDefinedAttributeType$>
- (<$Attribute.attributeValueClassName$>*)<$Attribute.name$>;
- (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.attributeValueClassName$>*)value_;
<$if Attribute.hasScalarAttributeType$>
- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value;
- (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_;
<$endif$>
-- (BOOL)validate<$Attribute.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_;
+//- (BOOL)validate<$Attribute.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_;
+<$endif$>
<$endforeach do$>
<$foreach Relationship relationshipsByName do$>
<$if Relationship.isToMany$>
@@ -26,7 +28,7 @@
<$else$>
- (<$Relationship.destinationEntity.managedObjectClassName$>*)<$Relationship.name$>;
- (void)set<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_;
-- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_;
+//- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_;
<$endif$>
<$endforeach do$>
@end
View
@@ -5,6 +5,7 @@
@implementation _<$managedObjectClassName$>
<$foreach Attribute attributesByName do$>
+<$if Attribute.hasDefinedAttributeType$>
- (<$Attribute.attributeValueClassName$>*)<$Attribute.name$> {
[self willAccessValueForKey:@"<$Attribute.name$>"];
@@ -19,10 +20,6 @@
[self didChangeValueForKey:@"<$Attribute.name$>"];
}
-- (BOOL)validate<$Attribute.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_ {
- return YES;
-}
-
<$if Attribute.hasScalarAttributeType$>
- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value {
@@ -34,7 +31,7 @@
}
<$endif$>
-
+<$endif$>
<$endforeach do$>
<$foreach Relationship relationshipsByName do$>
@@ -73,10 +70,6 @@
[self didChangeValueForKey:@"<$Relationship.name$>"];
}
-- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_ {
- return YES;
-}
-
<$endif$>
<$endforeach do$>
@end
View
@@ -14,6 +14,7 @@
@interface NSEntityDescription (customBaseClass)
- (BOOL)hasCustomBaseClass;
- (NSString*)customSuperentity;
+- (BOOL)hasCustomSuperentity;
@end
@implementation NSEntityDescription (customBaseClass)
- (BOOL)hasCustomBaseClass {
@@ -27,10 +28,15 @@ - (NSString*)customSuperentity {
return gCustomBaseClass ? gCustomBaseClass : @"NSManagedObject";
}
}
+- (BOOL)hasCustomSuperentity {
+ // managedObjectClassName is null when the parent entity isn't set.
+ return [[self superentity] managedObjectClassName] ? YES : NO;
+}
@end
@interface NSAttributeDescription (scalarAttributeType)
- (BOOL)hasScalarAttributeType;
- (NSString*)scalarAttributeType;
+- (BOOL)hasDefinedAttributeType;
@end
@implementation NSAttributeDescription (scalarAttributeType)
- (BOOL)hasScalarAttributeType {
@@ -71,6 +77,9 @@ - (NSString*)scalarAttributeType {
return nil;
}
}
+- (BOOL)hasDefinedAttributeType {
+ return [self attributeType] != NSUndefinedAttributeType;
+}
@end
@interface NSString (camelCaseString)
- (NSString*)camelCaseString;
@@ -151,7 +160,7 @@ int main (int argc, const char * argv[]) {
assert([mfilePath length]);
break;
case opt_version:
- printf("mogenerator 1.0.1. By Jonathan 'Wolf' Rentzsch.\n");
+ printf("mogenerator 1.0.2. By Jonathan 'Wolf' Rentzsch.\n");
break;
case opt_help:
default:
@@ -224,5 +233,3 @@ int main (int argc, const char * argv[]) {
[pool release];
return 0;
}
-
-

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit ac1c2f0

Please sign in to comment.