Changeset 243
- Timestamp:
- 07/17/07 13:26:49 (1 year ago)
- Files:
-
- trunk/cocoa/mogenerator/machine.m.motemplate (modified) (3 diffs)
- trunk/cocoa/mogenerator/mogenerator.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cocoa/mogenerator/machine.m.motemplate
r224 r243 16 16 17 17 - (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$>"]; 21 21 } 22 22 … … 39 39 - (void)add<$Relationship.name.initialCapitalString$>:(NSSet*)value_ { 40 40 [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_]; 43 43 } 44 44 … … 52 52 NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value_ count:1]; 53 53 [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]; 57 57 } 58 58 trunk/cocoa/mogenerator/mogenerator.m
r239 r243 136 136 } 137 137 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 138 157 NSString *ApplicationSupportSubdirectoryName = @"mogenerator"; 139 NSString *gTemplatePath = nil; 140 static NSString* appSupportFileNamed(NSString *fileName_) { 158 - (NSString*)appSupportFileNamed:(NSString*)fileName_ { 141 159 NSFileManager *fileManager = [NSFileManager defaultManager]; 142 160 BOOL isDirectory; 143 161 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_]; 147 165 } 148 166 } else { … … 153 171 if ([fileManager fileExistsAtPath:appSupportDirectory isDirectory:&isDirectory]) { 154 172 NSString *appSupportSubdirectory = [appSupportDirectory stringByAppendingPathComponent:ApplicationSupportSubdirectoryName]; 173 if (templateGroup) { 174 appSupportSubdirectory = [appSupportSubdirectory stringByAppendingPathComponent:templateGroup]; 175 } 155 176 if ([fileManager fileExistsAtPath:appSupportSubdirectory isDirectory:&isDirectory] && isDirectory) { 156 177 NSString *appSupportFile = [appSupportSubdirectory stringByAppendingPathComponent:fileName_]; … … 163 184 } 164 185 165 NSLog(@"appSupportFileNamed (@\"%@\"): file not found", fileName_);186 NSLog(@"appSupportFileNamed:@\"%@\": file not found", fileName_); 166 187 exit(EXIT_FAILURE); 167 188 return nil; 168 189 } 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 @end185 186 @implementation MOGeneratorApp187 190 188 191 - (void) application: (DDCliApplication *) app … … 204 207 {@"machine-dir", 'M', DDGetoptRequiredArgument}, 205 208 {@"human-dir", 'H', DDGetoptRequiredArgument}, 209 {@"template-group", 0, DDGetoptRequiredArgument}, 206 210 207 211 {@"help", 'h', DDGetoptNoArgument}, … … 220 224 " --includem FILE Generate aggregate include file\n" 221 225 " --template-path PATH Path to templates\n" 226 " --template-group NAME Name of template group\n" 222 227 " -O, --output-dir DIR Output directory\n" 223 228 " -M, --machine-dir DIR Output directory for machine files\n" … … 266 271 if (_version) 267 272 { 268 printf("mogenerator 1. 4. By Jonathan 'Wolf' Rentzsch + friends.\n");273 printf("mogenerator 1.5. By Jonathan 'Wolf' Rentzsch + friends.\n"); 269 274 return EXIT_SUCCESS; 270 275 } 271 276 272 277 gCustomBaseClass = [baseClass retain]; 273 gTemplatePath = templatePath;274 278 NSString * mfilePath = includem; 275 279 NSMutableString * mfileContent = [NSMutableString stringWithString:@""]; … … 287 291 288 292 if (model) { 289 MiscMergeEngine *machineH = engineWithTemplatePath( appSupportFileNamed(@"machine.h.motemplate"));293 MiscMergeEngine *machineH = engineWithTemplatePath([self appSupportFileNamed:@"machine.h.motemplate"]); 290 294 assert(machineH); 291 MiscMergeEngine *machineM = engineWithTemplatePath( appSupportFileNamed(@"machine.m.motemplate"));295 MiscMergeEngine *machineM = engineWithTemplatePath([self appSupportFileNamed:@"machine.m.motemplate"]); 292 296 assert(machineM); 293 MiscMergeEngine *humanH = engineWithTemplatePath( appSupportFileNamed(@"human.h.motemplate"));297 MiscMergeEngine *humanH = engineWithTemplatePath([self appSupportFileNamed:@"human.h.motemplate"]); 294 298 assert(humanH); 295 MiscMergeEngine *humanM = engineWithTemplatePath( appSupportFileNamed(@"human.m.motemplate"));299 MiscMergeEngine *humanM = engineWithTemplatePath([self appSupportFileNamed:@"human.m.motemplate"]); 296 300 assert(humanM); 297 301 … … 388 392 return DDCliAppRunWithClass([MOGeneratorApp class]); 389 393 } 390
