Changeset 243

Show
Ignore:
Timestamp:
07/17/07 13:26:49 (1 year ago)
Author:
rentzsch
Message:

[NEW] mogenerator 1.5. Added --template-group option.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cocoa/mogenerator/machine.m.motemplate

    r224 r243  
    1616 
    1717- (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.attributeValueClassName$>*)value_ { 
    18     [self willChangeValueForKey:@"<$Attribute.name$>"]; 
    19     [self setPrimitiveValue:value_ forKey:@"<$Attribute.name$>"]; 
    20     [self didChangeValueForKey:@"<$Attribute.name$>"]; 
     18       [self willChangeValueForKey:@"<$Attribute.name$>"]; 
     19       [self setPrimitiveValue:value_ forKey:@"<$Attribute.name$>"]; 
     20       [self didChangeValueForKey:@"<$Attribute.name$>"]; 
    2121} 
    2222 
     
    3939- (void)add<$Relationship.name.initialCapitalString$>:(NSSet*)value_ { 
    4040        [self willChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value_]; 
    41     [[self primitiveValueForKey:@"<$Relationship.name$>"] unionSet:value_]; 
    42     [self didChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value_]; 
     41       [[self primitiveValueForKey:@"<$Relationship.name$>"] unionSet:value_]; 
     42       [self didChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:value_]; 
    4343} 
    4444 
     
    5252        NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value_ count:1]; 
    5353        [self willChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; 
    54     [[self primitiveValueForKey:@"<$Relationship.name$>"] addObject:value_]; 
    55     [self didChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; 
    56     [changedObjects release]; 
     54       [[self primitiveValueForKey:@"<$Relationship.name$>"] addObject:value_]; 
     55       [self didChangeValueForKey:@"<$Relationship.name$>" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects]; 
     56       [changedObjects release]; 
    5757} 
    5858 
  • trunk/cocoa/mogenerator/mogenerator.m

    r239 r243  
    136136} 
    137137 
     138@interface MOGeneratorApp : NSObject <DDCliApplicationDelegate> { 
     139        NSString                                *tempMOMPath; 
     140        NSManagedObjectModel    *model; 
     141        NSString                                *baseClass; 
     142        NSString                                *includem; 
     143        NSString                                *templatePath; 
     144        NSString                                *outputDir; 
     145        NSString                                *machineDir; 
     146        NSString                                *humanDir; 
     147        NSString                                *templateGroup; 
     148        BOOL                                    _help; 
     149        BOOL                                    _version; 
     150} 
     151 
     152- (NSString*)appSupportFileNamed:(NSString*)fileName_; 
     153@end 
     154 
     155@implementation MOGeneratorApp 
     156 
    138157NSString *ApplicationSupportSubdirectoryName = @"mogenerator"; 
    139 NSString *gTemplatePath = nil; 
    140 static NSString* appSupportFileNamed(NSString *fileName_) { 
     158- (NSString*)appSupportFileNamed:(NSString*)fileName_ { 
    141159        NSFileManager *fileManager = [NSFileManager defaultManager]; 
    142160        BOOL isDirectory; 
    143161         
    144         if (gTemplatePath) { 
    145                 if ([fileManager fileExistsAtPath:gTemplatePath isDirectory:&isDirectory] && isDirectory) { 
    146                         return [gTemplatePath stringByAppendingPathComponent:fileName_]; 
     162        if (templatePath) { 
     163                if ([fileManager fileExistsAtPath:templatePath isDirectory:&isDirectory] && isDirectory) { 
     164                        return [templatePath stringByAppendingPathComponent:fileName_]; 
    147165                } 
    148166        } else { 
     
    153171                        if ([fileManager fileExistsAtPath:appSupportDirectory isDirectory:&isDirectory]) { 
    154172                                NSString *appSupportSubdirectory = [appSupportDirectory stringByAppendingPathComponent:ApplicationSupportSubdirectoryName]; 
     173                                if (templateGroup) { 
     174                                        appSupportSubdirectory = [appSupportSubdirectory stringByAppendingPathComponent:templateGroup]; 
     175                                } 
    155176                                if ([fileManager fileExistsAtPath:appSupportSubdirectory isDirectory:&isDirectory] && isDirectory) { 
    156177                                        NSString *appSupportFile = [appSupportSubdirectory stringByAppendingPathComponent:fileName_]; 
     
    163184        } 
    164185         
    165         NSLog(@"appSupportFileNamed(@\"%@\"): file not found", fileName_); 
     186        NSLog(@"appSupportFileNamed:@\"%@\": file not found", fileName_); 
    166187        exit(EXIT_FAILURE); 
    167188        return nil; 
    168189} 
    169  
    170 @interface MOGeneratorApp : NSObject <DDCliApplicationDelegate> 
    171 { 
    172         NSString * tempMOMPath; 
    173     NSManagedObjectModel * model; 
    174     NSString * baseClass; 
    175     NSString * includem; 
    176     NSString * templatePath; 
    177     NSString * outputDir; 
    178     NSString * machineDir; 
    179     NSString * humanDir; 
    180     BOOL _help; 
    181     BOOL _version; 
    182 } 
    183  
    184 @end 
    185  
    186 @implementation MOGeneratorApp 
    187190 
    188191- (void) application: (DDCliApplication *) app 
     
    204207    {@"machine-dir",    'M',    DDGetoptRequiredArgument}, 
    205208    {@"human-dir",      'H',    DDGetoptRequiredArgument}, 
     209    {@"template-group", 0,      DDGetoptRequiredArgument}, 
    206210 
    207211    {@"help",           'h',    DDGetoptNoArgument}, 
     
    220224           "      --includem FILE           Generate aggregate include file\n" 
    221225           "      --template-path PATH      Path to templates\n" 
     226           "      --template-group NAME     Name of template group\n" 
    222227           "  -O, --output-dir DIR          Output directory\n" 
    223228           "  -M, --machine-dir DIR         Output directory for machine files\n" 
     
    266271    if (_version) 
    267272    { 
    268         printf("mogenerator 1.4. By Jonathan 'Wolf' Rentzsch + friends.\n"); 
     273        printf("mogenerator 1.5. By Jonathan 'Wolf' Rentzsch + friends.\n"); 
    269274        return EXIT_SUCCESS; 
    270275    } 
    271276     
    272277    gCustomBaseClass = [baseClass retain]; 
    273     gTemplatePath = templatePath; 
    274278    NSString * mfilePath = includem; 
    275279        NSMutableString * mfileContent = [NSMutableString stringWithString:@""]; 
     
    287291         
    288292        if (model) { 
    289                 MiscMergeEngine *machineH = engineWithTemplatePath(appSupportFileNamed(@"machine.h.motemplate")); 
     293                MiscMergeEngine *machineH = engineWithTemplatePath([self appSupportFileNamed:@"machine.h.motemplate"]); 
    290294                assert(machineH); 
    291                 MiscMergeEngine *machineM = engineWithTemplatePath(appSupportFileNamed(@"machine.m.motemplate")); 
     295                MiscMergeEngine *machineM = engineWithTemplatePath([self appSupportFileNamed:@"machine.m.motemplate"]); 
    292296                assert(machineM); 
    293                 MiscMergeEngine *humanH = engineWithTemplatePath(appSupportFileNamed(@"human.h.motemplate")); 
     297                MiscMergeEngine *humanH = engineWithTemplatePath([self appSupportFileNamed:@"human.h.motemplate"]); 
    294298                assert(humanH); 
    295                 MiscMergeEngine *humanM = engineWithTemplatePath(appSupportFileNamed(@"human.m.motemplate")); 
     299                MiscMergeEngine *humanM = engineWithTemplatePath([self appSupportFileNamed:@"human.m.motemplate"]); 
    296300                assert(humanM);  
    297301         
     
    388392    return DDCliAppRunWithClass([MOGeneratorApp class]); 
    389393} 
    390