diff --git a/.gitignore b/.gitignore index 2e4a8a51..515ce9c0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,8 @@ dist *.xcodeproj/*.mode* *.xcodeproj/*.pbxuser **/*.xcodeproj/* -!**/*.xcodeproj/project.pbxproj \ No newline at end of file +!**/*.xcodeproj/project.pbxproj +/mogenerator.xcodeproj/project.xcworkspace/ +/mogenerator.xcodeproj/xcuserdata/ +/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/ +/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/xcuserdata/ diff --git a/FoundationAdditions.h b/FoundationAdditions.h index 6b1fd35f..4812ae8d 100644 --- a/FoundationAdditions.h +++ b/FoundationAdditions.h @@ -39,6 +39,5 @@ extern void Printf(NSString *format, ...); - (BOOL)regularFileExistsAtPath:(NSString *)path; - (NSString *)findFile:(NSString *)filename inSearchPath:(NSArray *)paths; - (void)touchPath:(NSString *)filePath; -- (BOOL)deepCreateDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes; @end diff --git a/FoundationAdditions.m b/FoundationAdditions.m index 5565ff4b..05a88cd9 100644 --- a/FoundationAdditions.m +++ b/FoundationAdditions.m @@ -38,7 +38,7 @@ void ErrVPrintf(NSString *format, va_list arguments) { NSString *logString = [[NSString alloc] initWithFormat:format arguments:arguments]; - fwrite([logString cString], 1, [logString cStringLength], stderr); + fwrite([logString cStringUsingEncoding:NSUTF8StringEncoding], 1, [logString lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stderr); if (![logString hasSuffix:@"\n"]) fputc('\n', stdout); [logString release]; } @@ -55,7 +55,7 @@ void ErrPrintf(NSString *format, ...) void VPrintf(NSString *format, va_list arguments) { NSString *logString = [[NSString alloc] initWithFormat:format arguments:arguments]; - fwrite([logString cString], 1, [logString cStringLength], stdout); + fwrite([logString cStringUsingEncoding:NSUTF8StringEncoding], 1, [logString lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stdout); if (![logString hasSuffix:@"\n"]) fputc('\n', stdout); [logString release]; } @@ -92,7 +92,7 @@ - (id)computeReversedArrayForKey:(NSString *) key return [[self reversedArray] valueForKeyPath:key]; } -static int sortByName(id obj1, id obj2, void *context) +static NSInteger sortByName(id obj1, id obj2, void *context) { return [(NSString *)[obj1 valueForKey:@"name"] compare:[obj2 valueForKey:@"name"]]; } @@ -143,7 +143,7 @@ - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObj - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObject withObject:anObject2 { - unsigned i, count = [self count]; + NSUInteger i, count = [self count]; NSMutableArray *array = [NSMutableArray arrayWithCapacity:count]; for(i=0; i 0 && ![self directoryExistsAtPath:parent]) - { - // May want to ensure owner write permissions here... - if (![self deepCreateDirectoryAtPath:parent attributes:attributes]) - return NO; - } - - return [self createDirectoryAtPath:path attributes:attributes]; -} - @end diff --git a/MiscMerge/KeyValue+MiscMerge.m b/MiscMerge/KeyValue+MiscMerge.m index 4a7dde6d..27497538 100755 --- a/MiscMerge/KeyValue+MiscMerge.m +++ b/MiscMerge/KeyValue+MiscMerge.m @@ -65,7 +65,7 @@ - (BOOL)hasMiscMergeKey:(NSString *)key return (keySelector != NULL && [self respondsToSelector:keySelector]) || ([[self class] accessInstanceVariablesDirectly] && - class_getInstanceVariable([self class], [key cString])); + class_getInstanceVariable([self class], [key cStringUsingEncoding:NSUTF8StringEncoding])); } @end @@ -117,4 +117,4 @@ static Ivar_t class_getInstanceVariable(Class aClass, const char *name) return NULL; } -#endif GNU_RUNTIME +#endif diff --git a/MiscMerge/MiscMergeCommand.m b/MiscMerge/MiscMergeCommand.m index bd4ad4cf..c4e0164e 100755 --- a/MiscMerge/MiscMergeCommand.m +++ b/MiscMerge/MiscMergeCommand.m @@ -112,7 +112,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner isOptional:(BOOL)optional { NSCharacterSet *letterSet = [NSCharacterSet letterCharacterSet]; - int origLocation = [scanner scanLocation]; + NSUInteger origLocation = [scanner scanLocation]; BOOL isAlphaKeyword = [aKeyWord length] > 0 && [letterSet characterIsMember:[aKeyWord characterAtIndex:0]]; BOOL wasCaseSensitive = [scanner caseSensitive]; BOOL foundKeyword; @@ -124,7 +124,7 @@ - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner if (foundKeyword && isAlphaKeyword) { NSString *string = [scanner string]; - int currLocation = [scanner scanLocation]; + NSUInteger currLocation = [scanner scanLocation]; /* If we're at the end of the string, or the next char is not a letter, we're good. Otherwise abort. */ if (currLocation < [string length] && diff --git a/MiscMerge/MiscMergeEngine.m b/MiscMerge/MiscMergeEngine.m index 224c5410..f09c0136 100755 --- a/MiscMerge/MiscMergeEngine.m +++ b/MiscMerge/MiscMergeEngine.m @@ -427,7 +427,7 @@ - (void)removeContextObject:(id)anObject [contextStack removeObjectIdenticalTo:anObject]; if ( anObject == localSymbols ) { - int i; + NSInteger i; localSymbols = nil; @@ -466,7 +466,7 @@ - (MiscMergeTemplate *)template "*/ - (void)setMainObject:(id)anObject { - unsigned oldIndex = NSNotFound; + NSUInteger oldIndex = NSNotFound; if (currentObject != nil) { @@ -569,7 +569,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block { NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init]; NSArray *commandArray = [block commandArray]; - int i, count = [commandArray count]; + NSInteger i, count = [commandArray count]; MiscMergeCommandExitType exitCode = MiscMergeCommandExitNormal; /* * Maintain the execution stack. This stack isn't being used at the @@ -603,7 +603,7 @@ - (MiscMergeCommandExitType)executeCommandBlock:(MiscMergeCommandBlock *)block "*/ - (id)valueForField:(NSString *)fieldName quoted:(int)quoted { - int i; + NSInteger i; id value = nil; id prevValue = nil; id returnValue = nil; diff --git a/MiscMerge/MiscMergeExpression.m b/MiscMerge/MiscMergeExpression.m index c691f786..40dc58ea 100755 --- a/MiscMerge/MiscMergeExpression.m +++ b/MiscMerge/MiscMergeExpression.m @@ -441,7 +441,7 @@ - (NSString *)nameDescription - (NSString *)description { - int index, count = [expressions count]; + NSInteger index, count = [expressions count]; NSMutableString *string = [NSMutableString stringWithFormat:@"%@(", [self nameDescription]]; for ( index = 0; index < count; index++ ) { @@ -525,7 +525,7 @@ - (NSArray *)evaluateAsListWithEngine:(MiscMergeEngine *)anEngine NSEnumerator *enumerator = [expressions objectEnumerator]; MiscMergeExpression *expression; - while ( expression = (MiscMergeExpression *)[enumerator nextObject] ) { + while (( expression = (MiscMergeExpression *)[enumerator nextObject] )) { [array addObject:[expression evaluateWithEngine:anEngine]]; } diff --git a/MiscMerge/MiscMergeFunctions.m b/MiscMerge/MiscMergeFunctions.m index 89ccefad..6c8bec4b 100755 --- a/MiscMerge/MiscMergeFunctions.m +++ b/MiscMerge/MiscMergeFunctions.m @@ -112,8 +112,8 @@ Class MMCommonAnscestorClass(id obj1, id obj2) else { NSCharacterSet *whitespaceSet = [NSCharacterSet whitespaceCharacterSet]; NSCharacterSet *newlineSet = [NSCharacterSet newlineCharacterSet]; - int start = 0, end = [string length]-1; - int i; + NSInteger start = 0, end = [string length]-1; + NSInteger i; for ( i = 0; i <= end; i++ ) { unichar character = [string characterAtIndex:i]; diff --git a/MiscMerge/MiscMergeTemplate.m b/MiscMerge/MiscMergeTemplate.m index 7d35dee3..be29361d 100755 --- a/MiscMerge/MiscMergeTemplate.m +++ b/MiscMerge/MiscMergeTemplate.m @@ -75,7 +75,7 @@ + (NSString *)defaultStartDelimiter /* This works better for whatever reason. Due to some unknown pecularities, a constant NSString doesn't work under Windows with Apple's implementation. */ - return [NSString stringWithCString:"«"]; + return [NSString stringWithCString:"«" encoding:NSUTF8StringEncoding]; } /*" @@ -87,7 +87,7 @@ + (NSString *)defaultEndDelimiter // return @")"; // return @"»"; /* This works better than a constant NSString for whatever reason. See above. */ - return [NSString stringWithCString:"»"]; + return [NSString stringWithCString:"»" encoding:NSUTF8StringEncoding]; } /*" Creates a new, autoreleased MiscMergeTemplate. "*/ @@ -444,9 +444,9 @@ - (void)parseContentsOfFile:(NSString *)filename "*/ - (void)parseString:(NSString *)string { + NSMutableString *accumString = [[[NSMutableString alloc] init] autorelease]; NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init]; NSScanner *scanner = [NSScanner scannerWithString:string]; - NSMutableString *accumString = [[NSMutableString alloc] init]; NSString *currString; int nestingLevel = 0; int maxNestingLevel = 0; diff --git a/MiscMerge/NSScanner+MiscMerge.m b/MiscMerge/NSScanner+MiscMerge.m index 4289844f..aecceff4 100755 --- a/MiscMerge/NSScanner+MiscMerge.m +++ b/MiscMerge/NSScanner+MiscMerge.m @@ -51,7 +51,7 @@ - (BOOL)scanString:(NSString *)aString "*/ - (NSRange)remainingRange { - unsigned location = [self scanLocation]; + NSUInteger location = [self scanLocation]; return NSMakeRange(location, [[self string] length] - location); } @@ -84,7 +84,7 @@ - (void)skipPastSkipCharacters - (BOOL)scanCharacter:(unichar)targetCharacter { - unsigned scanLocation = [self scanLocation]; + NSUInteger scanLocation = [self scanLocation]; NSString *myString = [self string]; [self skipPastSkipCharacters]; @@ -104,7 +104,7 @@ - (BOOL)scanCharacter:(unichar)targetCharacter - (unichar)peekNextCharacter { - unsigned scanLocation; + NSUInteger scanLocation; NSString *myString; [self skipPastSkipCharacters]; diff --git a/MiscMerge/NSString+MiscAdditions.h b/MiscMerge/NSString+MiscAdditions.h index 3bad4b37..fc1de2f7 100755 --- a/MiscMerge/NSString+MiscAdditions.h +++ b/MiscMerge/NSString+MiscAdditions.h @@ -40,7 +40,7 @@ enum /*" "Letter" manipulation "*/ - (NSString *)letterAtIndex:(unsigned)anIndex; - (NSString *)firstLetter; -- (unsigned)letterCount; +- (NSUInteger)letterCount; /*" Getting "words" "*/ - (NSArray *)wordArray; diff --git a/MiscMerge/NSString+MiscAdditions.m b/MiscMerge/NSString+MiscAdditions.m index 68e49bff..397c562b 100755 --- a/MiscMerge/NSString+MiscAdditions.m +++ b/MiscMerge/NSString+MiscAdditions.m @@ -123,11 +123,11 @@ - (NSString *)firstLetter return [self letterAtIndex:0]; } -- (unsigned)letterCount +- (NSUInteger)letterCount { - unsigned count = 0; - unsigned selfLength = [self length]; - unsigned currIndex = 0; + NSUInteger count = 0; + NSUInteger selfLength = [self length]; + NSUInteger currIndex = 0; NSRange letterRange; while (currIndex < selfLength) @@ -227,7 +227,7 @@ - (NSString *)firstWord } static NSRange _nextSearchRange(NSString *string, unsigned mask, - NSRange *foundRange, unsigned lastIndex, unsigned firstIndex) + NSRange *foundRange, NSUInteger lastIndex, NSUInteger firstIndex) { /* * The char range stuff is if we want to use @@ -241,7 +241,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask, if (mask & NSBackwardsSearch) { - unsigned endLocation; + NSUInteger endLocation; if (mask & MiscOverlappingSearch) { @@ -282,7 +282,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask, NSRange foundRange; NSRange betweenRange; unsigned searchOptions = (mask & (NSCaseInsensitiveSearch|NSLiteralSearch)); - unsigned selfLength = [self length]; + NSUInteger selfLength = [self length]; NSMutableString *newString = [NSMutableString stringWithCapacity:selfLength]; mask &= ~NSBackwardsSearch; @@ -347,7 +347,7 @@ static NSRange _nextSearchRange(NSString *string, unsigned mask, if ([scanner scanCharactersFromSet:aSet intoString:&betweenString]) { - int i, count = [betweenString length]; + NSInteger i, count = [betweenString length]; // int i, count = [betweenString letterCount]; for (i=0;i 0) - fileString = [[NSString alloc] initWithContentsOfFile:resolvedFilename]; + fileString = [[[NSString alloc] initWithContentsOfFile:resolvedFilename] autorelease]; if (fileString) { diff --git a/MiscMerge/_MiscMergeProcedureCommand.m b/MiscMerge/_MiscMergeProcedureCommand.m index 0b395a3e..44f1bacd 100755 --- a/MiscMerge/_MiscMergeProcedureCommand.m +++ b/MiscMerge/_MiscMergeProcedureCommand.m @@ -61,7 +61,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem [self eatKeyWord:@"procedure" fromScanner:aScanner isOptional:NO]; procedureName = [[self getArgumentStringFromScanner:aScanner toEnd:NO] retain]; - while (argName = [self getArgumentStringFromScanner:aScanner toEnd:NO]) { + while ((argName = [self getArgumentStringFromScanner:aScanner toEnd:NO])) { if ( [argName hasSuffix:@"?"] ) { optArgProcessing = YES; argName = [argName substringToIndex:([argName length] - 1)]; @@ -104,9 +104,9 @@ - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger /* The *real* execute; messaged from the call command */ - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger arguments:(NSArray *)passedArgArray { - int argumentIndex = 0, argumentCount = [argumentArray count]; - int passedIndex = 0, passedCount = [passedArgArray count]; - int addToArgIndex = 0; + NSInteger argumentIndex = 0, argumentCount = [argumentArray count]; + NSInteger passedIndex = 0, passedCount = [passedArgArray count]; + NSInteger addToArgIndex = 0; NSMutableDictionary *procedureContext = [NSMutableDictionary dictionary]; for ( ; passedIndex < passedCount; passedIndex++ ) { diff --git a/contributed templates/Nikita Zhuk/ponso/README.txt b/contributed templates/Nikita Zhuk/ponso/README.txt new file mode 100644 index 00000000..54fb8a71 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/README.txt @@ -0,0 +1,46 @@ +PONSO - Plain Old NSObjects +=========================== + +What is PONSO? +-------------- +The idea is to use mogenerator to generate lightweight, memory-only, type-safe ObjC data model classes from Xcode data models. + +Features +-------- +- Type-safe attributes +- Supports one-to-one and one-to-many relationships +- Relationships are always ordered - implemented with NSArrays +- Supports inverse relationships, which should be always marked as 'transient' +- Supports serialization of any model object to NSDictionary and initialization from NSDictionary +- Supports writing and reading to binary property list files +- Requires that data model is a tree, where nodes are entities and edges are strong, non-transient relationships. Does not work with graph data models. +- Supports weak relationships which are not archived in serialized form. These relationships are not considered as part of the object graph tree, e.g. you can have strong relationships A -> B, A -> C and a weak relationship B -> C and this won't invalidate the "tree model" requirement. +- To create a weak relationship, add "destinationEntityIDKeyPath" user info key to that relationship in Xcode data modeller, and specify the name of attribute which can be used as unique ID to find the destination object. See sample projects entities DepartmentAssistant and DepartmentEmployee for examples. +- Cycles between weak relationships are found automatically and are warned about during code generation. + + +How to use +---------- +- The only additional source code you need to compile into your application for PONSO is ModelObject class found in "contributed templates/Nikita Zhuk/ponso/code" +- See "contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest" project for sample setup + + +TODO +----- +PONSO is a work in progress and can be enchanced in a various ways. + +Some missing features include: +- Automatic setting of inverse one-to-one relationships in setters +- Support for many-to-many relationships +- Implementations of to-many relationships as ordered sets instead of arrays +- Cycle detection of strong relationships +- Detection of retain cycles caused by both relationship directions being non-transient + +Feel free to fork & contribute. + + +Contact info +------------- +Nikita Zhuk, 2011 +Twitter: @nzhuk + diff --git a/contributed templates/Nikita Zhuk/ponso/code/ModelObject.h b/contributed templates/Nikita Zhuk/ponso/code/ModelObject.h new file mode 100644 index 00000000..7631db15 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/code/ModelObject.h @@ -0,0 +1,58 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ModelObject.h + mogenerator / PONSO + Created by Nikita Zhuk on 22.1.2011. + */ + +/** + Abstract superclass for all of our model classes. + */ + +#import + +@interface ModelObject : NSObject +{ + NSDictionary *sourceDictionaryRepresentation; +} + +@property(nonatomic, retain) NSDictionary *sourceDictionaryRepresentation; + +/** + Reads and deserializes a ModelObject from plist at given \c filePath + \return Newly created ModelObject or nil if any of the following occurs: file doesn't exist, file cannot be read, plist cannot be parsed. +*/ ++ (id)createModelObjectFromFile:(NSString *)filePath; + +/** + Serializes the receiver into binary plist and writes it to given \c filePath. Creates any intermediate directories in the path if necessary. + \return YES on success, NO on error (binary serialization or I/O error). +*/ +- (BOOL)writeToFile:(NSString *)filePath; + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary; +- (NSDictionary *)dictionaryRepresentation; + +- (void)awakeFromDictionaryRepresentationInit; + +@end + + +@interface NSMutableDictionary (PONSONSMutableDictionaryAdditions) + +- (void)setObjectIfNotNil:(id)obj forKey:(NSString *)key; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/code/ModelObject.m b/contributed templates/Nikita Zhuk/ponso/code/ModelObject.m new file mode 100644 index 00000000..9d2a3e5c --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/code/ModelObject.m @@ -0,0 +1,159 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + ModelObject.m + mogenerator / PONSO + Created by Nikita Zhuk on 22.1.2011. + */ + +#import "ModelObject.h" + +@implementation ModelObject + ++ (id)createModelObjectFromFile:(NSString *)filePath +{ + if(![[NSFileManager defaultManager] fileExistsAtPath:filePath]) + { + return nil; + } + + NSError *error = nil; + NSData *plistData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingUncached error:&error]; + if(!plistData) + { + NSLog(@"Couldn't read '%@' data from '%@': %@.", NSStringFromClass([self class]), filePath, error); + return nil; + } + + if([plistData length] == 0) + { + NSLog(@"Empty '%@' data found from '%@'.", NSStringFromClass([self class]), filePath); + return nil; + } + + NSString *errorString = nil; + NSDictionary *plist = [NSPropertyListSerialization propertyListFromData:plistData + mutabilityOption:0 + format:NULL + errorDescription:&errorString]; + if(!plist) + { + NSLog(@"Couldn't load '%@' data from '%@': %@.", NSStringFromClass([self class]), filePath, errorString); + [errorString release]; + + return nil; + } + + id modelObject = [[[self alloc] initWithDictionaryRepresentation:plist] autorelease]; + [modelObject awakeFromDictionaryRepresentationInit]; + + return modelObject; +} + +- (BOOL)writeToFile:(NSString *)filePath +{ + if(filePath == nil) + { + NSLog(@"File path was nil - cannot write to file."); + return NO; + } + + // Save this modelObject into plist + NSDictionary *dict = [self dictionaryRepresentation]; + NSString *errorDesc = nil; + NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:dict format:NSPropertyListBinaryFormat_v1_0 errorDescription:&errorDesc]; + if(!plistData) + { + NSLog(@"Error while serializing model object of class '%@' into plist. Error: '%@'.", NSStringFromClass([self class]), errorDesc); + + [errorDesc release]; // From docs: "If you receive a string, you must release it." + return NO; + } + + BOOL isDir = NO; + if(![[NSFileManager defaultManager] fileExistsAtPath:[filePath stringByDeletingLastPathComponent] isDirectory:&isDir] || !isDir) + { + NSError *error = nil; + if(![[NSFileManager defaultManager] createDirectoryAtPath:[filePath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:&error]) + { + NSLog(@"Couldn't create parent directory of file path '%@' for saving model object of class '%@': %@.", filePath, NSStringFromClass([self class]), error); + return NO; + } + } + + if(![plistData writeToFile:filePath atomically:YES]) + { + NSLog(@"Error while saving model object of class '%@' into plist file %@.", NSStringFromClass([self class]), filePath); + return NO; + + } + + return YES; +} + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super init])) + { + self.sourceDictionaryRepresentation = dictionary; + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + return [NSDictionary dictionary]; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + self.sourceDictionaryRepresentation = nil; +} + +- (void) dealloc +{ + self.sourceDictionaryRepresentation = nil; + + [super dealloc]; +} + +#pragma mark NSCopying + +- (id)copyWithZone:(NSZone *)zone +{ + // Note: ModelObject is not autoreleased because we are in copy method. + ModelObject *copy = [[[self class] alloc] initWithDictionaryRepresentation:[self dictionaryRepresentation]]; + [copy awakeFromDictionaryRepresentationInit]; + + return copy; +} + +@synthesize sourceDictionaryRepresentation; + +@end + + +@implementation NSMutableDictionary (PONSONSMutableDictionaryAdditions) + +- (void)setObjectIfNotNil:(id)obj forKey:(NSString *)key +{ + if(obj == nil) + return; + + [self setObject:obj forKey:key]; +} + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion new file mode 100644 index 00000000..96b1591a --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + MyModel.xcdatamodel + + diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements new file mode 100644 index 00000000..d36c5742 Binary files /dev/null and b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements differ diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout new file mode 100644 index 00000000..399589af Binary files /dev/null and b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout differ diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.pbxproj b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.pbxproj new file mode 100644 index 00000000..4e38107e --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.pbxproj @@ -0,0 +1,342 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 457C268D1399FAC600BF00DD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 457C268C1399FAC600BF00DD /* Foundation.framework */; }; + 457C26901399FAC600BF00DD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 457C268F1399FAC600BF00DD /* main.m */; }; + 457C26C5139A18CE00BF00DD /* ModelObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 457C26C4139A18CE00BF00DD /* ModelObject.m */; }; + 4584D411139A9D360035BCA5 /* _ModelAssistant.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D3FA139A9D360035BCA5 /* _ModelAssistant.m */; }; + 4584D412139A9D360035BCA5 /* _ModelCompany.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D3FC139A9D360035BCA5 /* _ModelCompany.m */; }; + 4584D413139A9D360035BCA5 /* _ModelDepartment.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D3FE139A9D360035BCA5 /* _ModelDepartment.m */; }; + 4584D414139A9D360035BCA5 /* _ModelDepartmentAssistant.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D400139A9D360035BCA5 /* _ModelDepartmentAssistant.m */; }; + 4584D415139A9D360035BCA5 /* _ModelDepartmentEmployee.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D402139A9D360035BCA5 /* _ModelDepartmentEmployee.m */; }; + 4584D416139A9D360035BCA5 /* _ModelEmployee.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D404139A9D360035BCA5 /* _ModelEmployee.m */; }; + 4584D417139A9D360035BCA5 /* ModelAssistant.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D406139A9D360035BCA5 /* ModelAssistant.m */; }; + 4584D418139A9D360035BCA5 /* ModelCompany.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D408139A9D360035BCA5 /* ModelCompany.m */; }; + 4584D419139A9D360035BCA5 /* ModelDepartment.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D40A139A9D360035BCA5 /* ModelDepartment.m */; }; + 4584D41A139A9D360035BCA5 /* ModelDepartmentAssistant.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D40C139A9D360035BCA5 /* ModelDepartmentAssistant.m */; }; + 4584D41B139A9D360035BCA5 /* ModelDepartmentEmployee.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D40E139A9D360035BCA5 /* ModelDepartmentEmployee.m */; }; + 4584D41C139A9D360035BCA5 /* ModelEmployee.m in Sources */ = {isa = PBXBuildFile; fileRef = 4584D410139A9D360035BCA5 /* ModelEmployee.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 457C26861399FAC600BF00DD /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 457C26881399FAC600BF00DD /* PonsoTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = PonsoTest; sourceTree = BUILT_PRODUCTS_DIR; }; + 457C268C1399FAC600BF00DD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 457C268F1399FAC600BF00DD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 457C26921399FAC600BF00DD /* PonsoTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PonsoTest-Prefix.pch"; sourceTree = ""; }; + 457C269A1399FB1E00BF00DD /* MyModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MyModel.xcdatamodel; sourceTree = ""; }; + 457C26C3139A18CE00BF00DD /* ModelObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelObject.h; path = ../../../code/ModelObject.h; sourceTree = ""; }; + 457C26C4139A18CE00BF00DD /* ModelObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelObject.m; path = ../../../code/ModelObject.m; sourceTree = ""; }; + 4584D3F9139A9D360035BCA5 /* _ModelAssistant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelAssistant.h; path = Sources/DataModel/_ModelAssistant.h; sourceTree = SOURCE_ROOT; }; + 4584D3FA139A9D360035BCA5 /* _ModelAssistant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelAssistant.m; path = Sources/DataModel/_ModelAssistant.m; sourceTree = SOURCE_ROOT; }; + 4584D3FB139A9D360035BCA5 /* _ModelCompany.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelCompany.h; path = Sources/DataModel/_ModelCompany.h; sourceTree = SOURCE_ROOT; }; + 4584D3FC139A9D360035BCA5 /* _ModelCompany.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelCompany.m; path = Sources/DataModel/_ModelCompany.m; sourceTree = SOURCE_ROOT; }; + 4584D3FD139A9D360035BCA5 /* _ModelDepartment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelDepartment.h; path = Sources/DataModel/_ModelDepartment.h; sourceTree = SOURCE_ROOT; }; + 4584D3FE139A9D360035BCA5 /* _ModelDepartment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelDepartment.m; path = Sources/DataModel/_ModelDepartment.m; sourceTree = SOURCE_ROOT; }; + 4584D3FF139A9D360035BCA5 /* _ModelDepartmentAssistant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelDepartmentAssistant.h; path = Sources/DataModel/_ModelDepartmentAssistant.h; sourceTree = SOURCE_ROOT; }; + 4584D400139A9D360035BCA5 /* _ModelDepartmentAssistant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelDepartmentAssistant.m; path = Sources/DataModel/_ModelDepartmentAssistant.m; sourceTree = SOURCE_ROOT; }; + 4584D401139A9D360035BCA5 /* _ModelDepartmentEmployee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelDepartmentEmployee.h; path = Sources/DataModel/_ModelDepartmentEmployee.h; sourceTree = SOURCE_ROOT; }; + 4584D402139A9D360035BCA5 /* _ModelDepartmentEmployee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelDepartmentEmployee.m; path = Sources/DataModel/_ModelDepartmentEmployee.m; sourceTree = SOURCE_ROOT; }; + 4584D403139A9D360035BCA5 /* _ModelEmployee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _ModelEmployee.h; path = Sources/DataModel/_ModelEmployee.h; sourceTree = SOURCE_ROOT; }; + 4584D404139A9D360035BCA5 /* _ModelEmployee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _ModelEmployee.m; path = Sources/DataModel/_ModelEmployee.m; sourceTree = SOURCE_ROOT; }; + 4584D405139A9D360035BCA5 /* ModelAssistant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelAssistant.h; path = Sources/DataModel/ModelAssistant.h; sourceTree = SOURCE_ROOT; }; + 4584D406139A9D360035BCA5 /* ModelAssistant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelAssistant.m; path = Sources/DataModel/ModelAssistant.m; sourceTree = SOURCE_ROOT; }; + 4584D407139A9D360035BCA5 /* ModelCompany.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelCompany.h; path = Sources/DataModel/ModelCompany.h; sourceTree = SOURCE_ROOT; }; + 4584D408139A9D360035BCA5 /* ModelCompany.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelCompany.m; path = Sources/DataModel/ModelCompany.m; sourceTree = SOURCE_ROOT; }; + 4584D409139A9D360035BCA5 /* ModelDepartment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelDepartment.h; path = Sources/DataModel/ModelDepartment.h; sourceTree = SOURCE_ROOT; }; + 4584D40A139A9D360035BCA5 /* ModelDepartment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelDepartment.m; path = Sources/DataModel/ModelDepartment.m; sourceTree = SOURCE_ROOT; }; + 4584D40B139A9D360035BCA5 /* ModelDepartmentAssistant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelDepartmentAssistant.h; path = Sources/DataModel/ModelDepartmentAssistant.h; sourceTree = SOURCE_ROOT; }; + 4584D40C139A9D360035BCA5 /* ModelDepartmentAssistant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelDepartmentAssistant.m; path = Sources/DataModel/ModelDepartmentAssistant.m; sourceTree = SOURCE_ROOT; }; + 4584D40D139A9D360035BCA5 /* ModelDepartmentEmployee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelDepartmentEmployee.h; path = Sources/DataModel/ModelDepartmentEmployee.h; sourceTree = SOURCE_ROOT; }; + 4584D40E139A9D360035BCA5 /* ModelDepartmentEmployee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelDepartmentEmployee.m; path = Sources/DataModel/ModelDepartmentEmployee.m; sourceTree = SOURCE_ROOT; }; + 4584D40F139A9D360035BCA5 /* ModelEmployee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelEmployee.h; path = Sources/DataModel/ModelEmployee.h; sourceTree = SOURCE_ROOT; }; + 4584D410139A9D360035BCA5 /* ModelEmployee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ModelEmployee.m; path = Sources/DataModel/ModelEmployee.m; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 457C26851399FAC600BF00DD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 457C268D1399FAC600BF00DD /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 457C267D1399FAC600BF00DD = { + isa = PBXGroup; + children = ( + 457C26991399FB1E00BF00DD /* MyModel.xcdatamodeld */, + 457C268E1399FAC600BF00DD /* PonsoTest */, + 457C268B1399FAC600BF00DD /* Frameworks */, + 457C26891399FAC600BF00DD /* Products */, + ); + sourceTree = ""; + }; + 457C26891399FAC600BF00DD /* Products */ = { + isa = PBXGroup; + children = ( + 457C26881399FAC600BF00DD /* PonsoTest */, + ); + name = Products; + sourceTree = ""; + }; + 457C268B1399FAC600BF00DD /* Frameworks */ = { + isa = PBXGroup; + children = ( + 457C268C1399FAC600BF00DD /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 457C268E1399FAC600BF00DD /* PonsoTest */ = { + isa = PBXGroup; + children = ( + 457C268F1399FAC600BF00DD /* main.m */, + 457C26C3139A18CE00BF00DD /* ModelObject.h */, + 457C26C4139A18CE00BF00DD /* ModelObject.m */, + 457C26AF139A188D00BF00DD /* Data Model */, + 457C26911399FAC600BF00DD /* Supporting Files */, + ); + path = PonsoTest; + sourceTree = ""; + }; + 457C26911399FAC600BF00DD /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 457C26921399FAC600BF00DD /* PonsoTest-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 457C26AF139A188D00BF00DD /* Data Model */ = { + isa = PBXGroup; + children = ( + 4584D3F9139A9D360035BCA5 /* _ModelAssistant.h */, + 4584D3FA139A9D360035BCA5 /* _ModelAssistant.m */, + 4584D3FB139A9D360035BCA5 /* _ModelCompany.h */, + 4584D3FC139A9D360035BCA5 /* _ModelCompany.m */, + 4584D3FD139A9D360035BCA5 /* _ModelDepartment.h */, + 4584D3FE139A9D360035BCA5 /* _ModelDepartment.m */, + 4584D3FF139A9D360035BCA5 /* _ModelDepartmentAssistant.h */, + 4584D400139A9D360035BCA5 /* _ModelDepartmentAssistant.m */, + 4584D401139A9D360035BCA5 /* _ModelDepartmentEmployee.h */, + 4584D402139A9D360035BCA5 /* _ModelDepartmentEmployee.m */, + 4584D403139A9D360035BCA5 /* _ModelEmployee.h */, + 4584D404139A9D360035BCA5 /* _ModelEmployee.m */, + 4584D405139A9D360035BCA5 /* ModelAssistant.h */, + 4584D406139A9D360035BCA5 /* ModelAssistant.m */, + 4584D407139A9D360035BCA5 /* ModelCompany.h */, + 4584D408139A9D360035BCA5 /* ModelCompany.m */, + 4584D409139A9D360035BCA5 /* ModelDepartment.h */, + 4584D40A139A9D360035BCA5 /* ModelDepartment.m */, + 4584D40B139A9D360035BCA5 /* ModelDepartmentAssistant.h */, + 4584D40C139A9D360035BCA5 /* ModelDepartmentAssistant.m */, + 4584D40D139A9D360035BCA5 /* ModelDepartmentEmployee.h */, + 4584D40E139A9D360035BCA5 /* ModelDepartmentEmployee.m */, + 4584D40F139A9D360035BCA5 /* ModelEmployee.h */, + 4584D410139A9D360035BCA5 /* ModelEmployee.m */, + ); + name = "Data Model"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 457C26871399FAC600BF00DD /* PonsoTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 457C26961399FAC600BF00DD /* Build configuration list for PBXNativeTarget "PonsoTest" */; + buildPhases = ( + 457C269C1399FC7000BF00DD /* ShellScript */, + 457C26841399FAC600BF00DD /* Sources */, + 457C26851399FAC600BF00DD /* Frameworks */, + 457C26861399FAC600BF00DD /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PonsoTest; + productName = PonsoTest; + productReference = 457C26881399FAC600BF00DD /* PonsoTest */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 457C267F1399FAC600BF00DD /* Project object */ = { + isa = PBXProject; + attributes = { + ORGANIZATIONNAME = "@nzhuk"; + }; + buildConfigurationList = 457C26821399FAC600BF00DD /* Build configuration list for PBXProject "PonsoTest" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 457C267D1399FAC600BF00DD; + productRefGroup = 457C26891399FAC600BF00DD /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 457C26871399FAC600BF00DD /* PonsoTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXShellScriptBuildPhase section */ + 457C269C1399FC7000BF00DD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "### Settings\n\nDATA_MODEL_FILE=\"$PROJECT_DIR/MyModel.xcdatamodeld/MyModel.xcdatamodel\"\nDATA_MODEL_SOURCE_DIR=\"$PROJECT_DIR/Sources/DataModel\"\n\nBASE_CLASS=\"ModelObject\"\n\nMOGENERATOR_DIR=\"$PROJECT_DIR/../../../../../\"\nMOGENERATOR_BIN=\"$MOGENERATOR_DIR/mogenerator\" ## Adjust this so that it points to a compiled mogenerator binary.\nMOGENERATOR_TEMPLATES=\"$MOGENERATOR_DIR/contributed templates/Nikita Zhuk/ponso/templates\"\n\n### Logic\n\nsource \"$MOGENERATOR_DIR/ponso/generate.sh\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 457C26841399FAC600BF00DD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 457C26901399FAC600BF00DD /* main.m in Sources */, + 457C26C5139A18CE00BF00DD /* ModelObject.m in Sources */, + 4584D411139A9D360035BCA5 /* _ModelAssistant.m in Sources */, + 4584D412139A9D360035BCA5 /* _ModelCompany.m in Sources */, + 4584D413139A9D360035BCA5 /* _ModelDepartment.m in Sources */, + 4584D414139A9D360035BCA5 /* _ModelDepartmentAssistant.m in Sources */, + 4584D415139A9D360035BCA5 /* _ModelDepartmentEmployee.m in Sources */, + 4584D416139A9D360035BCA5 /* _ModelEmployee.m in Sources */, + 4584D417139A9D360035BCA5 /* ModelAssistant.m in Sources */, + 4584D418139A9D360035BCA5 /* ModelCompany.m in Sources */, + 4584D419139A9D360035BCA5 /* ModelDepartment.m in Sources */, + 4584D41A139A9D360035BCA5 /* ModelDepartmentAssistant.m in Sources */, + 4584D41B139A9D360035BCA5 /* ModelDepartmentEmployee.m in Sources */, + 4584D41C139A9D360035BCA5 /* ModelEmployee.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 457C26941399FAC600BF00DD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.6; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 457C26951399FAC600BF00DD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.6; + SDKROOT = macosx; + }; + name = Release; + }; + 457C26971399FAC600BF00DD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PonsoTest/PonsoTest-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 457C26981399FAC600BF00DD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "PonsoTest/PonsoTest-Prefix.pch"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 457C26821399FAC600BF00DD /* Build configuration list for PBXProject "PonsoTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 457C26941399FAC600BF00DD /* Debug */, + 457C26951399FAC600BF00DD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 457C26961399FAC600BF00DD /* Build configuration list for PBXNativeTarget "PonsoTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 457C26971399FAC600BF00DD /* Debug */, + 457C26981399FAC600BF00DD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 457C26991399FB1E00BF00DD /* MyModel.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 457C269A1399FB1E00BF00DD /* MyModel.xcdatamodel */, + ); + currentVersion = 457C269A1399FB1E00BF00DD /* MyModel.xcdatamodel */; + path = MyModel.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = 457C267F1399FAC600BF00DD /* Project object */; +} diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..26965267 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch new file mode 100644 index 00000000..0053d9e3 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'PonsoTest' target in the 'PonsoTest' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/main.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/main.m new file mode 100644 index 00000000..11c48033 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/main.m @@ -0,0 +1,134 @@ + /* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + main.m + mogenerator / PONSO + Created by Nikita Zhuk on 22.1.2011. + */ + +#import +#import "ModelCompany.h" +#import "ModelDepartment.h" +#import "ModelDepartmentAssistant.h" +#import "ModelDepartmentEmployee.h" +#import "ModelEmployee.h" +#import "ModelAssistant.h" + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + ModelCompany *company1 = [[[ModelCompany alloc] init] autorelease]; + company1.name = @"Our company"; + company1.yearFoundedValue = 2003; + + ModelEmployee *emp1 = [[[ModelEmployee alloc] init] autorelease]; + ModelEmployee *emp2 = [[[ModelEmployee alloc] init] autorelease]; + + emp1.name = @"John The Engineer"; + emp1.birthDate = [NSDate dateWithTimeIntervalSince1970:60*60]; + emp1.isOnVacationValue = YES; + + emp2.name = @"Mike The Tester"; + + ModelAssistant *as1 = [[[ModelAssistant alloc] init] autorelease]; + ModelAssistant *as2 = [[[ModelAssistant alloc] init] autorelease]; + + as1.name = @"First assistant"; + as1.birthDate = [NSDate date]; + + as2.name = @"Second assistant"; + as2.birthDate = [NSDate date]; + + [company1 addEmployeesObject:emp1]; + [company1 addEmployeesObject:emp2]; + [company1 addAssistantsObject:as1]; + [company1 addAssistantsObject:as2]; + + emp1.assistant = as2; + as2.boss = emp1; // Currently one-to-one relationships' inverse must be set manually + + emp2.assistant = as1; + as1.boss = emp2; // Currently one-to-one relationships' inverse must be set manually + + ModelDepartment *dep1 = [[[ModelDepartment alloc] init] autorelease]; + ModelDepartment *dep2 = [[[ModelDepartment alloc] init] autorelease]; + dep1.name = @"R&D Department"; + dep2.name = @"QA Department"; + + // Setup workers of dep1 + ModelDepartmentEmployee *depEmp1 = [[[ModelDepartmentEmployee alloc] init] autorelease]; + depEmp1.employee = emp1; + depEmp1.startedWorking = [NSDate dateWithTimeIntervalSince1970:10000]; + [dep1 addEmployeesObject:depEmp1]; + + ModelDepartmentEmployee *depEmp2 = [[[ModelDepartmentEmployee alloc] init] autorelease]; + depEmp2.employee = emp2; + depEmp2.startedWorking = [NSDate dateWithTimeIntervalSince1970:20000]; + [dep1 addEmployeesObject:depEmp2]; + + ModelDepartmentAssistant *depAs1 = [[[ModelDepartmentAssistant alloc] init] autorelease]; + depAs1.assistant = as1; + depAs1.startedWorking = [NSDate dateWithTimeIntervalSince1970:30000]; + [dep1 addAssistantsObject:depAs1]; + + // Setup workers of dep2 + depEmp2 = [[[ModelDepartmentEmployee alloc] init] autorelease]; + depEmp2.employee = emp2; + depEmp2.startedWorking = [NSDate dateWithTimeIntervalSince1970:40000]; + [dep2 addEmployeesObject:depEmp2]; + + depAs1 = [[[ModelDepartmentAssistant alloc] init] autorelease]; + depAs1.assistant = as1; + depAs1.startedWorking = [NSDate dateWithTimeIntervalSince1970:50000]; + [dep2 addAssistantsObject:depAs1]; + + ModelDepartmentAssistant *depAs2 = [[[ModelDepartmentAssistant alloc] init] autorelease]; + depAs2.assistant = as2; + depAs2.startedWorking = [NSDate dateWithTimeIntervalSince1970:60000]; + [dep2 addAssistantsObject:depAs2]; + + [company1 addDepartmentsObject:dep1]; + [company1 addDepartmentsObject:dep2]; + + // Test NSDictionary serialization + ModelCompany *recreatedCompany = [[[ModelCompany alloc] initWithDictionaryRepresentation:[company1 dictionaryRepresentation]] autorelease]; + [recreatedCompany awakeFromDictionaryRepresentationInit]; + + NSDictionary *recreatedCompanyDict = [recreatedCompany dictionaryRepresentation]; + + NSLog(@"%@", [company1 dictionaryRepresentation]); + NSLog(@"%@", recreatedCompanyDict); + + NSCAssert([recreatedCompanyDict isEqualToDictionary:[company1 dictionaryRepresentation]], @"ModelCompany serialization roundtrip failed."); + NSCAssert([recreatedCompany.employees count] == 2, @""); + NSCAssert([recreatedCompany.assistants count] == 2, @""); + NSCAssert([recreatedCompany.departments count] == 2, @""); + + // Test file serialization (uses NSDictionary) + NSString *tempFile = [[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]] stringByAppendingPathExtension:@"ponso-temp-plist"]; + BOOL result = [company1 writeToFile:tempFile]; + NSCAssert(result, @""); + + ModelCompany *recreatedCompany2 = [ModelCompany createModelObjectFromFile:tempFile]; + NSDictionary *recreatedCompany2Dict = [recreatedCompany2 dictionaryRepresentation]; + [[NSFileManager defaultManager] removeItemAtPath:tempFile error:nil]; + + NSCAssert([recreatedCompany2Dict isEqualToDictionary:[company1 dictionaryRepresentation]], @"ModelCompany serialization roundtrip failed."); + + [pool drain]; + return 0; +} + diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h new file mode 100644 index 00000000..0ab0bbce --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h @@ -0,0 +1,11 @@ +// +// ModelAssistant.h +// +// $Id$ +// + +#import "_ModelAssistant.h" + +@interface ModelAssistant : _ModelAssistant <_ModelAssistant> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m new file mode 100644 index 00000000..e8b070a7 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m @@ -0,0 +1,18 @@ +// +// ModelAssistant.m +// +// $Id$ +// + +#import "ModelAssistant.h" + +@implementation ModelAssistant + +#pragma mark Abstract method overrides + + + + +// Custom logic goes here. + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h new file mode 100644 index 00000000..c5c08b32 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h @@ -0,0 +1,11 @@ +// +// ModelCompany.h +// +// $Id$ +// + +#import "_ModelCompany.h" + +@interface ModelCompany : _ModelCompany <_ModelCompany> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m new file mode 100644 index 00000000..c5ebd291 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m @@ -0,0 +1,18 @@ +// +// ModelCompany.m +// +// $Id$ +// + +#import "ModelCompany.h" + +@implementation ModelCompany + +#pragma mark Abstract method overrides + + + + +// Custom logic goes here. + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h new file mode 100644 index 00000000..0a7f1048 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h @@ -0,0 +1,11 @@ +// +// ModelDepartment.h +// +// $Id$ +// + +#import "_ModelDepartment.h" + +@interface ModelDepartment : _ModelDepartment <_ModelDepartment> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m new file mode 100644 index 00000000..e092a052 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m @@ -0,0 +1,18 @@ +// +// ModelDepartment.m +// +// $Id$ +// + +#import "ModelDepartment.h" + +@implementation ModelDepartment + +#pragma mark Abstract method overrides + + + + +// Custom logic goes here. + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h new file mode 100644 index 00000000..e2952c3c --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h @@ -0,0 +1,11 @@ +// +// ModelDepartmentAssistant.h +// +// $Id$ +// + +#import "_ModelDepartmentAssistant.h" + +@interface ModelDepartmentAssistant : _ModelDepartmentAssistant <_ModelDepartmentAssistant> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m new file mode 100644 index 00000000..b15109ee --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m @@ -0,0 +1,23 @@ +// +// ModelDepartmentAssistant.m +// +// $Id$ +// + +#import "ModelDepartmentAssistant.h" +#import "ModelDepartment.h" +#import "ModelCompany.h" + +@implementation ModelDepartmentAssistant + +#pragma mark Abstract method overrides + + +- (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID +{ + NSAssert(self.department.company != nil, @""); + + return [[self.department.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; +} + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h new file mode 100644 index 00000000..043e710d --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h @@ -0,0 +1,11 @@ +// +// ModelDepartmentEmployee.h +// +// $Id$ +// + +#import "_ModelDepartmentEmployee.h" + +@interface ModelDepartmentEmployee : _ModelDepartmentEmployee <_ModelDepartmentEmployee> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m new file mode 100644 index 00000000..3bd85786 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m @@ -0,0 +1,23 @@ +// +// ModelDepartmentEmployee.m +// +// $Id$ +// + +#import "ModelDepartmentEmployee.h" +#import "ModelDepartment.h" +#import "ModelCompany.h" + +@implementation ModelDepartmentEmployee + +#pragma mark Abstract method overrides + + +- (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID +{ + NSAssert(self.department.company != nil, @""); + + return [[self.department.company.employees filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; +} + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h new file mode 100644 index 00000000..4b19be77 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h @@ -0,0 +1,11 @@ +// +// ModelEmployee.h +// +// $Id$ +// + +#import "_ModelEmployee.h" + +@interface ModelEmployee : _ModelEmployee <_ModelEmployee> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m new file mode 100644 index 00000000..29d0a48f --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m @@ -0,0 +1,21 @@ +// +// ModelEmployee.m +// +// $Id$ +// + +#import "ModelEmployee.h" +#import "ModelCompany.h" + +@implementation ModelEmployee + +#pragma mark Abstract method overrides + +- (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID +{ + NSAssert(self.company != nil, @""); + + return [[self.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; +} + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h new file mode 100644 index 00000000..bf8efc97 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h @@ -0,0 +1,55 @@ +// +// ModelAssistant.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelAssistant.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelEmployee; +@class ModelCompany; +@class ModelDepartmentAssistant; + + +@protocol _ModelAssistant + +@end + + +@interface _ModelAssistant : ModelObject +{ + NSDate *birthDate; + NSString *name; + + + ModelEmployee *boss; + + ModelCompany *company; + + NSArray *departments; + +} + +@property (nonatomic, retain, readwrite) NSDate *birthDate; +@property (nonatomic, retain, readwrite) NSString *name; + +@property (nonatomic, assign, readwrite) ModelEmployee *boss; + +@property (nonatomic, assign, readwrite) ModelCompany *company; + +@property (nonatomic, retain, readonly) NSArray *departments; + + + + +- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_; +- (void)removeDepartmentsObjects; +- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_; + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m new file mode 100644 index 00000000..af892a87 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m @@ -0,0 +1,139 @@ +// +// ModelAssistant.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelAssistant.h instead. +// + +#import "_ModelAssistant.h" + +#import "ModelEmployee.h" +#import "ModelCompany.h" +#import "ModelDepartmentAssistant.h" + + +@interface _ModelAssistant() +@property (nonatomic, retain, readwrite) NSArray *departments; + +@end + +/** \ingroup DataModel */ + +@implementation _ModelAssistant + +- (id)init +{ + if((self = [super init])) + { + + } + + return self; +} + +#pragma mark Scalar values + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.birthDate = [dictionary objectForKey:@"ModelAssistant.birthDate"]; + self.name = [dictionary objectForKey:@"ModelAssistant.name"]; + + + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.birthDate forKey:@"ModelAssistant.birthDate"]; + [dict setObjectIfNotNil:self.name forKey:@"ModelAssistant.name"]; + + + + + + + + + + if([self.departments count] > 0) + { + + } + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + + + + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + +- (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_ +{ + if(self.departments == nil) + { + self.departments = [NSMutableArray array]; + } + + [(NSMutableArray *)self.departments addObject:value_]; + value_.assistant = (ModelAssistant*)self; +} + +- (void)removeDepartmentsObjects +{ + self.departments = [NSMutableArray array]; +} + +- (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_ +{ + value_.assistant = nil; + [(NSMutableArray *)self.departments removeObject:value_]; +} + + + +- (void)dealloc +{ + self.birthDate = nil; + self.name = nil; + + self.boss = nil; + self.company = nil; + self.departments = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize birthDate; +@synthesize name; + +@synthesize boss; +@synthesize company; +@synthesize departments; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h new file mode 100644 index 00000000..b4eedaa2 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h @@ -0,0 +1,60 @@ +// +// ModelCompany.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelCompany.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelAssistant; +@class ModelDepartment; +@class ModelEmployee; + + +@protocol _ModelCompany + +@end + + +@interface _ModelCompany : ModelObject +{ + NSString *name; + NSNumber *yearFounded; + + + NSArray *assistants; + + NSArray *departments; + + NSArray *employees; + +} + +@property (nonatomic, retain, readwrite) NSString *name; +@property (nonatomic, retain, readwrite) NSNumber *yearFounded; +@property (nonatomic, assign, readwrite) int yearFoundedValue; + +@property (nonatomic, retain, readonly) NSArray *assistants; +@property (nonatomic, retain, readonly) NSArray *departments; +@property (nonatomic, retain, readonly) NSArray *employees; + + +- (void)addAssistantsObject:(ModelAssistant*)value_; +- (void)removeAssistantsObjects; +- (void)removeAssistantsObject:(ModelAssistant*)value_; + +- (void)addDepartmentsObject:(ModelDepartment*)value_; +- (void)removeDepartmentsObjects; +- (void)removeDepartmentsObject:(ModelDepartment*)value_; + +- (void)addEmployeesObject:(ModelEmployee*)value_; +- (void)removeEmployeesObjects; +- (void)removeEmployeesObject:(ModelEmployee*)value_; + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.m new file mode 100644 index 00000000..119cb68d --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.m @@ -0,0 +1,250 @@ +// +// ModelCompany.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelCompany.h instead. +// + +#import "_ModelCompany.h" + +#import "ModelAssistant.h" +#import "ModelDepartment.h" +#import "ModelEmployee.h" + + +@interface _ModelCompany() +@property (nonatomic, retain, readwrite) NSArray *assistants; +@property (nonatomic, retain, readwrite) NSArray *departments; +@property (nonatomic, retain, readwrite) NSArray *employees; + +@end + +/** \ingroup DataModel */ + +@implementation _ModelCompany + +- (id)init +{ + if((self = [super init])) + { + + } + + return self; +} + +#pragma mark Scalar values + +- (int)yearFoundedValue +{ + return [self.yearFounded intValue]; +} + +- (void)setYearFoundedValue:(int)value_ +{ + self.yearFounded = [NSNumber numberWithInt:value_]; +} + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.name = [dictionary objectForKey:@"ModelCompany.name"]; + self.yearFounded = [dictionary objectForKey:@"ModelCompany.yearFounded"]; + + + for(id objectRepresentationForDict in [dictionary objectForKey:@"ModelCompany.assistants"]) + { + ModelAssistant *assistantsObj = [[[ModelAssistant alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self addAssistantsObject:assistantsObj]; + } + for(id objectRepresentationForDict in [dictionary objectForKey:@"ModelCompany.departments"]) + { + ModelDepartment *departmentsObj = [[[ModelDepartment alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self addDepartmentsObject:departmentsObj]; + } + for(id objectRepresentationForDict in [dictionary objectForKey:@"ModelCompany.employees"]) + { + ModelEmployee *employeesObj = [[[ModelEmployee alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self addEmployeesObject:employeesObj]; + } + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.name forKey:@"ModelCompany.name"]; + [dict setObjectIfNotNil:self.yearFounded forKey:@"ModelCompany.yearFounded"]; + + if([self.assistants count] > 0) + { + + NSMutableArray *assistantsRepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.assistants count]]; + for(ModelAssistant *obj in self.assistants) + { + [assistantsRepresentationsForDictionary addObject:[obj dictionaryRepresentation]]; + } + [dict setObjectIfNotNil:assistantsRepresentationsForDictionary forKey:@"ModelCompany.assistants"]; + + } + + if([self.departments count] > 0) + { + + NSMutableArray *departmentsRepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.departments count]]; + for(ModelDepartment *obj in self.departments) + { + [departmentsRepresentationsForDictionary addObject:[obj dictionaryRepresentation]]; + } + [dict setObjectIfNotNil:departmentsRepresentationsForDictionary forKey:@"ModelCompany.departments"]; + + } + + if([self.employees count] > 0) + { + + NSMutableArray *employeesRepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.employees count]]; + for(ModelEmployee *obj in self.employees) + { + [employeesRepresentationsForDictionary addObject:[obj dictionaryRepresentation]]; + } + [dict setObjectIfNotNil:employeesRepresentationsForDictionary forKey:@"ModelCompany.employees"]; + + } + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + + + + + for(ModelDepartment *departmentsObj in self.departments) + { + [departmentsObj awakeFromDictionaryRepresentationInit]; + } + + for(ModelAssistant *assistantsObj in self.assistants) + { + [assistantsObj awakeFromDictionaryRepresentationInit]; + } + + for(ModelEmployee *employeesObj in self.employees) + { + [employeesObj awakeFromDictionaryRepresentationInit]; + } + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + +- (void)addAssistantsObject:(ModelAssistant*)value_ +{ + if(self.assistants == nil) + { + self.assistants = [NSMutableArray array]; + } + + [(NSMutableArray *)self.assistants addObject:value_]; + value_.company = (ModelCompany*)self; +} + +- (void)removeAssistantsObjects +{ + self.assistants = [NSMutableArray array]; +} + +- (void)removeAssistantsObject:(ModelAssistant*)value_ +{ + value_.company = nil; + [(NSMutableArray *)self.assistants removeObject:value_]; +} + + +- (void)addDepartmentsObject:(ModelDepartment*)value_ +{ + if(self.departments == nil) + { + self.departments = [NSMutableArray array]; + } + + [(NSMutableArray *)self.departments addObject:value_]; + value_.company = (ModelCompany*)self; +} + +- (void)removeDepartmentsObjects +{ + self.departments = [NSMutableArray array]; +} + +- (void)removeDepartmentsObject:(ModelDepartment*)value_ +{ + value_.company = nil; + [(NSMutableArray *)self.departments removeObject:value_]; +} + + +- (void)addEmployeesObject:(ModelEmployee*)value_ +{ + if(self.employees == nil) + { + self.employees = [NSMutableArray array]; + } + + [(NSMutableArray *)self.employees addObject:value_]; + value_.company = (ModelCompany*)self; +} + +- (void)removeEmployeesObjects +{ + self.employees = [NSMutableArray array]; +} + +- (void)removeEmployeesObject:(ModelEmployee*)value_ +{ + value_.company = nil; + [(NSMutableArray *)self.employees removeObject:value_]; +} + + + +- (void)dealloc +{ + self.name = nil; + self.yearFounded = nil; + + self.assistants = nil; + self.departments = nil; + self.employees = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize name; +@synthesize yearFounded; + +@synthesize assistants; +@synthesize departments; +@synthesize employees; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h new file mode 100644 index 00000000..77c6eb15 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h @@ -0,0 +1,55 @@ +// +// ModelDepartment.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartment.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelDepartmentAssistant; +@class ModelCompany; +@class ModelDepartmentEmployee; + + +@protocol _ModelDepartment + +@end + + +@interface _ModelDepartment : ModelObject +{ + NSString *name; + + + NSArray *assistants; + + ModelCompany *company; + + NSArray *employees; + +} + +@property (nonatomic, retain, readwrite) NSString *name; + +@property (nonatomic, retain, readonly) NSArray *assistants; +@property (nonatomic, assign, readwrite) ModelCompany *company; + +@property (nonatomic, retain, readonly) NSArray *employees; + + +- (void)addAssistantsObject:(ModelDepartmentAssistant*)value_; +- (void)removeAssistantsObjects; +- (void)removeAssistantsObject:(ModelDepartmentAssistant*)value_; + + +- (void)addEmployeesObject:(ModelDepartmentEmployee*)value_; +- (void)removeEmployeesObjects; +- (void)removeEmployeesObject:(ModelDepartmentEmployee*)value_; + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.m new file mode 100644 index 00000000..f11595db --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.m @@ -0,0 +1,194 @@ +// +// ModelDepartment.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartment.h instead. +// + +#import "_ModelDepartment.h" + +#import "ModelDepartmentAssistant.h" +#import "ModelCompany.h" +#import "ModelDepartmentEmployee.h" + + +@interface _ModelDepartment() +@property (nonatomic, retain, readwrite) NSArray *assistants; +@property (nonatomic, retain, readwrite) NSArray *employees; + +@end + +/** \ingroup DataModel */ + +@implementation _ModelDepartment + +- (id)init +{ + if((self = [super init])) + { + + } + + return self; +} + +#pragma mark Scalar values + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.name = [dictionary objectForKey:@"ModelDepartment.name"]; + + + for(id objectRepresentationForDict in [dictionary objectForKey:@"ModelDepartment.assistants"]) + { + ModelDepartmentAssistant *assistantsObj = [[[ModelDepartmentAssistant alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self addAssistantsObject:assistantsObj]; + } + for(id objectRepresentationForDict in [dictionary objectForKey:@"ModelDepartment.employees"]) + { + ModelDepartmentEmployee *employeesObj = [[[ModelDepartmentEmployee alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self addEmployeesObject:employeesObj]; + } + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.name forKey:@"ModelDepartment.name"]; + + if([self.assistants count] > 0) + { + + NSMutableArray *assistantsRepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.assistants count]]; + for(ModelDepartmentAssistant *obj in self.assistants) + { + [assistantsRepresentationsForDictionary addObject:[obj dictionaryRepresentation]]; + } + [dict setObjectIfNotNil:assistantsRepresentationsForDictionary forKey:@"ModelDepartment.assistants"]; + + } + + + + + + if([self.employees count] > 0) + { + + NSMutableArray *employeesRepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.employees count]]; + for(ModelDepartmentEmployee *obj in self.employees) + { + [employeesRepresentationsForDictionary addObject:[obj dictionaryRepresentation]]; + } + [dict setObjectIfNotNil:employeesRepresentationsForDictionary forKey:@"ModelDepartment.employees"]; + + } + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + + + + + for(ModelDepartmentEmployee *employeesObj in self.employees) + { + [employeesObj awakeFromDictionaryRepresentationInit]; + } + + for(ModelDepartmentAssistant *assistantsObj in self.assistants) + { + [assistantsObj awakeFromDictionaryRepresentationInit]; + } + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + +- (void)addAssistantsObject:(ModelDepartmentAssistant*)value_ +{ + if(self.assistants == nil) + { + self.assistants = [NSMutableArray array]; + } + + [(NSMutableArray *)self.assistants addObject:value_]; + value_.department = (ModelDepartment*)self; +} + +- (void)removeAssistantsObjects +{ + self.assistants = [NSMutableArray array]; +} + +- (void)removeAssistantsObject:(ModelDepartmentAssistant*)value_ +{ + value_.department = nil; + [(NSMutableArray *)self.assistants removeObject:value_]; +} + + +- (void)addEmployeesObject:(ModelDepartmentEmployee*)value_ +{ + if(self.employees == nil) + { + self.employees = [NSMutableArray array]; + } + + [(NSMutableArray *)self.employees addObject:value_]; + value_.department = (ModelDepartment*)self; +} + +- (void)removeEmployeesObjects +{ + self.employees = [NSMutableArray array]; +} + +- (void)removeEmployeesObject:(ModelDepartmentEmployee*)value_ +{ + value_.department = nil; + [(NSMutableArray *)self.employees removeObject:value_]; +} + + + +- (void)dealloc +{ + self.name = nil; + + self.assistants = nil; + self.company = nil; + self.employees = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize name; + +@synthesize assistants; +@synthesize company; +@synthesize employees; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h new file mode 100644 index 00000000..4b6bae73 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h @@ -0,0 +1,46 @@ +// +// ModelDepartmentAssistant.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartmentAssistant.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelAssistant; +@class ModelDepartment; + + +@protocol _ModelDepartmentAssistant + +- (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; + +@end + + +@interface _ModelDepartmentAssistant : ModelObject +{ + NSDate *startedWorking; + + + ModelAssistant *assistant; + + ModelDepartment *department; + +} + +@property (nonatomic, retain, readwrite) NSDate *startedWorking; + +@property (nonatomic, retain, readwrite) ModelAssistant *assistant; +@property (nonatomic, assign, readwrite) ModelDepartment *department; + + + + + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m new file mode 100644 index 00000000..5bdad3e1 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m @@ -0,0 +1,107 @@ +// +// ModelDepartmentAssistant.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartmentAssistant.h instead. +// + +#import "_ModelDepartmentAssistant.h" + +#import "ModelAssistant.h" +#import "ModelDepartment.h" + + +@interface _ModelDepartmentAssistant() + +@end + +/** \ingroup DataModel */ + +@implementation _ModelDepartmentAssistant + +- (id)init +{ + if((self = [super init])) + { + + } + + return self; +} + +#pragma mark Scalar values + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.startedWorking = [dictionary objectForKey:@"ModelDepartmentAssistant.startedWorking"]; + + + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.startedWorking forKey:@"ModelDepartmentAssistant.startedWorking"]; + + + [dict setObjectIfNotNil:[self.assistant valueForKeyPath:@"name"] forKey:@"ModelDepartmentAssistant.assistant"]; + + + + + + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + self.assistant = [(_ModelDepartmentAssistant<_ModelDepartmentAssistant> *)self fetchAssistantObjectWithIDForAssistantRelationship:[self.sourceDictionaryRepresentation objectForKey:@"ModelDepartmentAssistant.assistant"]]; + [self.assistant addDepartmentsObject:(ModelDepartmentAssistant*)self]; + + + + + [self.assistant awakeFromDictionaryRepresentationInit]; + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + + +- (void)dealloc +{ + self.startedWorking = nil; + + self.assistant = nil; + self.department = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize startedWorking; + +@synthesize assistant; +@synthesize department; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h new file mode 100644 index 00000000..0f17e87d --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h @@ -0,0 +1,46 @@ +// +// ModelDepartmentEmployee.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartmentEmployee.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelDepartment; +@class ModelEmployee; + + +@protocol _ModelDepartmentEmployee + +- (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID; + +@end + + +@interface _ModelDepartmentEmployee : ModelObject +{ + NSDate *startedWorking; + + + ModelDepartment *department; + + ModelEmployee *employee; + +} + +@property (nonatomic, retain, readwrite) NSDate *startedWorking; + +@property (nonatomic, assign, readwrite) ModelDepartment *department; + +@property (nonatomic, retain, readwrite) ModelEmployee *employee; + + + + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m new file mode 100644 index 00000000..6046a41a --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m @@ -0,0 +1,107 @@ +// +// ModelDepartmentEmployee.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelDepartmentEmployee.h instead. +// + +#import "_ModelDepartmentEmployee.h" + +#import "ModelDepartment.h" +#import "ModelEmployee.h" + + +@interface _ModelDepartmentEmployee() + +@end + +/** \ingroup DataModel */ + +@implementation _ModelDepartmentEmployee + +- (id)init +{ + if((self = [super init])) + { + + } + + return self; +} + +#pragma mark Scalar values + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.startedWorking = [dictionary objectForKey:@"ModelDepartmentEmployee.startedWorking"]; + + + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.startedWorking forKey:@"ModelDepartmentEmployee.startedWorking"]; + + + + + + + [dict setObjectIfNotNil:[self.employee valueForKeyPath:@"name"] forKey:@"ModelDepartmentEmployee.employee"]; + + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + self.employee = [(_ModelDepartmentEmployee<_ModelDepartmentEmployee> *)self fetchEmployeeObjectWithIDForEmployeeRelationship:[self.sourceDictionaryRepresentation objectForKey:@"ModelDepartmentEmployee.employee"]]; + [self.employee addDepartmentsObject:(ModelDepartmentEmployee*)self]; + + + + + [self.employee awakeFromDictionaryRepresentationInit]; + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + + +- (void)dealloc +{ + self.startedWorking = nil; + + self.department = nil; + self.employee = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize startedWorking; + +@synthesize department; +@synthesize employee; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h new file mode 100644 index 00000000..84074f86 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h @@ -0,0 +1,59 @@ +// +// ModelEmployee.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelEmployee.h instead. +// + + +#import +#import "ModelObject.h" + +@class ModelAssistant; +@class ModelCompany; +@class ModelDepartmentEmployee; + + +@protocol _ModelEmployee + +- (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; + +@end + + +@interface _ModelEmployee : ModelObject +{ + NSDate *birthDate; + NSNumber *isOnVacation; + NSString *name; + + + ModelAssistant *assistant; + + ModelCompany *company; + + NSArray *departments; + +} + +@property (nonatomic, retain, readwrite) NSDate *birthDate; +@property (nonatomic, retain, readwrite) NSNumber *isOnVacation; +@property (nonatomic, assign, readwrite) BOOL isOnVacationValue; +@property (nonatomic, retain, readwrite) NSString *name; + +@property (nonatomic, retain, readwrite) ModelAssistant *assistant; +@property (nonatomic, assign, readwrite) ModelCompany *company; + +@property (nonatomic, retain, readonly) NSArray *departments; + + + + +- (void)addDepartmentsObject:(ModelDepartmentEmployee*)value_; +- (void)removeDepartmentsObjects; +- (void)removeDepartmentsObject:(ModelDepartmentEmployee*)value_; + + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.m b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.m new file mode 100644 index 00000000..0d68b3e3 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.m @@ -0,0 +1,159 @@ +// +// ModelEmployee.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to ModelEmployee.h instead. +// + +#import "_ModelEmployee.h" + +#import "ModelAssistant.h" +#import "ModelCompany.h" +#import "ModelDepartmentEmployee.h" + + +@interface _ModelEmployee() +@property (nonatomic, retain, readwrite) NSArray *departments; + +@end + +/** \ingroup DataModel */ + +@implementation _ModelEmployee + +- (id)init +{ + if((self = [super init])) + { + self.isOnVacation = [NSNumber numberWithBool:0]; + + } + + return self; +} + +#pragma mark Scalar values + +- (BOOL)isOnVacationValue +{ + return [self.isOnVacation boolValue]; +} + +- (void)setIsOnVacationValue:(BOOL)value_ +{ + self.isOnVacation = [NSNumber numberWithBool:value_]; +} + + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + self.birthDate = [dictionary objectForKey:@"ModelEmployee.birthDate"]; + self.isOnVacation = [dictionary objectForKey:@"ModelEmployee.isOnVacation"]; + self.name = [dictionary objectForKey:@"ModelEmployee.name"]; + + + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + [dict setObjectIfNotNil:self.birthDate forKey:@"ModelEmployee.birthDate"]; + [dict setObjectIfNotNil:self.isOnVacation forKey:@"ModelEmployee.isOnVacation"]; + [dict setObjectIfNotNil:self.name forKey:@"ModelEmployee.name"]; + + + [dict setObjectIfNotNil:[self.assistant valueForKeyPath:@"name"] forKey:@"ModelEmployee.assistant"]; + + + + + + + if([self.departments count] > 0) + { + + } + + + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + self.assistant = [(_ModelEmployee<_ModelEmployee> *)self fetchAssistantObjectWithIDForAssistantRelationship:[self.sourceDictionaryRepresentation objectForKey:@"ModelEmployee.assistant"]]; + self.assistant.boss = (ModelEmployee*)self; + + + + + + [self.assistant awakeFromDictionaryRepresentationInit]; + + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + + +- (void)addDepartmentsObject:(ModelDepartmentEmployee*)value_ +{ + if(self.departments == nil) + { + self.departments = [NSMutableArray array]; + } + + [(NSMutableArray *)self.departments addObject:value_]; + value_.employee = (ModelEmployee*)self; +} + +- (void)removeDepartmentsObjects +{ + self.departments = [NSMutableArray array]; +} + +- (void)removeDepartmentsObject:(ModelDepartmentEmployee*)value_ +{ + value_.employee = nil; + [(NSMutableArray *)self.departments removeObject:value_]; +} + + + +- (void)dealloc +{ + self.birthDate = nil; + self.isOnVacation = nil; + self.name = nil; + + self.assistant = nil; + self.company = nil; + self.departments = nil; + + [super dealloc]; +} + +#pragma mark Synthesizes + +@synthesize birthDate; +@synthesize isOnVacation; +@synthesize name; + +@synthesize assistant; +@synthesize company; +@synthesize departments; + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/templates/human.h.motemplate b/contributed templates/Nikita Zhuk/ponso/templates/human.h.motemplate new file mode 100755 index 00000000..8b4976d2 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/templates/human.h.motemplate @@ -0,0 +1,11 @@ +// +// <$managedObjectClassName$>.h +// +// $Id$ +// + +#import "_<$managedObjectClassName$>.h" + +@interface <$managedObjectClassName$> : _<$managedObjectClassName$> <_<$managedObjectClassName$>> +// Custom logic goes here. +@end diff --git a/contributed templates/Nikita Zhuk/ponso/templates/human.m.motemplate b/contributed templates/Nikita Zhuk/ponso/templates/human.m.motemplate new file mode 100755 index 00000000..dea65a11 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/templates/human.m.motemplate @@ -0,0 +1,24 @@ +// +// <$managedObjectClassName$>.m +// +// $Id$ +// + +#import "<$managedObjectClassName$>.h" + +@implementation <$managedObjectClassName$> + +#pragma mark Abstract method overrides + +<$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> +- (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID +{ + //! TODO: Return an object of type <$Relationship.destinationEntity.managedObjectClassName$> + return nil; +} +<$endif$><$endif$><$endforeach do$> + + +// Custom logic goes here. + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/templates/machine.h.motemplate b/contributed templates/Nikita Zhuk/ponso/templates/machine.h.motemplate new file mode 100755 index 00000000..96c76c74 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/templates/machine.h.motemplate @@ -0,0 +1,46 @@ +// +// <$managedObjectClassName$>.h +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to <$managedObjectClassName$>.h instead. +// + + +#import +#import "ModelObject.h" + +<$foreach Relationship noninheritedRelationships do$>@class <$Relationship.destinationEntity.managedObjectClassName$>; +<$endforeach do$> + +@protocol _<$managedObjectClassName$> +<$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> +- (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID; +<$endif$><$endif$><$endforeach do$> +@end + + +@interface _<$managedObjectClassName$> : <$customSuperentity$> +{ + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$Attribute.objectAttributeType$> *<$Attribute.name$>;<$endif$> + <$endforeach do$> + <$foreach Relationship noninheritedRelationships do$> + <$if Relationship.isToMany$>NSArray *<$Relationship.name$>;<$else$><$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>;<$endif$> + <$endforeach do$> +} + +<$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$>@property (nonatomic, retain, readwrite) <$Attribute.objectAttributeType$> *<$Attribute.name$>; +<$if Attribute.hasScalarAttributeType$>@property (nonatomic, assign, readwrite) <$Attribute.scalarAttributeType$> <$Attribute.name$>Value; +<$endif$><$endif$><$endforeach do$> +<$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$>@property (nonatomic, retain, readonly) NSArray *<$Relationship.name$>; +<$else$><$if Relationship.isTransient $>@property (nonatomic, assign, readwrite) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; +<$else$>@property (nonatomic, retain, readwrite) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>;<$endif$> +<$endif$><$endforeach do$> +<$foreach Relationship noninheritedRelationships do$> +<$if Relationship.isToMany$>- (void)add<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_; +- (void)remove<$Relationship.name.initialCapitalString$>Objects; +- (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_; +<$endif$><$endforeach do$> + +@end diff --git a/contributed templates/Nikita Zhuk/ponso/templates/machine.m.motemplate b/contributed templates/Nikita Zhuk/ponso/templates/machine.m.motemplate new file mode 100755 index 00000000..c29a0947 --- /dev/null +++ b/contributed templates/Nikita Zhuk/ponso/templates/machine.m.motemplate @@ -0,0 +1,174 @@ +// +// <$managedObjectClassName$>.m +// +// $Id$ +// +// DO NOT EDIT. This file is machine-generated and constantly overwritten. +// Make changes to <$managedObjectClassName$>.h instead. +// + +#import "_<$managedObjectClassName$>.h" + +<$foreach Relationship noninheritedRelationships do$>#import "<$Relationship.destinationEntity.managedObjectClassName$>.h" +<$endforeach do$> + +@interface _<$managedObjectClassName$>() +<$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$>@property (nonatomic, retain, readwrite) NSArray *<$Relationship.name$>; +<$endif$><$endforeach do$> +@end + +/** \ingroup DataModel */ + +@implementation _<$managedObjectClassName$> + +- (id)init +{ + if((self = [super init])) + { + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$if Attribute.hasScalarAttributeType$><$if ! Attribute.isOptional$><$if Attribute.defaultValue$>self.<$Attribute.name$> = [NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:<$Attribute.defaultValue$>]; + <$else$>self.<$Attribute.name$> = [NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:0]; + <$endif$><$endif$><$endif$><$endif$><$endforeach do$> + } + + return self; +} + +#pragma mark Scalar values +<$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$if Attribute.hasScalarAttributeType$> +- (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value +{ + return [self.<$Attribute.name$> <$Attribute.scalarAttributeType.camelCaseString$>Value]; +} + +- (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ +{ + self.<$Attribute.name$> = [NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:value_]; +} +<$endif$><$endif$><$endforeach do$> + + +#pragma mark Dictionary representation + +- (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary +{ + if((self = [super initWithDictionaryRepresentation:dictionary])) + { + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$>self.<$Attribute.name$> = [dictionary objectForKey:@"<$managedObjectClassName$>.<$Attribute.name$>"]; + <$endif$><$endforeach do$> + <$foreach Relationship noninheritedRelationships do$><$if ! Relationship.userInfo.destinationEntityIDKeyPath $><$if ! Relationship.isTransient$><$if Relationship.isToMany$> + for(id objectRepresentationForDict in [dictionary objectForKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]) + { + <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>Obj = [[[<$Relationship.destinationEntity.managedObjectClassName$> alloc] initWithDictionaryRepresentation:objectRepresentationForDict] autorelease]; + [self add<$Relationship.name.initialCapitalString$>Object:<$Relationship.name$>Obj]; + }<$else$>NSDictionary *<$Relationship.name$>Dict = [dictionary objectForKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]; + if(<$Relationship.name$>Dict != nil) + { + <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>Obj = [[<$Relationship.destinationEntity.managedObjectClassName$> alloc] initWithDictionaryRepresentation:<$Relationship.name$>Dict]; + self.<$Relationship.name$> = <$Relationship.name$>Obj; + [<$Relationship.name$>Obj release]; + }<$endif$><$endif$><$endif$><$endforeach do$> + } + + return self; +} + +- (NSDictionary *)dictionaryRepresentation +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$>[dict setObjectIfNotNil:self.<$Attribute.name$> forKey:@"<$managedObjectClassName$>.<$Attribute.name$>"]; + <$endif$><$endforeach do$> + <$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$>if([self.<$Relationship.name$> count] > 0) + { + <$if (! Relationship.isTransient) or (Relationship.userInfo.destinationEntityIDKeyPath) $> + NSMutableArray *<$Relationship.name$>RepresentationsForDictionary = [NSMutableArray arrayWithCapacity:[self.<$Relationship.name$> count]]; + for(<$Relationship.destinationEntity.managedObjectClassName$> *obj in self.<$Relationship.name$>) + { + <$if Relationship.userInfo.destinationEntityIDKeyPath $>[<$Relationship.name$>RepresentationsForDictionary addObject:[obj valueForKeyPath:@"<$Relationship.userInfo.destinationEntityIDKeyPath$>"]]; + <$else$>[<$Relationship.name$>RepresentationsForDictionary addObject:[obj dictionaryRepresentation]];<$endif$> + } + [dict setObjectIfNotNil:<$Relationship.name$>RepresentationsForDictionary forKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]; + <$endif$> + } + <$else$> + <$if Relationship.userInfo.destinationEntityIDKeyPath $>[dict setObjectIfNotNil:[self.<$Relationship.name$> valueForKeyPath:@"<$Relationship.userInfo.destinationEntityIDKeyPath$>"] forKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]; + <$else$><$if ! Relationship.isTransient $>[dict setObjectIfNotNil:[self.<$Relationship.name$> dictionaryRepresentation] forKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]; + <$endif$> + <$endif$> + <$endif$> + <$endforeach do$> + return dict; +} + +- (void)awakeFromDictionaryRepresentationInit +{ + if(self.sourceDictionaryRepresentation == nil) + return; // awakeFromDictionaryRepresentationInit has been already executed on this object. + + <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if Relationship.userInfo.destinationEntityIDKeyPath $><$if Relationship.isToMany$>NSArray *<$managedObjectClassName$>_<$Relationship.name$>IDs = [self.sourceDictionaryRepresentation objectForKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]; + for(id <$managedObjectClassName$>_<$Relationship.name$>ID in <$managedObjectClassName$>_<$Relationship.name$>IDs) + { + <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>Obj = [(_<$managedObjectClassName$><_<$managedObjectClassName$>> *)self fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:<$managedObjectClassName$>_<$Relationship.name$>ID]; + if(<$Relationship.name$>Obj != nil) + [self add<$Relationship.name.initialCapitalString$>Object:<$Relationship.name$>Obj]; + } + <$else$>self.<$Relationship.name$> = [(_<$managedObjectClassName$><_<$managedObjectClassName$>> *)self fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:[self.sourceDictionaryRepresentation objectForKey:@"<$managedObjectClassName$>.<$Relationship.name$>"]]; + <$if ! Relationship.inverseRelationship.isToMany$>self.<$Relationship.name$>.<$Relationship.inverseRelationship.name$> = (<$managedObjectClassName$>*)self; + <$else$>[self.<$Relationship.name$> add<$Relationship.inverseRelationship.name.initialCapitalString$>Object:(<$managedObjectClassName$>*)self];<$endif$> + + <$endif$><$endif$><$endforeach do$> + + + <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.destinationEntity != Relationship.entity $><$if Relationship.isToMany$> + for(<$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>Obj in self.<$Relationship.name$>) + { + [<$Relationship.name$>Obj awakeFromDictionaryRepresentationInit]; + } + <$else$>[self.<$Relationship.name$> awakeFromDictionaryRepresentationInit]; + <$endif$><$endif$><$endif$><$endforeach do$> + + [super awakeFromDictionaryRepresentationInit]; +} + +#pragma mark Direct access + +<$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$> +- (void)add<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_ +{ + if(self.<$Relationship.name$> == nil) + { + self.<$Relationship.name$> = [NSMutableArray array]; + } + + [(NSMutableArray *)self.<$Relationship.name$> addObject:value_]; + <$if Relationship.inverseRelationship$><$if ! Relationship.inverseRelationship.isToMany$>value_.<$Relationship.inverseRelationship.name$> = (<$managedObjectClassName$>*)self;<$endif$><$endif$> +} + +- (void)remove<$Relationship.name.initialCapitalString$>Objects +{ + self.<$Relationship.name$> = [NSMutableArray array]; +} + +- (void)remove<$Relationship.name.initialCapitalString$>Object:(<$Relationship.destinationEntity.managedObjectClassName$>*)value_ +{ + <$if Relationship.inverseRelationship$><$if ! Relationship.inverseRelationship.isToMany$>value_.<$Relationship.inverseRelationship.name$> = nil;<$endif$><$endif$> + [(NSMutableArray *)self.<$Relationship.name$> removeObject:value_]; +} + +<$endif$><$endforeach do$> + +- (void)dealloc +{ + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$>self.<$Attribute.name$> = nil; + <$endif$><$endforeach do$> + <$foreach Relationship noninheritedRelationships do$>self.<$Relationship.name$> = nil; + <$endforeach do$> + [super dealloc]; +} + +#pragma mark Synthesizes + +<$foreach Attribute noninheritedAttributes do$>@synthesize <$Attribute.name$>; +<$endforeach do$> +<$foreach Relationship noninheritedRelationships do$>@synthesize <$Relationship.name$>; +<$endforeach do$> +@end diff --git a/ddcli/DDGetoptLongParser.m b/ddcli/DDGetoptLongParser.m index fd7e0b55..a383def1 100644 --- a/ddcli/DDGetoptLongParser.m +++ b/ddcli/DDGetoptLongParser.m @@ -42,12 +42,12 @@ - (void) handleArgumentNotRecognized: (NSString *) option @implementation DDGetoptLongParser -+ (DDGetoptLongParser *) optionsWithTarget: (id) target; ++ (DDGetoptLongParser *) optionsWithTarget: (id) target { return [[[self alloc] initWithTarget: target] autorelease]; } -- (id) initWithTarget: (id) target; +- (id) initWithTarget: (id) target { self = [super init]; if (self == nil) @@ -77,18 +77,18 @@ - (void) dealloc [super dealloc]; } -- (id) target; +- (id) target { return mTarget; } -- (void) setTarget: (id) target; +- (void) setTarget: (id) target { mTarget = target; } -- (void) setGetoptLongOnly: (BOOL) getoptLongOnly; +- (void) setGetoptLongOnly: (BOOL) getoptLongOnly { if (getoptLongOnly) mGetoptFunction = getopt_long_only; @@ -96,7 +96,7 @@ - (void) setGetoptLongOnly: (BOOL) getoptLongOnly; mGetoptFunction = getopt_long; } -- (void) addOptionsFromTable: (DDGetoptOption *) optionTable; +- (void) addOptionsFromTable: (DDGetoptOption *) optionTable { DDGetoptOption * currentOption = optionTable; while ((currentOption->longOption != nil) || @@ -113,7 +113,7 @@ - (void) addOptionsFromTable: (DDGetoptOption *) optionTable; - (void) addLongOption: (NSString *) longOption shortOption: (char) shortOption key: (NSString *) key - argumentOptions: (DDGetoptArgumentOptions) argumentOptions; + argumentOptions: (DDGetoptArgumentOptions) argumentOptions { const char * utf8String = [longOption UTF8String]; NSData * utf8Data = [NSData dataWithBytes: utf8String length: strlen(utf8String)]; @@ -153,13 +153,13 @@ - (void) addLongOption: (NSString *) longOption - (void) addLongOption: (NSString *) longOption key: (NSString *) key - argumentOptions: (DDGetoptArgumentOptions) argumentOptions; + argumentOptions: (DDGetoptArgumentOptions) argumentOptions { [self addLongOption: longOption shortOption: 0 key: key argumentOptions: argumentOptions]; } -- (NSArray *) parseOptions; +- (NSArray *) parseOptions { NSProcessInfo * processInfo = [NSProcessInfo processInfo]; NSArray * arguments = [processInfo arguments]; @@ -168,11 +168,11 @@ - (NSArray *) parseOptions; } - (NSArray *) parseOptionsWithArguments: (NSArray *) arguments - command: (NSString *) command; + command: (NSString *) command { - int argc = [arguments count]; + NSUInteger argc = [arguments count]; char ** argv = alloca(sizeof(char *) * argc); - int i; + NSUInteger i; for (i = 0; i < argc; i++) { NSString * argument = [arguments objectAtIndex: i]; @@ -193,7 +193,7 @@ - (NSArray *) parseOptionsWithArguments: (NSArray *) arguments opterr = 1; int longOptionIndex = -1; - while ((ch = mGetoptFunction(argc, argv, optionString, options, &longOptionIndex)) != -1) + while ((ch = mGetoptFunction((int)argc, argv, optionString, options, &longOptionIndex)) != -1) { NSString * last_argv = [NSString stringWithUTF8String: argv[optind-1]]; if (ch == ':') @@ -233,7 +233,7 @@ - (NSArray *) parseOptionsWithArguments: (NSArray *) arguments @implementation DDGetoptLongParser (Private) -- (NSString *) optionToKey: (NSString *) option; +- (NSString *) optionToKey: (NSString *) option { NSScanner * scanner = [NSScanner scannerWithString: option]; [scanner setCharactersToBeSkipped: [NSCharacterSet characterSetWithCharactersInString: @"-"]]; @@ -250,25 +250,25 @@ - (NSString *) optionToKey: (NSString *) option; return key; } -- (struct option *) firstOption; +- (struct option *) firstOption { struct option * options = [mOptionsData mutableBytes]; return options; } -- (struct option *) currentOption; +- (struct option *) currentOption { struct option * options = [mOptionsData mutableBytes]; return &options[mCurrentOption]; } -- (void) addOption; +- (void) addOption { [mOptionsData increaseLengthBy: sizeof(struct option)]; mCurrentOption++; } -- (NSString *) errorOption: (NSString *) option; +- (NSString *) errorOption: (NSString *) option { if (![option hasPrefix: @"-"]) return [NSString stringWithFormat: @"%c", optopt]; @@ -277,7 +277,7 @@ - (NSString *) errorOption: (NSString *) option; } - (void) handleMissingArgument: (NSString *) option - command: (NSString *) command; + command: (NSString *) command { option = [self errorOption: option]; @@ -294,7 +294,7 @@ - (void) handleMissingArgument: (NSString *) option } - (void) handleArgumentNotRecognized: (NSString *) option - command: (NSString *) command; + command: (NSString *) command { option = [self errorOption: option]; if ([mTarget respondsToSelector: @selector(optionIsNotRecognized:)]) diff --git a/mogenerator b/mogenerator new file mode 100755 index 00000000..17502f1e Binary files /dev/null and b/mogenerator differ diff --git a/mogenerator.m b/mogenerator.m index a81f2a7c..34722839 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -74,35 +74,38 @@ - (NSString*)customSuperentity { } /** @TypeInfo NSAttributeDescription */ - (NSArray*)noninheritedAttributes { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self attributesByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity attributesByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self attributesByName] allValues]; + return [[[self attributesByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } } /** @TypeInfo NSAttributeDescription */ - (NSArray*)noninheritedRelationships { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self relationshipsByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity relationshipsByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self relationshipsByName] allValues]; + return [[[self relationshipsByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } } /** @TypeInfo NSFetchedPropertyDescription */ - (NSArray*)noninheritedFetchedProperties { + NSArray *sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]; NSEntityDescription *superentity = [self superentity]; if (superentity) { NSMutableArray *result = [[[[self fetchedPropertiesByName] allValues] mutableCopy] autorelease]; [result removeObjectsInArray:[[superentity fetchedPropertiesByName] allValues]]; - return result; + return [result sortedArrayUsingDescriptors:sortDescriptors]; } else { - return [[self fetchedPropertiesByName] allValues]; + return [[[self fetchedPropertiesByName] allValues] sortedArrayUsingDescriptors:sortDescriptors]; } } @@ -260,7 +263,7 @@ - (BOOL)hasTransformableAttributeType { @implementation NSString (camelCaseString) - (NSString*)camelCaseString { NSArray *lowerCasedWordArray = [[self wordArray] arrayByMakingObjectsPerformSelector:@selector(lowercaseString)]; - unsigned wordIndex = 1, wordCount = [lowerCasedWordArray count]; + NSUInteger wordIndex = 1, wordCount = [lowerCasedWordArray count]; NSMutableArray *camelCasedWordArray = [NSMutableArray arrayWithCapacity:wordCount]; if (wordCount) [camelCasedWordArray addObject:[lowerCasedWordArray objectAtIndex:0]]; @@ -366,7 +369,7 @@ - (void) printUsage; } - (NSString*)currentXcodePath { - NSMutableString *result = @""; + NSString *result = @""; @try { NSTask *task = [[[NSTask alloc] init] autorelease]; @@ -384,9 +387,8 @@ - (NSString*)currentXcodePath { [task launch]; NSData *data = [file readDataToEndOfFile]; - - result = [[[NSMutableString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; - [result deleteCharactersInRange:NSMakeRange([result length]-1, 1)]; // trim newline + result = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; + result = [result substringToIndex:[result length]-1]; // trim newline } @catch(NSException *ex) { ddprintf(@"WARNING couldn't launch /usr/bin/xcode-select\n"); } @@ -426,8 +428,20 @@ - (void)setModel:(NSString*)path; } assert(momc && "momc not found"); - tempMOMPath = [[NSTemporaryDirectory() stringByAppendingPathComponent:[(id)CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(kCFAllocatorDefault)) autorelease]] stringByAppendingPathExtension:@"mom"]; - system([[NSString stringWithFormat:@"\"%@\" \"%@\" \"%@\"", momc, path, tempMOMPath] UTF8String]); // Ignored system's result -- momc doesn't return any relevent error codes. + tempMOMPath = [[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]] stringByAppendingPathExtension:@"mom"]; + + NSArray *supportedMomcOptions = [NSArray arrayWithObjects:@"MOMC_NO_WARNINGS", @"MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS", @"MOMC_SUPPRESS_INVERSE_TRANSIENT_ERROR", nil]; + NSMutableString *momcOptions = [NSMutableString string]; + + for (NSString *momcOption in supportedMomcOptions) + { + if([[[NSProcessInfo processInfo] environment] objectForKey:momcOption] != nil) + { + [momcOptions appendFormat:@" -%@ ", momcOption]; + } + } + + system([[NSString stringWithFormat:@"\"%@\" %@ \"%@\" \"%@\"", momc, momcOptions, path, tempMOMPath] UTF8String]); // Ignored system's result -- momc doesn't return any relevent error codes. path = tempMOMPath; } model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]] autorelease]; @@ -583,9 +597,9 @@ - (int) application: (DDCliApplication *) app if (_listSourceFiles) { [machineHFiles addObject:machineHFileName]; } else { - if (![fm regularFileExistsAtPath:machineHFileName] || ![generatedMachineH isEqualToString:[NSString stringWithContentsOfFile:machineHFileName]]) { + if (![fm regularFileExistsAtPath:machineHFileName] || ![generatedMachineH isEqualToString:[NSString stringWithContentsOfFile:machineHFileName encoding:NSUTF8StringEncoding error:nil]]) { // If the file doesn't exist or is different than what we just generated, write it out. - [generatedMachineH writeToFile:machineHFileName atomically:NO]; + [generatedMachineH writeToFile:machineHFileName atomically:NO encoding:NSUTF8StringEncoding error:nil]; machineDirtied = YES; machineFilesGenerated++; } @@ -597,9 +611,9 @@ - (int) application: (DDCliApplication *) app if (_listSourceFiles) { [machineMFiles addObject:machineMFileName]; } else { - if (![fm regularFileExistsAtPath:machineMFileName] || ![generatedMachineM isEqualToString:[NSString stringWithContentsOfFile:machineMFileName]]) { + if (![fm regularFileExistsAtPath:machineMFileName] || ![generatedMachineM isEqualToString:[NSString stringWithContentsOfFile:machineMFileName encoding:NSUTF8StringEncoding error:nil]]) { // If the file doesn't exist or is different than what we just generated, write it out. - [generatedMachineM writeToFile:machineMFileName atomically:NO]; + [generatedMachineM writeToFile:machineMFileName atomically:NO encoding:NSUTF8StringEncoding error:nil]; machineDirtied = YES; machineFilesGenerated++; } @@ -615,7 +629,7 @@ - (int) application: (DDCliApplication *) app if (machineDirtied) [fm touchPath:humanHFileName]; } else { - [generatedHumanH writeToFile:humanHFileName atomically:NO]; + [generatedHumanH writeToFile:humanHFileName atomically:NO encoding:NSUTF8StringEncoding error:nil]; humanFilesGenerated++; } } @@ -636,7 +650,7 @@ - (int) application: (DDCliApplication *) app if (machineDirtied) [fm touchPath:humanMFileName]; } else { - [generatedHumanM writeToFile:humanMFileName atomically:NO]; + [generatedHumanM writeToFile:humanMFileName atomically:NO encoding:NSUTF8StringEncoding error:nil]; humanFilesGenerated++; } } @@ -656,11 +670,11 @@ - (int) application: (DDCliApplication *) app } if (tempMOMPath) { - [fm removeFileAtPath:tempMOMPath handler:nil]; + [fm removeItemAtPath:tempMOMPath error:nil]; } bool mfileGenerated = NO; if (mfilePath && ![mfileContent isEqualToString:@""]) { - [mfileContent writeToFile:mfilePath atomically:NO]; + [mfileContent writeToFile:mfilePath atomically:NO encoding:NSUTF8StringEncoding error:nil]; mfileGenerated = YES; } diff --git a/mogenerator.xcodeproj/project.pbxproj b/mogenerator.xcodeproj/project.pbxproj index 55ef1965..36c74c25 100644 --- a/mogenerator.xcodeproj/project.pbxproj +++ b/mogenerator.xcodeproj/project.pbxproj @@ -3,10 +3,13 @@ archiveVersion = 1; classes = { }; - objectVersion = 42; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ + 457C26CD139A1EF900BF00DD /* MKCDAGNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 457C26C8139A1EF900BF00DD /* MKCDAGNode.m */; }; + 457C26CE139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 457C26CA139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m */; }; + 457C26CF139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 457C26CC139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m */; }; 55200E960C49FEEA00018A42 /* DDCliApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 55200E900C49FEEA00018A42 /* DDCliApplication.m */; }; 55200E970C49FEEA00018A42 /* DDCliUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 55200E920C49FEEA00018A42 /* DDCliUtil.m */; }; 55200E980C49FEEA00018A42 /* DDGetoptLongParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 55200E950C49FEEA00018A42 /* DDGetoptLongParser.m */; }; @@ -62,6 +65,12 @@ 08FB7796FE84155DC02AAC07 /* mogenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = mogenerator.m; sourceTree = ""; usesTabs = 1; }; 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 32A70AAB03705E1F00C91783 /* mogenerator_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mogenerator_Prefix.pch; sourceTree = ""; }; + 457C26C7139A1EF900BF00DD /* MKCDAGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKCDAGNode.h; sourceTree = ""; }; + 457C26C8139A1EF900BF00DD /* MKCDAGNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKCDAGNode.m; sourceTree = ""; }; + 457C26C9139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKCNSEntityDescriptionAdditions.h; sourceTree = ""; }; + 457C26CA139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKCNSEntityDescriptionAdditions.m; sourceTree = ""; }; + 457C26CB139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MKCNSManagedObjectModelAdditions.h; sourceTree = ""; }; + 457C26CC139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MKCNSManagedObjectModelAdditions.m; sourceTree = ""; }; 55200E8F0C49FEEA00018A42 /* DDCliApplication.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DDCliApplication.h; sourceTree = ""; }; 55200E900C49FEEA00018A42 /* DDCliApplication.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DDCliApplication.m; sourceTree = ""; }; 55200E910C49FEEA00018A42 /* DDCliUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DDCliUtil.h; sourceTree = ""; }; @@ -148,7 +157,7 @@ 79D2BF970ACFB51A00F3F141 /* MiscMergeFunctions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeFunctions.m; path = ../MiscMerge/MiscMergeFunctions.m; sourceTree = ""; }; 79D2BF980ACFB51A00F3F141 /* MiscMergeSpike_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeSpike_Prefix.pch; path = ../MiscMerge/MiscMergeSpike_Prefix.pch; sourceTree = ""; }; 79D2BF990ACFB51A00F3F141 /* MiscMergeTemplate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeTemplate.h; path = ../MiscMerge/MiscMergeTemplate.h; sourceTree = ""; }; - 79D2BF9A0ACFB51A00F3F141 /* MiscMergeTemplate.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeTemplate.m; path = ../MiscMerge/MiscMergeTemplate.m; sourceTree = ""; }; + 79D2BF9A0ACFB51A00F3F141 /* MiscMergeTemplate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeTemplate.m; path = ../MiscMerge/MiscMergeTemplate.m; sourceTree = ""; }; 79D2BF9B0ACFB51A00F3F141 /* NSNull.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = NSNull.h; path = ../MiscMerge/NSNull.h; sourceTree = ""; }; 79D2BF9C0ACFB51A00F3F141 /* NSNull.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSNull.m; path = ../MiscMerge/NSNull.m; sourceTree = ""; }; 79D2BF9D0ACFB51A00F3F141 /* NSScanner+MiscMerge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSScanner+MiscMerge.h"; path = "../MiscMerge/NSScanner+MiscMerge.h"; sourceTree = ""; }; @@ -180,6 +189,7 @@ children = ( 08FB7795FE84155DC02AAC07 /* Source */, 79D2BF510ACFB51000F3F141 /* MiscMerge */, + 457C26C6139A1EF900BF00DD /* ponso */, 55200E8E0C49FEEA00018A42 /* ddcli */, 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, 1AB674ADFE9D54B511CA2CBB /* Products */, @@ -220,6 +230,19 @@ name = Products; sourceTree = ""; }; + 457C26C6139A1EF900BF00DD /* ponso */ = { + isa = PBXGroup; + children = ( + 457C26C7139A1EF900BF00DD /* MKCDAGNode.h */, + 457C26C8139A1EF900BF00DD /* MKCDAGNode.m */, + 457C26C9139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.h */, + 457C26CA139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m */, + 457C26CB139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.h */, + 457C26CC139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m */, + ); + path = ponso; + sourceTree = ""; + }; 55200E8E0C49FEEA00018A42 /* ddcli */ = { isa = PBXGroup; children = ( @@ -348,8 +371,12 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "mogenerator" */; - compatibilityVersion = "Xcode 2.4"; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + ); mainGroup = 08FB7794FE84155DC02AAC07 /* mogenerator */; projectDirPath = ""; projectRoot = ""; @@ -410,6 +437,9 @@ 55200E980C49FEEA00018A42 /* DDGetoptLongParser.m in Sources */, 55200F9D0C4A2CA800018A42 /* DDCliParseException.m in Sources */, 7931E67B10FE984F00175784 /* RegexKitLite.m in Sources */, + 457C26CD139A1EF900BF00DD /* MKCDAGNode.m in Sources */, + 457C26CE139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m in Sources */, + 457C26CF139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -423,57 +453,44 @@ DEPLOYMENT_LOCATION = YES; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = mogenerator_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INSTALL_PATH = "$(HOME)/bin"; PRODUCT_NAME = mogenerator; - ZERO_LINK = YES; + WARNING_CFLAGS = "-Wall"; }; name = Debug; }; 1DEB927608733DD40010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - ppc, - i386, - ); DEPLOYMENT_LOCATION = NO; DEPLOYMENT_POSTPROCESSING = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = mogenerator_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INSTALL_PATH = "$(HOME)/bin"; PRODUCT_NAME = mogenerator; + WARNING_CFLAGS = "-Wall"; }; name = Release; }; 1DEB927908733DD40010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - GCC_C_LANGUAGE_STANDARD = c99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_VERSION = 4.0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = ""; + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; }; name = Debug; }; 1DEB927A08733DD40010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - GCC_C_LANGUAGE_STANDARD = c99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_VERSION = 4.0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = ""; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; }; name = Release; }; diff --git a/ponso/MKCDAGNode.h b/ponso/MKCDAGNode.h new file mode 100644 index 00000000..bb16510e --- /dev/null +++ b/ponso/MKCDAGNode.h @@ -0,0 +1,47 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCDAGNode.h + Created by Nikita Zhuk on 22.1.2011. + */ + +#import + +/** + Generic DAG (Directed Acyclic Graph) implementation + */ +@interface MKCDAGNode : NSObject +{ + id object; + NSMutableArray *nodes; +} + +//! Generic payload object, not used in the algorithm. Can be nil. +@property(nonatomic, retain) id object; + +//! All objects of nodes in topological order which are reachable from the receiver. +@property(nonatomic, readonly) NSArray *objectsInTopologicalOrder; + +- (id)initWithObject:(id)object; + +/** + Creates dependency between receiver and the given node and adds the given node into the DAG. + The dependency direction is from the receiver to the given node, e.g. [a addNode:b] means that 'a' depends on 'b'. + If the new node would create a cycle in the DAG it's not added and NO is returned. + YES is returned otherwise. + */ +- (BOOL)addNode:(MKCDAGNode *)node; + +@end diff --git a/ponso/MKCDAGNode.m b/ponso/MKCDAGNode.m new file mode 100644 index 00000000..6c722748 --- /dev/null +++ b/ponso/MKCDAGNode.m @@ -0,0 +1,132 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCDAGNode.m + Created by Nikita Zhuk on 22.1.2011. + */ + +#import "MKCDAGNode.h" + +@interface MKCDAGNode() +/** + All nodes directly reachable from this node ( = nodes to which there is a directed edge from 'self' node) + */ +@property(nonatomic, retain) NSMutableArray *nodes; +@end + +@implementation MKCDAGNode + +#pragma mark Algorithms + ++ (BOOL)isCyclicNode:(MKCDAGNode *)node visitedNodes:(NSMutableSet *)visitedNodes +{ + if([visitedNodes intersectsSet:[NSSet setWithArray:node.nodes]]) + { + // We've seen these nodes already - a cycle! + return YES; + } + + for (MKCDAGNode *childNode in node.nodes) + { + [visitedNodes addObject:childNode]; + BOOL childNodeIsCyclic = [self isCyclicNode:childNode visitedNodes:visitedNodes]; + [visitedNodes removeObject:childNode]; + + if(childNodeIsCyclic) + { + return YES; + } + } + + return NO; +} + +// DAG topological order visitor, see http://en.wikipedia.org/wiki/Directed_acyclic_graph +// 'visitedNodes' set is used to 'mark' visited nodes. ++ (void)visitNode:(MKCDAGNode *)node visitedNodes:(NSMutableSet *)visitedNodes orderedNodes:(NSMutableArray *)orderedNodes +{ + if([visitedNodes containsObject:node]) + { + return; + } + + [visitedNodes addObject:node]; + + for (MKCDAGNode *childNode in node.nodes) + { + [self visitNode:childNode visitedNodes:visitedNodes orderedNodes:orderedNodes]; + } + + [orderedNodes addObject:node]; +} + +#pragma mark Public + +- (id)initWithObject:(id)anObject +{ + if((self = [super init])) + { + self.nodes = [NSMutableArray array]; + self.object = anObject; + } + return self; +} + +- (NSArray *)objectsInTopologicalOrder +{ + NSMutableArray *orderedNodes = [NSMutableArray array]; + + [[self class] visitNode:self visitedNodes:[NSMutableSet set] orderedNodes:orderedNodes]; + + NSMutableArray *orderedObjects = [NSMutableArray array]; + for (MKCDAGNode *node in orderedNodes) + { + if(node.object != nil) + { + [orderedObjects addObject:node.object]; + } + } + return orderedObjects; +} + +- (BOOL)addNode:(MKCDAGNode *)node +{ + if(node == nil) + return NO; + + if(![self.nodes containsObject:node]) + [self.nodes addObject:node]; + + // Check that this node didn't cause a cycle - if it did, remove it. + BOOL isCyclic = [[self class] isCyclicNode:node visitedNodes:[NSMutableSet set]]; + if(isCyclic) + { + [self.nodes removeObject:node]; + } + + return !isCyclic; +} + +- (void) dealloc +{ + self.nodes = nil; + self.object = nil; + + [super dealloc]; +} + +@synthesize nodes; +@synthesize object; +@end diff --git a/ponso/MKCNSEntityDescriptionAdditions.h b/ponso/MKCNSEntityDescriptionAdditions.h new file mode 100644 index 00000000..fd1b53d5 --- /dev/null +++ b/ponso/MKCNSEntityDescriptionAdditions.h @@ -0,0 +1,28 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCNSEntityDescriptionAdditions.h + Created by Nikita Zhuk on 22.1.2011. + */ + +#import + + +@interface NSEntityDescription(MKCNSEntityDescriptionAdditions) + +/** @TypeInfo NSAttributeDescription */ +@property(nonatomic, readonly) NSArray *noninheritedRelationshipsInIDKeyPathTopologicalOrder; + +@end diff --git a/ponso/MKCNSEntityDescriptionAdditions.m b/ponso/MKCNSEntityDescriptionAdditions.m new file mode 100644 index 00000000..03f001c4 --- /dev/null +++ b/ponso/MKCNSEntityDescriptionAdditions.m @@ -0,0 +1,83 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCNSEntityDescriptionAdditions.m + Created by Nikita Zhuk on 22.1.2011. + */ + + +#import "MKCNSEntityDescriptionAdditions.h" +#import "MKCNSManagedObjectModelAdditions.h" + +@interface MKCNSRelationshipDescriptionIDKeyPathDependencyFilter : NSObject @end + +@implementation MKCNSRelationshipDescriptionIDKeyPathDependencyFilter + +- (BOOL)includeRelationship:(NSRelationshipDescription *)relationship +{ + if([[relationship entity] isEqual:[relationship destinationEntity]]) + { + // Relationship from entity to itself - ignore. + return NO; + } + + return [[[relationship userInfo] objectForKey:@"destinationEntityIDKeyPath"] length] > 0; +} + +@end + +@implementation NSEntityDescription(MKCNSEntityDescriptionAdditions) + +/** @TypeInfo NSAttributeDescription */ +- (NSArray*)noninheritedRelationshipsInIDKeyPathTopologicalOrder +{ + NSArray *relationships = nil; + + NSEntityDescription *superentity = [self superentity]; + if (superentity != nil) + { + NSMutableArray *result = [[[[self relationshipsByName] allValues] mutableCopy] autorelease]; + [result removeObjectsInArray:[[superentity relationshipsByName] allValues]]; + relationships = result; + } + else + { + relationships = [[self relationshipsByName] allValues]; + } + + // Initially, sort relationships in alphabetical order. + relationships = [relationships sortedArrayUsingDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]]; + + // Sort relationships in topological order by their destination entities including "IDKeyPath" relationships in dependencies. + // Although this is a bit naive O(n^2) sort, it should be fast enough since n (=number of relationships) is usually very low. + id IDKeyPathDependencyFilter = [[[MKCNSRelationshipDescriptionIDKeyPathDependencyFilter alloc] init] autorelease]; + NSArray *allEntities = [[self managedObjectModel] entitiesInTopologicalOrderUsingDependencyFilter:IDKeyPathDependencyFilter]; + NSMutableArray *sortedRelationships = [NSMutableArray arrayWithCapacity:[relationships count]]; + + for (NSEntityDescription *entity in allEntities) + { + for (NSRelationshipDescription *relationship in relationships) + { + if([[relationship destinationEntity] isEqual:entity]) + { + [sortedRelationships addObject:relationship]; + } + } + } + + return sortedRelationships; +} + +@end diff --git a/ponso/MKCNSManagedObjectModelAdditions.h b/ponso/MKCNSManagedObjectModelAdditions.h new file mode 100644 index 00000000..94db08e0 --- /dev/null +++ b/ponso/MKCNSManagedObjectModelAdditions.h @@ -0,0 +1,44 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCNSManagedObjectModelAdditions.h + Created by Nikita Zhuk on 22.1.2011. + */ + +#import + + +@protocol MKCNSRelationshipDescriptionDependencyFilter +- (BOOL)includeRelationship:(NSRelationshipDescription *)relationship; +@end + +@interface NSManagedObjectModel(MKCNSManagedObjectModelAdditions) + +/** + Array of NSEntityDescription objects, sorted in topological order + based on relationships between entity descriptions. + If there are cyclic dependencies, a nil is returned. + This method counts all relationships as dependencies if they are not marked as being 'transient'. + */ + +- (NSArray *) entitiesInTopologicalOrder; + +/* + Same as entitiesInTopologicalOrder, but uses the given dependencyFilter to decide whether a + relationship should be counted as dependency or not. + */ +- (NSArray *) entitiesInTopologicalOrderUsingDependencyFilter:(id) dependencyFilter; + +@end diff --git a/ponso/MKCNSManagedObjectModelAdditions.m b/ponso/MKCNSManagedObjectModelAdditions.m new file mode 100644 index 00000000..175e8948 --- /dev/null +++ b/ponso/MKCNSManagedObjectModelAdditions.m @@ -0,0 +1,98 @@ +/* + Copyright 2011 Marko Karppinen & Co. LLC. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + MKCNSManagedObjectModelAdditions.m + Created by Nikita Zhuk on 22.1.2011. + */ + +#import "MKCNSManagedObjectModelAdditions.h" +#import "MKCDAGNode.h" + +@interface MKCNSRelationshipDescriptionDefaultDependencyFilter : NSObject @end + +@implementation MKCNSRelationshipDescriptionDefaultDependencyFilter + +- (BOOL)includeRelationship:(NSRelationshipDescription *)relationship +{ + if([[relationship entity] isEqual:[relationship destinationEntity]]) + { + // Relationship from entity to itself - ignore. + return NO; + } + + return ![relationship isTransient]; +} + +@end + + +@implementation NSManagedObjectModel(MKCNSManagedObjectModelAdditions) + +- (NSArray *) entitiesInTopologicalOrderUsingDependencyFilter:(id) dependencyFilter +{ + // Wrap entitites in DAG nodes and place them all into dict for faster access + NSMutableDictionary *entityNodes = [NSMutableDictionary dictionaryWithCapacity:[[self entities] count]]; + for (NSEntityDescription *entity in [self entities]) + { + MKCDAGNode *node = [[[MKCDAGNode alloc] initWithObject:entity] autorelease]; + [entityNodes setObject:node forKey:[entity name]]; + } + + // Create DAG from entities based on their relationships + MKCDAGNode *root = [[[MKCDAGNode alloc] initWithObject:nil] autorelease]; + + for (NSEntityDescription *entity in [self entities]) + { + MKCDAGNode *node = [entityNodes objectForKey:[entity name]]; + + if(![root addNode:node]) + { + NSLog(@"Couldn't add node of entity '%@' to root.", [entity name]); + return nil; + } + + for (NSRelationshipDescription *relationship in [[entity relationshipsByName] allValues]) + { + BOOL shouldInclude = YES; + + if(dependencyFilter != nil) + { + shouldInclude = [dependencyFilter includeRelationship:relationship]; + } + + if(shouldInclude) + { + MKCDAGNode *childNode = [entityNodes objectForKey:[[relationship destinationEntity] name]]; + + if(![node addNode:childNode]) + { + NSLog(@"Couldn't add dependency '%@' -> '%@'. A cycle was detected.", [[relationship entity] name], [[relationship destinationEntity] name]); + return nil; + } + } + } + } + + return root.objectsInTopologicalOrder; +} + +- (NSArray *) entitiesInTopologicalOrder +{ + id defaultFilter = [[[MKCNSRelationshipDescriptionDefaultDependencyFilter alloc] init] autorelease]; + + return [self entitiesInTopologicalOrderUsingDependencyFilter:defaultFilter]; +} + +@end diff --git a/ponso/PONSO-LICENSE.txt b/ponso/PONSO-LICENSE.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/ponso/PONSO-LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/ponso/generate.sh b/ponso/generate.sh new file mode 100644 index 00000000..dee37591 --- /dev/null +++ b/ponso/generate.sh @@ -0,0 +1,24 @@ +if [ ! -f "$MOGENERATOR_BIN" ] +then + echo "mogenerator binary doesn't exist at $MOGENERATOR_BIN" + exit 1 +fi + +echo "Generating Data Model Classes from $DATA_MODEL_FILE ..." +if [ ! -d "$DATA_MODEL_FILE" ] + then + echo "Data model file doesn't exist at $DATA_MODEL_FILE" +exit 1 +fi + +mkdir -p "$DATA_MODEL_SOURCE_DIR" + +MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS=YES \ +MOMC_SUPPRESS_INVERSE_TRANSIENT_ERROR=YES \ +"$MOGENERATOR_BIN" \ +-m "$DATA_MODEL_FILE" \ +--base-class "$BASE_CLASS" \ +--template-path "$MOGENERATOR_TEMPLATES" \ +-O "$DATA_MODEL_SOURCE_DIR" + +echo "Generated Data Model Classes to $DATA_MODEL_SOURCE_DIR"