├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── MiscMerge ├── English.lproj │ └── InfoPlist.strings ├── FoundationAdditions.h ├── FoundationAdditions.m ├── Info.plist ├── KeyValue+MiscMerge.h ├── KeyValue+MiscMerge.m ├── MiscKit License Notes.markdown ├── MiscKit License.markdown ├── MiscMerge.rtf ├── MiscMerge.xcodeproj │ └── project.pbxproj ├── MiscMergeCommand.h ├── MiscMergeCommand.m ├── MiscMergeCommandBlock.h ├── MiscMergeCommandBlock.m ├── MiscMergeDriver.h ├── MiscMergeDriver.m ├── MiscMergeEngine.h ├── MiscMergeEngine.m ├── MiscMergeExpression.h ├── MiscMergeExpression.m ├── MiscMergeFunctions.h ├── MiscMergeFunctions.m ├── MiscMergeSpike_Prefix.pch ├── MiscMergeTemplate.h ├── MiscMergeTemplate.m ├── MiscMerge_Prefix.pch ├── NSNull.h ├── NSNull.m ├── NSScanner+MiscMerge.h ├── NSScanner+MiscMerge.m ├── NSString+MiscAdditions.h ├── NSString+MiscAdditions.m ├── _MiscMergeBreakCommand.h ├── _MiscMergeBreakCommand.m ├── _MiscMergeCallCommand.h ├── _MiscMergeCallCommand.m ├── _MiscMergeCommentCommand.h ├── _MiscMergeCommentCommand.m ├── _MiscMergeContinueCommand.h ├── _MiscMergeContinueCommand.m ├── _MiscMergeCopyCommand.h ├── _MiscMergeCopyCommand.m ├── _MiscMergeDateCommand.h ├── _MiscMergeDateCommand.m ├── _MiscMergeDebugCommand.h ├── _MiscMergeDebugCommand.m ├── _MiscMergeDelayedParseCommand.h ├── _MiscMergeDelayedParseCommand.m ├── _MiscMergeElseCommand.h ├── _MiscMergeElseCommand.m ├── _MiscMergeElseifCommand.h ├── _MiscMergeElseifCommand.m ├── _MiscMergeEndforeachCommand.h ├── _MiscMergeEndforeachCommand.m ├── _MiscMergeEndifCommand.h ├── _MiscMergeEndifCommand.m ├── _MiscMergeEndloopCommand.h ├── _MiscMergeEndloopCommand.m ├── _MiscMergeEndprocedureCommand.h ├── _MiscMergeEndprocedureCommand.m ├── _MiscMergeEndwhileCommand.h ├── _MiscMergeEndwhileCommand.m ├── _MiscMergeFieldCommand.h ├── _MiscMergeFieldCommand.m ├── _MiscMergeForeachCommand.h ├── _MiscMergeForeachCommand.m ├── _MiscMergeIdentifyCommand.h ├── _MiscMergeIdentifyCommand.m ├── _MiscMergeIfCommand.h ├── _MiscMergeIfCommand.m ├── _MiscMergeIncludeCommand.h ├── _MiscMergeIncludeCommand.m ├── _MiscMergeIndexCommand.h ├── _MiscMergeIndexCommand.m ├── _MiscMergeLoopCommand.h ├── _MiscMergeLoopCommand.m ├── _MiscMergeNextCommand.h ├── _MiscMergeNextCommand.m ├── _MiscMergeOmitCommand.h ├── _MiscMergeOmitCommand.m ├── _MiscMergeOptionCommand.h ├── _MiscMergeOptionCommand.m ├── _MiscMergeProcedureCommand.h ├── _MiscMergeProcedureCommand.m ├── _MiscMergeSetCommand.h ├── _MiscMergeSetCommand.m ├── _MiscMergeWhileCommand.h └── _MiscMergeWhileCommand.m ├── README.md ├── Version-History.md ├── build-mogenerator-Info-plist.sh ├── categories ├── NSString+MORegEx.h └── NSString+MORegEx.m ├── contributed templates ├── Brian Webster │ ├── Diff template readme.txt │ └── machine.h.motemplate ├── Dan Wood │ ├── Generating Standard Objects from Core Data Models.webloc │ ├── human.h.motemplate │ ├── human.m.motemplate │ ├── machine.h.motemplate │ └── machine.m.motemplate ├── Louis Gerbarg │ ├── human.h.motemplate │ ├── human.m.motemplate │ ├── machine.h.motemplate │ ├── machine.m.motemplate │ └── tweet.webloc ├── Nikita Zhuk │ └── ponso │ │ ├── README.txt │ │ ├── code │ │ ├── ModelObject.h │ │ └── ModelObject.m │ │ ├── sample project │ │ └── PonsoTest │ │ │ ├── MyModel.xcdatamodeld │ │ │ ├── .xccurrentversion │ │ │ └── MyModel.xcdatamodel │ │ │ │ ├── elements │ │ │ │ └── layout │ │ │ ├── PonsoTest.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── PonsoTest │ │ │ ├── PonsoTest-Prefix.pch │ │ │ └── main.m │ │ │ └── Sources │ │ │ └── DataModel │ │ │ ├── Model.h │ │ │ ├── ModelAssistant.h │ │ │ ├── ModelAssistant.m │ │ │ ├── ModelCompany.h │ │ │ ├── ModelCompany.m │ │ │ ├── ModelDepartment.h │ │ │ ├── ModelDepartment.m │ │ │ ├── ModelDepartmentAssistant.h │ │ │ ├── ModelDepartmentAssistant.m │ │ │ ├── ModelDepartmentEmployee.h │ │ │ ├── ModelDepartmentEmployee.m │ │ │ ├── ModelEmployee.h │ │ │ ├── ModelEmployee.m │ │ │ ├── _ModelAssistant.h │ │ │ ├── _ModelAssistant.m │ │ │ ├── _ModelCompany.h │ │ │ ├── _ModelCompany.m │ │ │ ├── _ModelDepartment.h │ │ │ ├── _ModelDepartment.m │ │ │ ├── _ModelDepartmentAssistant.h │ │ │ ├── _ModelDepartmentAssistant.m │ │ │ ├── _ModelDepartmentEmployee.h │ │ │ ├── _ModelDepartmentEmployee.m │ │ │ ├── _ModelEmployee.h │ │ │ └── _ModelEmployee.m │ │ └── templates │ │ ├── human.h.motemplate │ │ ├── human.m.motemplate │ │ ├── machine.h.motemplate │ │ └── machine.m.motemplate ├── Tyrone Trevorrow │ └── ponso │ │ ├── README.txt │ │ ├── code │ │ ├── ModelObject.h │ │ └── ModelObject.m │ │ ├── sample project │ │ └── PonsoTest │ │ │ ├── MyModel.xcdatamodeld │ │ │ ├── .xccurrentversion │ │ │ └── MyModel.xcdatamodel │ │ │ │ ├── elements │ │ │ │ └── layout │ │ │ ├── PonsoTest.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcuserdata │ │ │ │ │ └── t.trevorrow.xcuserdatad │ │ │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── xcuserdata │ │ │ │ └── t.trevorrow.xcuserdatad │ │ │ │ └── xcschemes │ │ │ │ ├── PonsoTest.xcscheme │ │ │ │ └── xcschememanagement.plist │ │ │ ├── PonsoTest │ │ │ ├── PonsoTest-Prefix.pch │ │ │ └── main.m │ │ │ └── Sources │ │ │ └── DataModel │ │ │ ├── Model.h │ │ │ ├── ModelAssistant.h │ │ │ ├── ModelAssistant.m │ │ │ ├── ModelCompany.h │ │ │ ├── ModelCompany.m │ │ │ ├── ModelDepartment.h │ │ │ ├── ModelDepartment.m │ │ │ ├── ModelDepartmentAssistant.h │ │ │ ├── ModelDepartmentAssistant.m │ │ │ ├── ModelDepartmentEmployee.h │ │ │ ├── ModelDepartmentEmployee.m │ │ │ ├── ModelEmployee.h │ │ │ ├── ModelEmployee.m │ │ │ ├── _ModelAssistant.h │ │ │ ├── _ModelAssistant.m │ │ │ ├── _ModelCompany.h │ │ │ ├── _ModelCompany.m │ │ │ ├── _ModelDepartment.h │ │ │ ├── _ModelDepartment.m │ │ │ ├── _ModelDepartmentAssistant.h │ │ │ ├── _ModelDepartmentAssistant.m │ │ │ ├── _ModelDepartmentEmployee.h │ │ │ ├── _ModelDepartmentEmployee.m │ │ │ ├── _ModelEmployee.h │ │ │ └── _ModelEmployee.m │ │ └── templates │ │ ├── NSSet │ │ ├── NSCoding │ │ │ ├── human.h.motemplate │ │ │ ├── human.m.motemplate │ │ │ ├── machine.h.motemplate │ │ │ └── machine.m.motemplate │ │ ├── human.h.motemplate │ │ ├── human.m.motemplate │ │ ├── machine.h.motemplate │ │ └── machine.m.motemplate │ │ ├── human.h.motemplate │ │ ├── human.m.motemplate │ │ ├── machine.h.motemplate │ │ └── machine.m.motemplate └── rentzsch non-dynamic │ ├── human.h.motemplate │ ├── human.m.motemplate │ ├── machine.h.motemplate │ └── machine.m.motemplate ├── ddcli ├── DDCliApplication.h ├── DDCliApplication.m ├── DDCliParseException.h ├── DDCliParseException.m ├── DDCliUtil.h ├── DDCliUtil.m ├── DDCommandLineInterface.h ├── DDGetoptLongParser.h └── DDGetoptLongParser.m ├── mogenerator.h ├── mogenerator.m ├── mogenerator.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ └── mogenerator.xcscheme ├── mogenerator_Prefix.pch ├── momcom ├── NSAttributeDescription+momcom.h ├── NSAttributeDescription+momcom.m ├── NSEntityDescription+momcom.h ├── NSEntityDescription+momcom.m ├── NSFetchRequest+momcom.h ├── NSFetchRequest+momcom.m ├── NSFetchedPropertyDescription+momcom.h ├── NSFetchedPropertyDescription+momcom.m ├── NSManagedObjectModel+momcom.h ├── NSManagedObjectModel+momcom.m ├── NSPropertyDescription+momcom.h ├── NSPropertyDescription+momcom.m ├── NSRelationshipDescription+momcom.h └── NSRelationshipDescription+momcom.m ├── ponso ├── MKCDAGNode.h ├── MKCDAGNode.m ├── MKCNSEntityDescriptionAdditions.h ├── MKCNSEntityDescriptionAdditions.m ├── MKCNSManagedObjectModelAdditions.h ├── MKCNSManagedObjectModelAdditions.m ├── PONSO-LICENSE.txt └── generate.sh ├── resources ├── README.md └── mogenerator-template-vscode │ ├── .vscode │ └── launch.json │ ├── .vscodeignore │ ├── CHANGELOG.md │ ├── README.md │ ├── language-configuration.json │ ├── package.json │ ├── sample.png │ ├── syntaxes │ └── mogenerator-template.tmLanguage.json │ └── vsc-extension-quickstart.md ├── templates ├── MyBaseClass.h ├── MyBaseClass.m ├── human.h.motemplate ├── human.m.motemplate ├── human.swift.motemplate ├── machine.h.motemplate ├── machine.m.motemplate └── machine.swift.motemplate └── test ├── JREnum ├── JREnum.h ├── JREnumTest │ ├── JREnumTest.xcodeproj │ │ └── project.pbxproj │ └── JREnumTest │ │ ├── JREnumTest-Prefix.pch │ │ ├── SplitEnums.h │ │ ├── SplitEnums.m │ │ └── main.m └── README.md ├── MogenSwiftTest ├── MogenSwiftTest.xcodeproj │ └── project.pbxproj ├── MogenSwiftTest │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── MogenSwiftTest.xcdatamodeld │ │ ├── .xccurrentversion │ │ └── MogenSwiftTest.xcdatamodel │ │ │ └── contents │ ├── MogenSwiftTest │ │ ├── MyEntityMO.swift │ │ ├── UnorderedToManyDstMO.swift │ │ ├── UnorderedToManySrcMO.swift │ │ ├── _MyEntityMO.swift │ │ ├── _UnorderedToManyDstMO.swift │ │ └── _UnorderedToManySrcMO.swift │ └── main.swift └── MogenSwiftTestTests │ ├── Info.plist │ └── MogenSwiftTestTests.swift ├── README.markdown ├── Rakefile ├── objc ├── Gender.h ├── Gender.m ├── MyBaseClass.h ├── MyBaseClass.m ├── ParentMO.m ├── test-prefix.pch └── test.m ├── swift ├── Gender.swift ├── MyBaseClass.swift └── main.swift └── test.xcdatamodel └── contents /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Feature Request 2 | 3 | _What would you like to see that is not currently available?_ 4 | 5 | ### Question 6 | 7 | _What is not clear?_ 8 | 9 | ### Expected Behavior 10 | 11 | _What should happen?_ 12 | 13 | ### Actual Behavior 14 | 15 | _What happens instead?_ 16 | 17 | ### Additional Information 18 | 19 | _Platform / Use Case / etc._ 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Summary of Changes 2 | 3 | _Please offer a description of the code changes in your pull request._ 4 | 5 | ### Addresses 6 | 7 | _Tag any [issues](https://github.com/rentzch/mogenerator/issues) that are being addressed._ 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | *.la 4 | #*# 5 | .*.rej 6 | *.rej 7 | .*~ 8 | *~ 9 | .#* 10 | .DS_Store 11 | Icon? 12 | *~.nib 13 | build 14 | .metadata 15 | bin 16 | dist 17 | *.xcodeproj/*.mode* 18 | *.xcodeproj/*.pbxuser 19 | **/*.xcodeproj/* 20 | !**/*.xcodeproj/project.pbxproj 21 | /mogenerator.xcodeproj/project.xcworkspace/ 22 | !/mogenerator.xcodeproj/xcshareddata/ 23 | /mogenerator.xcodeproj/xcuserdata/ 24 | /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/ 25 | /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/xcuserdata/ 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode10.1 3 | #xcode_project: mogenerator.xcodeproj 4 | #xcode_scheme: mogenerator 5 | script: cd test && rake 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to mogenerator 2 | 3 | Thanks for your interest in making mogenerator better. 4 | 5 | It's easy to contribute to mogenerator: 6 | 7 | * Fork the repo on GitHub. 8 | * `git clone` a local copy. 9 | * Make sure the [tests pass](https://github.com/rentzsch/mogenerator/tree/master/test) on your fresh copy. 10 | * Create a new descriptively-named feature branch (or not, if it's just a small fix or something). 11 | * Make your changes. 12 | * Make sure the [tests pass](https://github.com/rentzsch/mogenerator/tree/master/test) with your modifications. 13 | * Push your changes to GitHub. 14 | * Issue your Pull Request to me. 15 | 16 | Before submitting a pull request with code, I highly recommend opening a new [issue][issue] and checking to make sure it's something we will accept as a new feature or patch. Bug fixes are usually 100% OK, but not every feature is something that will may be relevant to mogenerator's goals. 17 | 18 | ### Code Guidelines 19 | 20 | mogenerator doesn't have any specific coding guidelines at this point. Just do your best to match the existing style in the file you are working in. If you create a new file, try to match what everything else is doing. If it's not perfect, no one will lose much sleep. It can always be fixed later. :) 21 | 22 | Thanks for playing! 23 | 24 | [issue]: https://github.com/rentzsch/mogenerator/issues/new 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2019 Jonathan 'Wolf' Rentzsch 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /MiscMerge/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/MiscMerge/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /MiscMerge/FoundationAdditions.h: -------------------------------------------------------------------------------- 1 | /* FoundationAdditions.h created by lindberg on Mon 20-Dec-1999 */ 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | extern void ErrVPrintf(NSString *format, va_list arguments); 8 | extern void ErrPrintf(NSString *format, ...); 9 | extern void VPrintf(NSString *format, va_list arguments); 10 | extern void Printf(NSString *format, ...); 11 | 12 | /* Various Foundation methods for use by templates and/or EOGenerator */ 13 | 14 | @interface NSArray (FoundationAdditions) 15 | 16 | - (NSArray *)reversedArray; 17 | 18 | // Key-value additions (i.e. @reversedArray, @sortedNameArray, etc. keys) 19 | - (id)computeReversedArrayForKey:(NSString *)key; 20 | - (id)computeSortedNameArrayForKey:(NSString *)key; 21 | - (id)computeSortedStringArrayForKey:(NSString *)key; 22 | 23 | - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector; 24 | - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObject; 25 | - (NSArray *)arrayByMakingObjectsPerformSelector:(SEL)aSelector withObject:anObject withObject:anObject2; 26 | 27 | @end 28 | 29 | @interface NSString (FoundationAdditions) 30 | 31 | - (NSString *)initialCapitalString; 32 | - (NSString *)beautifyString; 33 | 34 | @end 35 | 36 | @interface NSFileManager (FoundationAdditions) 37 | 38 | - (BOOL)directoryExistsAtPath:(NSString *)path; 39 | - (BOOL)regularFileExistsAtPath:(NSString *)path; 40 | - (NSString *)findFile:(NSString *)filename inSearchPath:(NSArray *)paths; 41 | - (void)touchPath:(NSString *)filePath; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /MiscMerge/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleName 10 | ${PRODUCT_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.yourcocoaframework 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MiscMerge/KeyValue+MiscMerge.h: -------------------------------------------------------------------------------- 1 | // 2 | // KeyValue+MiscMerge.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | 19 | @interface NSObject (MiscMergeHasKey) 20 | 21 | - (BOOL)hasMiscMergeKey:(NSString *)key; 22 | - (BOOL)hasMiscMergeKeyPath:(NSString *)keyPath; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // MiscMergeCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | #import "MiscMergeEngine.h" 19 | #import "MiscMergeTemplate.h" 20 | 21 | @class NSScanner; 22 | @class NSNumber; 23 | @class MiscMergeExpression; 24 | 25 | @interface MiscMergeCommand : NSObject 26 | {} 27 | 28 | /*" Basic methods "*/ 29 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template; 30 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template; 31 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger; 32 | 33 | - (BOOL)isKindOfCommandClass:(NSString *)command; 34 | 35 | /*" Help with parsing "*/ 36 | - (BOOL)eatKeyWord:(NSString *)aKeyWord fromScanner:(NSScanner *)scanner isOptional:(BOOL)flag; 37 | - getArgumentStringFromScanner:(NSScanner *)scanner toEnd:(BOOL)endFlag quotes:(int *)quotes; 38 | - getArgumentStringFromScanner:(NSScanner *)scanner toEnd:(BOOL)endFlag; 39 | - getPromptFromScanner:(NSScanner *)scanner toEnd:(BOOL)endFlag; 40 | - getPromptableArgumentStringFromScanner:(NSScanner *)scanner wasPrompt:(BOOL *)prompt toEnd:(BOOL)endFlag; 41 | 42 | - (MiscMergeExpression *)getPrimaryExpressionFromScanner:(NSScanner *)aScanner; 43 | - (MiscMergeExpression *)getExpressionFromScanner:(NSScanner *)aScanner; 44 | 45 | /*" Error reporting "*/ 46 | - (void)error_conditional:(NSString *)theCond; 47 | - (void)error_keyword:(NSString *)aKeyWord; 48 | - (void)error_noprompt; 49 | - (void)error_closequote; 50 | - (void)error_closeparens; 51 | - (void)error_argument:(NSString *)theArgument; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeCommandBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // MiscMergeCommandBlock.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | 19 | @class NSArray, NSMutableArray; 20 | @class MiscMergeCommand; 21 | 22 | @interface MiscMergeCommandBlock : NSObject 23 | { 24 | NSMutableArray *commandArray; 25 | id owner; 26 | } 27 | 28 | - initWithOwner:(id)anOwner; 29 | 30 | - (NSArray *)commandArray; 31 | - (id)owner; 32 | 33 | - (void)addCommand:(MiscMergeCommand *)command; 34 | - (void)removeCommand:(MiscMergeCommand *)command; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeCommandBlock.m: -------------------------------------------------------------------------------- 1 | // 2 | // MiscMergeCommandBlock.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommandBlock.h" 18 | #import 19 | #import "MiscMergeCommand.h" 20 | 21 | @implementation MiscMergeCommandBlock 22 | /*" 23 | * A MiscMergeCommandBlock is a wrapper around an NSArray of 24 | * MiscMergeCommands. A MiscMergeTemplate has a top-level command block, 25 | * and MiscMergeCommand subclasses that perform logic surrounding arbitrary 26 | * command sequences (such as 'if' statements and loops) can have their own 27 | * MiscMergeCommandBlocks that can be substituted as the "current" block in 28 | * a MiscMergeTemplate during parsing. 29 | * 30 | * An "owner" can be set so that the MiscMergeCommand representing the 31 | * current block can be derived if necessary. 32 | * 33 | * During execution, commands should use the MiscMergeEngine method 34 | * -#executeCommandBlock: to execute the commands contained in the block. 35 | "*/ 36 | 37 | /*" 38 | * The designated initializer. anOwner is not retained. 39 | "*/ 40 | - initWithOwner:(id)anOwner 41 | { 42 | commandArray = [[NSMutableArray alloc] init]; 43 | owner = anOwner; 44 | return self; 45 | } 46 | 47 | - init 48 | { 49 | return [self initWithOwner:nil]; 50 | } 51 | 52 | - (void)dealloc 53 | { 54 | [commandArray release]; 55 | [super dealloc]; 56 | } 57 | 58 | /*" Returns the NSArray of MiscMergeCommands "*/ 59 | - (NSArray *)commandArray 60 | { 61 | return commandArray; 62 | } 63 | 64 | /*" 65 | * Returns the "owner" (usually a MiscMergeCommand subclass) set by 66 | * -#initWithOwner:. 67 | "*/ 68 | - (id)owner 69 | { 70 | return owner; 71 | } 72 | 73 | /*" Adds a MiscMergeCommand to the block. "*/ 74 | - (void)addCommand:(MiscMergeCommand *)command 75 | { 76 | [commandArray addObject:command]; 77 | } 78 | 79 | /*" 80 | * Removes command from the internal commandArray. This method should only 81 | * be used in rare circumstances, such as when it's necessary to move a 82 | * command from one block to another. 83 | "*/ 84 | - (void)removeCommand:(MiscMergeCommand *)command 85 | { 86 | [commandArray removeObjectIdenticalTo:command]; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeDriver.h: -------------------------------------------------------------------------------- 1 | // 2 | // MiscMergeDriver.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | 19 | @class NSArray; 20 | @class MiscMergeTemplate, MiscMergeEngine; 21 | 22 | @interface MiscMergeDriver : NSObject 23 | { 24 | MiscMergeTemplate *template; /*" MiscMergeTemplate for merging "*/ 25 | MiscMergeEngine *engine; /*" The merge engine to be used for merges "*/ 26 | NSArray *dataArray; /*" List of MiscDictionaries used for merges "*/ 27 | BOOL merging; /*" YES if merging, NO if not "*/ 28 | 29 | int _mergeLoopIndex; /*" Index to #{dataArray} when merge is in progress "*/ 30 | } 31 | 32 | /*" Accessing the template "*/ 33 | - (MiscMergeTemplate *)template; 34 | - (void)setTemplate:(MiscMergeTemplate *)aTemplate; 35 | 36 | /*" Accessing the data "*/ 37 | - (NSArray *)mergeData; 38 | - (void)setMergeData:(NSArray *)aList; 39 | 40 | /*" Performing a merge "*/ 41 | - (NSArray *)doMerge:sender; 42 | 43 | /*" Accessing the engine "*/ 44 | - (MiscMergeEngine *)engine; 45 | - (void)setEngine:(MiscMergeEngine *)anEngine; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeFunctions.h: -------------------------------------------------------------------------------- 1 | /* MiscMergeFunctions.h created by akira on Tue 03-Sep-2002 */ 2 | 3 | #import 4 | 5 | extern BOOL MMBoolValueOfObject(id anObject); 6 | extern int MMIntegerValueOfObject(id anObject); 7 | extern double MMDoubleValueForObject(id anObject); 8 | 9 | extern BOOL MMIsObjectANumber(id anObject); 10 | extern BOOL MMIsObjectAString(id anObject); 11 | extern BOOL MMIsBooleanTrueString(NSString *anObject); 12 | 13 | extern NSComparisonResult MMCompareFloats(float num1, float num2); 14 | 15 | extern Class MMCommonAnscestorClass(id obj1, id obj2); 16 | 17 | extern NSString *MMStringByTrimmingCommandSpace(NSString *string); 18 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeSpike_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MiscMergeSpike' target in the 'MiscMergeSpike' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /MiscMerge/MiscMergeTemplate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MiscMergeTemplate.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | 19 | @class NSMutableArray, NSCharacterSet; 20 | @class MiscMergeCommandBlock; 21 | 22 | typedef enum _MiscMergeTrimWhitespaceBehavior { 23 | MiscMergeKeepWhitespace, 24 | MiscMergeKeepNonBlankWhitespace, 25 | MiscMergeTrimWhitespace, 26 | MiscMergeIgnoreCommandSpaces 27 | } MiscMergeTrimWhitespaceBehavior; 28 | 29 | @interface MiscMergeTemplate : NSObject 30 | { 31 | MiscMergeCommandBlock *topLevelCommands; 32 | NSMutableArray *commandStack; 33 | NSString *startDelimiter; 34 | NSString *endDelimiter; 35 | int _lineNumber; 36 | NSString *_filename; 37 | NSCharacterSet *_parseStopChars; 38 | MiscMergeTrimWhitespaceBehavior _trimWhitespaceBehavior; 39 | id _delegate; 40 | } 41 | 42 | /*" Creating a MiscMergeTemplate "*/ 43 | + template; 44 | + templateWithString:(NSString *)aString; 45 | 46 | /*" Initializing a MiscMergeTemplate "*/ 47 | - init; 48 | - initWithString:(NSString *)string; 49 | - initWithContentsOfFile:(NSString *)filename; 50 | 51 | - (id)delegate; 52 | - (void)setDelegate:(id)anObject; 53 | 54 | - (NSString *)resolveTemplateFilename:(NSString *)resolveName; 55 | 56 | /*" Accessing/setting the delimiters "*/ 57 | + (NSString *)defaultStartDelimiter; 58 | + (NSString *)defaultEndDelimiter; 59 | - (NSString *)startDelimiter; 60 | - (NSString *)endDelimiter; 61 | - (void)setStartDelimiter:(NSString *)startDelim endDelimiter:(NSString *)endDelim; 62 | 63 | /*" Change behavior of blank space between commands "*/ 64 | - (MiscMergeTrimWhitespaceBehavior)trimWhitespaceBehavior; 65 | - (void)setTrimWhitespaceBehavior:(MiscMergeTrimWhitespaceBehavior)flag; 66 | 67 | /*" Command block manipulation "*/ 68 | - (void)pushCommandBlock:(MiscMergeCommandBlock *)aBlock; 69 | - (void)popCommandBlock:(MiscMergeCommandBlock *)aBlock; 70 | - (void)popCommandBlock; 71 | - (MiscMergeCommandBlock *)currentCommandBlock; 72 | - (MiscMergeCommandBlock *)topLevelCommandBlock; 73 | 74 | /*" Loading the template "*/ 75 | - (void)parseContentsOfFile:(NSString *)filename; 76 | - (void)parseString:(NSString *)string; 77 | - (void)reportParseError:(NSString *)format, ...; 78 | - (void)setFilename:(NSString *)filename; 79 | - (NSString *)filename; 80 | 81 | /*" Deriving the class for a command string "*/ 82 | - (Class)classForCommand:(NSString *)aCommand; 83 | 84 | @end 85 | 86 | 87 | @interface MiscMergeTemplateDelegate 88 | 89 | - (NSString *)mergeTemplate:(MiscMergeTemplate *)template resolveTemplateFilename:(NSString *)filename; 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /MiscMerge/MiscMerge_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MiscMerge' target in the 'MiscMerge' project. 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /MiscMerge/NSNull.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull.m 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | 19 | #if defined(NSFoundationVersionNumber10_0) || defined(GNUSTEP) 20 | #define HAVE_NSNULL 1 21 | #endif 22 | 23 | #if HAVE_NSNULL 24 | #import 25 | #else 26 | 27 | @interface NSNull : NSObject 28 | { 29 | } 30 | 31 | + (NSNull *)null; 32 | 33 | + (id)allocWithZone:(NSZone *)zone; 34 | - (void)dealloc; 35 | 36 | - (id)description; 37 | 38 | - (id)retain; 39 | - (oneway void)release; 40 | - (id)autorelease; 41 | - (unsigned)retainCount; 42 | 43 | - (id)copyWithZone:(NSZone *)zone; 44 | - (id)copy; 45 | 46 | - (void)encodeWithCoder:(NSCoder *)aCoder; 47 | - (instancetype)initWithCoder:(NSCoder *)aDecoder; 48 | 49 | - (id)replacementObjectForCoder:(NSCoder *)aCoder; 50 | 51 | - (id)valueForKey:(NSString *)key; 52 | 53 | @end 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /MiscMerge/NSNull.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull.m 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "NSNull.h" 18 | #import 19 | #import 20 | 21 | #if !HAVE_NSNULL 22 | 23 | static NSNull *_instance; 24 | 25 | @implementation NSNull 26 | 27 | + (id)null 28 | { 29 | if ( _instance == nil ) 30 | _instance = [(id)NSAllocateObject([NSNull class], 0, NULL) init]; 31 | 32 | return _instance; 33 | } 34 | 35 | + (id)allocWithZone:(NSZone *)zone { return [self null]; } 36 | 37 | - (void)dealloc {} 38 | 39 | - (id)description { return @""; } 40 | 41 | - (id)retain { return self; } 42 | - (oneway void)release {} 43 | - (id)autorelease { return self; } 44 | - (unsigned)retainCount { return UINT_MAX; } 45 | 46 | - (id)copyWithZone:(NSZone *)zone { return self; }; 47 | - (id)copy { return self; }; 48 | 49 | - (void)encodeWithCoder:(NSCoder *)aCoder {} 50 | - (id)initWithCoder:(NSCoder *)aDecoder { return self; } 51 | 52 | - (id)replacementObjectForCoder:(NSCoder *)aCoder { return self; } 53 | 54 | - (id)valueForKey:(NSString *)key { return nil; } 55 | 56 | @end 57 | #endif 58 | -------------------------------------------------------------------------------- /MiscMerge/NSScanner+MiscMerge.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSScanner+MiscMerge.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import 18 | #import 19 | 20 | @interface NSScanner (MiscMerge) 21 | 22 | - (BOOL)scanLetterIntoString:(NSString **)aString; 23 | 24 | - (BOOL)scanString:(NSString *)aString; 25 | 26 | - (NSRange)remainingRange; 27 | - (NSString *)remainingString; 28 | 29 | - (void)skipPastSkipCharacters; 30 | 31 | - (BOOL)scanCharacter:(unichar)targetCharacter; 32 | - (unichar)peekNextCharacter; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeBreakCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeBreakCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeBreakCommand : MiscMergeCommand 20 | @end 21 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeBreakCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeBreakCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeBreakCommand.h" 18 | 19 | @implementation _MiscMergeBreakCommand 20 | 21 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template { 22 | return YES; 23 | } 24 | 25 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger { 26 | return MiscMergeCommandExitBreak; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeCallCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeCallCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | 20 | @interface _MiscMergeCallCommand : MiscMergeCommand 21 | { 22 | NSString *procedureName; 23 | NSMutableArray *argumentArray; 24 | NSMutableArray *quotedArray; 25 | BOOL alreadyWarned; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeCommentCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeCommentCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeCommentCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeCommentCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeCommentCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeCommentCommand.h" 18 | 19 | @implementation _MiscMergeCommentCommand 20 | 21 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template; 22 | { 23 | return YES; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeContinueCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeContinueCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeContinueCommand : MiscMergeCommand 20 | @end 21 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeContinueCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeContinueCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2002-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeContinueCommand.h" 18 | 19 | @implementation _MiscMergeContinueCommand 20 | 21 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template { 22 | return YES; 23 | } 24 | 25 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger { 26 | return MiscMergeCommandExitContinue; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeCopyCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeCopyCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeCopyCommand : MiscMergeCommand 20 | { 21 | NSString *theText; 22 | } 23 | 24 | - (void)parseFromRawString:(NSString *)aString; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeCopyCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeCopyCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeCopyCommand.h" 18 | #import "NSString+MiscAdditions.h" 19 | #import "NSScanner+MiscMerge.h" 20 | 21 | @implementation _MiscMergeCopyCommand 22 | 23 | - (void)dealloc 24 | { 25 | [theText release]; 26 | [super dealloc]; 27 | } 28 | 29 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 30 | { 31 | if (![self eatKeyWord:@"copy" fromScanner:aScanner isOptional:NO]) return NO; 32 | 33 | theText = [[[aScanner remainingString] stringByTrimmingLeadWhitespace] retain]; 34 | 35 | return YES; 36 | } 37 | 38 | /*" Special method used by the template "*/ 39 | - (void)parseFromRawString:(NSString *)aString 40 | { 41 | theText = [aString retain]; 42 | } 43 | 44 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 45 | { 46 | [aMerger appendToOutput:theText]; 47 | return MiscMergeCommandExitNormal; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDateCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDateCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeDateCommand : MiscMergeCommand 20 | { 21 | NSString *dateFormat; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDateCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDateCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeDateCommand.h" 18 | #import 19 | #import 20 | 21 | /* On YellowBox, NSCalendarDate is now in its own header */ 22 | #import 23 | #if defined(FOUNDATION_STATIC_INLINE) || defined(GNUSTEP) 24 | #import 25 | #endif 26 | 27 | @class NSCalendarDate; 28 | 29 | @implementation _MiscMergeDateCommand 30 | 31 | - (void)dealloc 32 | { 33 | [dateFormat release]; 34 | [super dealloc]; 35 | } 36 | 37 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 38 | { 39 | [self eatKeyWord:@"date" fromScanner:aScanner isOptional:NO]; 40 | dateFormat = [self getArgumentStringFromScanner:aScanner toEnd:YES]; 41 | if ([dateFormat length] == 0) 42 | dateFormat = @"%B %d, %Y"; 43 | 44 | [dateFormat retain]; 45 | return YES; 46 | } 47 | 48 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 49 | { 50 | NSCalendarDate *currentDate = (NSCalendarDate *)[NSCalendarDate date]; 51 | [aMerger appendToOutput:[currentDate descriptionWithCalendarFormat:dateFormat]]; 52 | return MiscMergeCommandExitNormal; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDebugCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDebugCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2003-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeDebugCommand : MiscMergeCommand 20 | { 21 | NSString *theText; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDebugCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDebugCommand.m 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeDebugCommand.h" 18 | @import Foundation; 19 | #import "NSString+MiscAdditions.h" 20 | #import "NSScanner+MiscMerge.h" 21 | 22 | @implementation _MiscMergeDebugCommand 23 | 24 | - (void)dealloc 25 | { 26 | [theText release]; 27 | [super dealloc]; 28 | } 29 | 30 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 31 | { 32 | if (![self eatKeyWord:@"debug" fromScanner:aScanner isOptional:NO]) return NO; 33 | 34 | theText = [[[aScanner remainingString] stringByTrimmingLeadWhitespace] retain]; 35 | 36 | return YES; 37 | } 38 | 39 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 40 | { 41 | fwrite([theText cStringUsingEncoding:NSUTF8StringEncoding], 1, [theText lengthOfBytesUsingEncoding:NSUTF8StringEncoding], stderr); 42 | if (![theText hasSuffix:@"\n"]) 43 | fputc('\n', stderr); 44 | 45 | return MiscMergeCommandExitNormal; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDelayedParseCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDelayedParseCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeDelayedParseCommand : MiscMergeCommand 20 | { 21 | NSString *unparsedCommand; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeDelayedParseCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeDelayedParseCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeDelayedParseCommand.h" 18 | #import 19 | #import "MiscMergeEngine.h" 20 | #import "MiscMergeTemplate.h" 21 | #import "MiscMergeCommand.h" 22 | 23 | @implementation _MiscMergeDelayedParseCommand 24 | 25 | - (void)dealloc 26 | { 27 | [unparsedCommand release]; 28 | [super dealloc]; 29 | } 30 | 31 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template 32 | { 33 | unparsedCommand = [aString copy]; 34 | return YES; 35 | } 36 | 37 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 38 | { 39 | MiscMergeTemplate *myTemplate = [aMerger template]; 40 | Class templateClass = [myTemplate class]; 41 | Class mergerClass = [aMerger class]; 42 | Class commandClass; 43 | MiscMergeTemplate *newTemplate = [[templateClass alloc] init]; 44 | MiscMergeEngine *newEngine = [[mergerClass alloc] init]; 45 | MiscMergeCommand *newCommand; 46 | NSString *result; 47 | 48 | [newTemplate setStartDelimiter:[myTemplate startDelimiter] 49 | endDelimiter:[myTemplate endDelimiter]]; 50 | [newTemplate parseString:unparsedCommand]; 51 | 52 | [newEngine setTemplate:newTemplate]; 53 | [newEngine setParentMerge:aMerger]; 54 | [newEngine setMainObject:[aMerger mainObject]]; 55 | 56 | result = [newEngine execute:self]; 57 | 58 | /* Hrm. */ 59 | commandClass = [myTemplate classForCommand:result]; 60 | newCommand = [[commandClass alloc] init]; 61 | [newCommand parseFromString:result template:myTemplate]; 62 | [aMerger executeCommand:newCommand]; 63 | 64 | [newCommand release]; 65 | [newTemplate release]; 66 | [newEngine release]; 67 | return MiscMergeCommandExitNormal; 68 | } 69 | 70 | @end 71 | 72 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeElseCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeElseCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeElseCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeElseCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeElseCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeElseCommand.h" 18 | //#import 19 | #import "_MiscMergeIfCommand.h" 20 | #import "MiscMergeCommandBlock.h" 21 | 22 | @implementation _MiscMergeElseCommand 23 | 24 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template 25 | { 26 | _MiscMergeIfCommand *ifCommand = [[template currentCommandBlock] owner]; 27 | 28 | if (![ifCommand isKindOfCommandClass:@"If"]) 29 | { 30 | [template reportParseError:@"Mismatched else command"]; 31 | } 32 | else 33 | { 34 | [ifCommand handleElseInTemplate:template]; 35 | } 36 | 37 | return YES; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeElseifCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeElseifCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeIfCommand.h" 18 | 19 | @interface _MiscMergeElseifCommand : _MiscMergeIfCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeElseifCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeElseifCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeElseifCommand.h" 18 | //#import 19 | #import //for NULL on OSXPB 20 | #import "NSScanner+MiscMerge.h" 21 | #import "MiscMergeCommandBlock.h" 22 | 23 | @implementation _MiscMergeElseifCommand 24 | 25 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 26 | { 27 | MiscMergeCommandBlock *parentIfBlock = [template currentCommandBlock]; 28 | _MiscMergeIfCommand *parentIfCommand = [parentIfBlock owner]; 29 | 30 | if (![parentIfCommand isKindOfCommandClass:@"If"]) 31 | { 32 | [template reportParseError:@"Mismatched elseif command"]; 33 | } 34 | else 35 | { 36 | /* 37 | * This is a tad messy. We are already included in the parent if's 38 | * "true" block, so we need to remove it from there, apply an 39 | * "else", then add ourselves to the "else" block. This way 40 | * we convert the "elseif" to a nested "if" inside the parent's else 41 | * block. 42 | */ 43 | [parentIfBlock removeCommand:self]; 44 | [parentIfCommand handleElseInTemplate:template]; 45 | [[template currentCommandBlock] addCommand:self]; 46 | } 47 | 48 | /* 49 | * Scan past the "else", so we can treat the rest as a normal if 50 | * statement. A bit of a hack, but it works. 51 | */ 52 | [aScanner scanString:@"else" intoString:NULL]; 53 | return [super parseFromScanner:aScanner template:template]; 54 | } 55 | 56 | /* 57 | * Override to pop our block, and pop our parent's block as well (since we 58 | * are nested inside another if statement). If parent is another elseif 59 | * command, then the process will repeat until we get to the original if 60 | * command. 61 | */ 62 | - (void)handleEndifInTemplate:(MiscMergeTemplate *)template 63 | { 64 | _MiscMergeIfCommand *parentIfCommand; 65 | 66 | // first pop our command block 67 | [super handleEndifInTemplate:template]; 68 | 69 | // then pop our parent's block 70 | parentIfCommand = [[template currentCommandBlock] owner]; 71 | if (![parentIfCommand isKindOfCommandClass:@"If"]) 72 | { 73 | [template reportParseError:@"Mismatched endif command"]; 74 | } 75 | else 76 | { 77 | [parentIfCommand handleEndifInTemplate:template]; 78 | } 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndforeachCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndforeachCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeEndforeachCommand : MiscMergeCommand 20 | { 21 | NSString *loopName; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndforeachCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndforeachCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeEndforeachCommand.h" 18 | //#import 19 | #import 20 | #import "_MiscMergeForeachCommand.h" 21 | #import "MiscMergeCommandBlock.h" 22 | 23 | @implementation _MiscMergeEndforeachCommand 24 | 25 | - (void)dealloc 26 | { 27 | [loopName release]; 28 | [super dealloc]; 29 | } 30 | 31 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 32 | { 33 | _MiscMergeForeachCommand *foreachCommand = [[template currentCommandBlock] owner]; 34 | 35 | [self eatKeyWord:@"endforeach" fromScanner:aScanner isOptional:NO]; 36 | loopName = [[self getArgumentStringFromScanner:aScanner toEnd:NO] retain]; 37 | 38 | if (![foreachCommand isKindOfCommandClass:@"Foreach"] || 39 | ([loopName length] > 0 && [[foreachCommand loopName] length] > 0 && 40 | ![loopName isEqualToString:[foreachCommand loopName]])) 41 | { 42 | [template reportParseError:@"Mismatched endforeach command"]; 43 | } 44 | else 45 | { 46 | [foreachCommand handleEndForeachInTemplate:template]; 47 | } 48 | 49 | return YES; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndifCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndifCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeEndifCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndifCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndifCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeEndifCommand.h" 18 | //#import 19 | #import "_MiscMergeIfCommand.h" 20 | #import "MiscMergeCommandBlock.h" 21 | 22 | @implementation _MiscMergeEndifCommand 23 | 24 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template 25 | { 26 | _MiscMergeIfCommand *ifCommand = [[template currentCommandBlock] owner]; 27 | 28 | if (![ifCommand isKindOfCommandClass:@"If"]) 29 | { 30 | [template reportParseError:@"Mismatched endif command"]; 31 | } 32 | else 33 | { 34 | [ifCommand handleEndifInTemplate:template]; 35 | } 36 | 37 | return YES; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndloopCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndloopCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeEndloopCommand : MiscMergeCommand 20 | { 21 | NSString *loopName; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndloopCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndloopCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeEndloopCommand.h" 18 | //#import 19 | #import 20 | #import "_MiscMergeLoopCommand.h" 21 | #import "MiscMergeCommandBlock.h" 22 | 23 | @implementation _MiscMergeEndloopCommand 24 | 25 | - (void)dealloc 26 | { 27 | [loopName release]; 28 | [super dealloc]; 29 | } 30 | 31 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 32 | { 33 | _MiscMergeLoopCommand *loopCommand = [[template currentCommandBlock] owner]; 34 | 35 | [self eatKeyWord:@"endloop" fromScanner:aScanner isOptional:NO]; 36 | loopName = [[self getArgumentStringFromScanner:aScanner toEnd:NO] retain]; 37 | 38 | if (![loopCommand isKindOfCommandClass:@"Loop"] || 39 | ([loopName length] > 0 && [[loopCommand loopName] length] > 0 && 40 | ![loopName isEqualToString:[loopCommand loopName]])) 41 | { 42 | [template reportParseError:@"Mismatched endloop command"]; 43 | } 44 | else 45 | { 46 | [loopCommand handleEndLoopInTemplate:template]; 47 | } 48 | 49 | return YES; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndprocedureCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndprocedureCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeEndprocedureCommand : MiscMergeCommand 20 | { 21 | NSString *procName; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndprocedureCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndprocedureCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeEndprocedureCommand.h" 18 | //#import 19 | #import 20 | #import "_MiscMergeProcedureCommand.h" 21 | #import "MiscMergeCommandBlock.h" 22 | 23 | @implementation _MiscMergeEndprocedureCommand 24 | 25 | - (void)dealloc 26 | { 27 | [procName release]; 28 | [super dealloc]; 29 | } 30 | 31 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 32 | { 33 | _MiscMergeProcedureCommand *procCommand = [[template currentCommandBlock] owner]; 34 | 35 | [self eatKeyWord:@"endprocedure" fromScanner:aScanner isOptional:NO]; 36 | procName = [[self getArgumentStringFromScanner:aScanner toEnd:NO] retain]; 37 | 38 | if (![procCommand isKindOfCommandClass:@"Procedure"] || 39 | ([procName length] > 0 && [[procCommand procedureName] length] > 0 && 40 | ![procName isEqualToString:[procCommand procedureName]])) 41 | { 42 | [template reportParseError:@"Mismatched endprocedure command"]; 43 | } 44 | else 45 | { 46 | [procCommand handleEndProcedureInTemplate:template]; 47 | } 48 | 49 | return YES; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndwhileCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndwhileCommand.h 3 | // 4 | // Written by Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeEndwhileCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeEndwhileCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeEndwhileCommand.m 3 | // 4 | // Written by Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeEndwhileCommand.h" 18 | #import 19 | #import "_MiscMergeWhileCommand.h" 20 | #import "MiscMergeCommandBlock.h" 21 | 22 | @implementation _MiscMergeEndwhileCommand 23 | 24 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 25 | { 26 | _MiscMergeWhileCommand *whileCommand = [[template currentCommandBlock] owner]; 27 | 28 | [self eatKeyWord:@"endwhile" fromScanner:aScanner isOptional:NO]; 29 | 30 | if (![whileCommand isKindOfCommandClass:@"While"]) 31 | { 32 | [template reportParseError:@"Mismatched endwhile command"]; 33 | } 34 | else 35 | { 36 | [whileCommand handleEndWhileInTemplate:template]; 37 | } 38 | 39 | return YES; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeFieldCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeFieldCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class MiscMergeExpression; 20 | 21 | @interface _MiscMergeFieldCommand : MiscMergeCommand 22 | { 23 | MiscMergeExpression *expression; 24 | } 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeFieldCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeFieldCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeFieldCommand.h" 18 | #import "MiscMergeExpression.h" 19 | #import "NSString+MiscAdditions.h" 20 | #import "NSScanner+MiscMerge.h" 21 | 22 | @implementation _MiscMergeFieldCommand 23 | 24 | - (void)dealloc 25 | { 26 | [expression release]; 27 | [super dealloc]; 28 | } 29 | 30 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 31 | { 32 | [self eatKeyWord:@"field" fromScanner:aScanner isOptional:YES]; 33 | expression = [[self getExpressionFromScanner:aScanner] retain]; 34 | return YES; 35 | } 36 | 37 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 38 | { 39 | [aMerger appendToOutput:[expression evaluateWithEngine:aMerger]]; 40 | return MiscMergeCommandExitNormal; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeForeachCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeForeachCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class MiscMergeCommandBlock; 20 | 21 | @interface _MiscMergeForeachCommand : MiscMergeCommand 22 | { 23 | NSString *itemName; 24 | NSString *arrayField; 25 | int arrayQuote; 26 | NSString *loopName; 27 | MiscMergeCommandBlock *commandBlock; 28 | MiscMergeExpression *arrayExpression; 29 | } 30 | 31 | - (NSString *)loopName; 32 | - (void)handleEndForeachInTemplate:(MiscMergeTemplate *)template; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIdentifyCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIdentifyCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeSetCommand.h" 18 | 19 | @interface _MiscMergeIdentifyCommand : _MiscMergeSetmergeCommand 20 | @end 21 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIdentifyCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIdentifyCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeIdentifyCommand.h" 18 | #import "MiscMergeExpression.h" 19 | #import "NSString+MiscAdditions.h" 20 | 21 | @implementation _MiscMergeIdentifyCommand 22 | 23 | - (NSString *)commandString 24 | { 25 | return @"identify"; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIfCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIfCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class MiscMergeCommandBlock; 20 | 21 | @interface _MiscMergeIfCommand : MiscMergeCommand 22 | { 23 | MiscMergeExpression *expression; 24 | MiscMergeCommandBlock *trueBlock; 25 | MiscMergeCommandBlock *elseBlock; 26 | } 27 | 28 | - (void)handleElseInTemplate:(MiscMergeTemplate *)template; 29 | - (void)handleEndifInTemplate:(MiscMergeTemplate *)template; 30 | 31 | - (BOOL)evaluateExpressionInMerger:(MiscMergeEngine *)anEngine; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIfCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIfCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeIfCommand.h" 18 | //#import 19 | #import 20 | #import 21 | #import "MiscMergeCommandBlock.h" 22 | #import "MiscMergeExpression.h" 23 | 24 | @implementation _MiscMergeIfCommand 25 | 26 | - (instancetype)init 27 | { 28 | [super init]; 29 | trueBlock = [[MiscMergeCommandBlock alloc] initWithOwner:self]; 30 | return self; 31 | } 32 | 33 | - (void)dealloc 34 | { 35 | [trueBlock release]; 36 | [elseBlock release]; 37 | [expression release]; 38 | [super dealloc]; 39 | } 40 | 41 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 42 | { 43 | [self eatKeyWord:@"if" fromScanner:aScanner isOptional:NO]; 44 | expression = [[self getExpressionFromScanner:aScanner] retain]; 45 | [template pushCommandBlock:trueBlock]; 46 | return YES; 47 | } 48 | 49 | - (void)handleElseInTemplate:(MiscMergeTemplate *)template 50 | { 51 | if (elseBlock == nil) 52 | elseBlock = [[MiscMergeCommandBlock alloc] initWithOwner:self]; 53 | [template popCommandBlock:trueBlock]; 54 | [template pushCommandBlock:elseBlock]; 55 | } 56 | 57 | - (void)handleEndifInTemplate:(MiscMergeTemplate *)template 58 | { 59 | [template popCommandBlock]; 60 | } 61 | 62 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 63 | { 64 | if ([self evaluateExpressionInMerger:aMerger]) 65 | return [aMerger executeCommandBlock:trueBlock]; 66 | else if (elseBlock) 67 | return [aMerger executeCommandBlock:elseBlock]; 68 | return MiscMergeCommandExitNormal; 69 | } 70 | 71 | 72 | - (BOOL)evaluateExpressionInMerger:(MiscMergeEngine *)anEngine 73 | { 74 | return [expression evaluateAsBoolWithEngine:anEngine]; 75 | } 76 | 77 | @end 78 | 79 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIncludeCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIncludeCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeIncludeCommand : MiscMergeCommand 20 | { 21 | MiscMergeCommandBlock *commandBlock; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIncludeCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIncludeCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeIncludeCommand.h" 18 | #import 19 | //#import 20 | #import "MiscMergeTemplate.h" 21 | #import "MiscMergeCommandBlock.h" 22 | #import "MiscMergeEngine.h" 23 | 24 | @implementation _MiscMergeIncludeCommand 25 | 26 | - (void)dealloc 27 | { 28 | [commandBlock release]; 29 | [super dealloc]; 30 | } 31 | 32 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 33 | { 34 | NSString *filename; 35 | NSString *resolvedFilename; 36 | NSString *fileString = nil; 37 | NSString *startDelim = nil; 38 | NSString *endDelim = nil; 39 | 40 | [self eatKeyWord:@"include" fromScanner:aScanner isOptional:NO]; 41 | filename = [self getArgumentStringFromScanner:aScanner toEnd:NO]; 42 | startDelim = [self getArgumentStringFromScanner:aScanner toEnd:NO]; 43 | 44 | if ( [startDelim length] > 0 ) { 45 | endDelim = [self getArgumentStringFromScanner:aScanner toEnd:NO]; 46 | 47 | if ( [endDelim length] == 0 ) { 48 | [template reportParseError:@"%@: Must specify an end delimiter if specifying a start delimiter.", [self class]]; 49 | startDelim = nil; 50 | } 51 | } 52 | 53 | resolvedFilename = [template resolveTemplateFilename:filename]; 54 | 55 | NSError *error = nil; 56 | if ([resolvedFilename length] > 0) 57 | fileString = [NSString stringWithContentsOfFile:resolvedFilename encoding:NSUTF8StringEncoding error:&error]; 58 | 59 | if (fileString) 60 | { 61 | MiscMergeTemplate *newTemplate = [[[template class] alloc] init]; 62 | 63 | if ( startDelim != nil ) 64 | [newTemplate setStartDelimiter:startDelim endDelimiter:endDelim]; 65 | else 66 | [newTemplate setStartDelimiter:[template startDelimiter] endDelimiter:[template endDelimiter]]; 67 | 68 | [newTemplate setFilename:resolvedFilename]; 69 | [newTemplate setDelegate:[template delegate]]; 70 | [newTemplate parseString:fileString]; 71 | commandBlock = [[newTemplate topLevelCommandBlock] retain]; 72 | [newTemplate release]; 73 | } 74 | else 75 | { 76 | [template reportParseError:@"%@: Could not load from file '%@' because %@", [self class], resolvedFilename, [error localizedDescription]]; 77 | } 78 | 79 | return YES; 80 | } 81 | 82 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 83 | { 84 | if (commandBlock) 85 | return [aMerger executeCommandBlock:commandBlock]; 86 | return MiscMergeCommandExitNormal; 87 | } 88 | 89 | @end 90 | 91 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIndexCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIndexCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class MiscMergeExpression; 20 | 21 | @interface _MiscMergeIndexCommand : MiscMergeCommand 22 | { 23 | NSString *arrayField; 24 | int arrayQuote; 25 | MiscMergeExpression *theIndex; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeIndexCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeIndexCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeIndexCommand.h" 18 | #import "MiscMergeExpression.h" 19 | #import 20 | #import 21 | 22 | @implementation _MiscMergeIndexCommand 23 | 24 | - (void)dealloc 25 | { 26 | [arrayField release]; 27 | [super dealloc]; 28 | } 29 | 30 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 31 | { 32 | [self eatKeyWord:@"index" fromScanner:aScanner isOptional:NO]; 33 | arrayField = [[self getArgumentStringFromScanner:aScanner toEnd:NO quotes:&arrayQuote] retain]; 34 | theIndex = [[self getPrimaryExpressionFromScanner:aScanner] retain]; 35 | return YES; 36 | } 37 | 38 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 39 | { 40 | id theArray = [aMerger valueForField:arrayField quoted:arrayQuote]; 41 | 42 | if ( [theArray respondsToSelector:@selector(objectAtIndex:)] ) { 43 | int lookupIndex = [theIndex evaluateAsIntWithEngine:aMerger]; 44 | 45 | if ( (lookupIndex >= 0) && (lookupIndex < [theArray count]) ) { 46 | [aMerger appendToOutput:[theArray objectAtIndex:lookupIndex]]; 47 | } 48 | } 49 | else { 50 | [aMerger appendToOutput:theArray]; 51 | } 52 | 53 | return MiscMergeCommandExitNormal; 54 | } 55 | 56 | @end 57 | 58 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeLoopCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeLoopCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class MiscMergeCommandBlock; 20 | @class MiscMergeExpression; 21 | 22 | @interface _MiscMergeLoopCommand : MiscMergeCommand 23 | { 24 | NSString *indexName; 25 | NSString *loopName; 26 | MiscMergeExpression *startKey; 27 | MiscMergeExpression *stopKey; 28 | MiscMergeExpression *stepKey; 29 | MiscMergeCommandBlock *commandBlock; 30 | } 31 | 32 | - (NSString *)loopName; 33 | - (void)handleEndLoopInTemplate:(MiscMergeTemplate *)template; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeNextCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeNextCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeNextCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeNextCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeNextCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeNextCommand.h" 18 | 19 | @implementation _MiscMergeNextCommand 20 | 21 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template; 22 | { 23 | return YES; 24 | } 25 | 26 | 27 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 28 | { 29 | [aMerger advanceRecord]; 30 | return MiscMergeCommandExitNormal; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeOmitCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeOmitCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeOmitCommand : MiscMergeCommand 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeOmitCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeOmitCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeOmitCommand.h" 18 | 19 | @implementation _MiscMergeOmitCommand 20 | 21 | - (BOOL)parseFromString:(NSString *)aString template:(MiscMergeTemplate *)template; 22 | { 23 | return YES; 24 | } 25 | 26 | 27 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 28 | { 29 | [aMerger abortMerge]; 30 | return MiscMergeCommandExitNormal; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeOptionCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeOptionCommand.h 3 | // 4 | // Written by Doug McClure 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Doug McClure. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeOptionCommand : MiscMergeCommand 20 | { 21 | int optionType; 22 | NSString *value1; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeProcedureCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeProcedureCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @class NSArray; 20 | @class MiscMergeCommandBlock; 21 | 22 | @interface _MiscMergeProcedureCommand : MiscMergeCommand 23 | { 24 | NSString *procedureName; 25 | MiscMergeCommandBlock *commandBlock; 26 | NSMutableArray *argumentArray; 27 | NSMutableArray *argumentTypes; 28 | } 29 | 30 | - (NSString *)procedureName; 31 | 32 | /*" Called by the endprocedure command "*/ 33 | - (void)handleEndProcedureInTemplate:(MiscMergeTemplate *)template; 34 | 35 | /*" Called by the call command "*/ 36 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger arguments:(NSArray *)passedArgArray; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeSetCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeSetCommand.h 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeSetCommand : MiscMergeCommand 20 | { 21 | NSString *field1; 22 | MiscMergeExpression *expression; 23 | } 24 | 25 | @end 26 | 27 | @interface _MiscMergeSetglobalCommand : _MiscMergeSetCommand 28 | @end 29 | 30 | @interface _MiscMergeSetengineCommand : _MiscMergeSetCommand 31 | @end 32 | 33 | @interface _MiscMergeSetmergeCommand : _MiscMergeSetCommand 34 | @end 35 | 36 | @interface _MiscMergeSetlocalCommand : _MiscMergeSetCommand 37 | @end 38 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeWhileCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeWhileCommand.h 3 | // 4 | // Written by Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "MiscMergeCommand.h" 18 | 19 | @interface _MiscMergeWhileCommand : MiscMergeCommand 20 | { 21 | MiscMergeExpression *expression; 22 | MiscMergeCommandBlock *commandBlock; 23 | } 24 | 25 | - (void)handleEndWhileInTemplate:(MiscMergeTemplate *)template; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /MiscMerge/_MiscMergeWhileCommand.m: -------------------------------------------------------------------------------- 1 | // 2 | // _MiscMergeWhileCommand.m 3 | // 4 | // Written by Don Yacktman and Carl Lindberg 5 | // 6 | // Copyright 2001-2004 by Don Yacktman and Carl Lindberg. 7 | // All rights reserved. 8 | // 9 | // This notice may not be removed from this source code. 10 | // 11 | // This header is included in the MiscKit by permission from the author 12 | // and its use is governed by the MiscKit license, found in the file 13 | // "License.rtf" in the MiscKit distribution. Please refer to that file 14 | // for a list of all applicable permissions and restrictions. 15 | // 16 | 17 | #import "_MiscMergeWhileCommand.h" 18 | #import 19 | #import "MiscMergeCommandBlock.h" 20 | #import "MiscMergeExpression.h" 21 | 22 | @implementation _MiscMergeWhileCommand 23 | 24 | - init 25 | { 26 | [super init]; 27 | commandBlock = [[MiscMergeCommandBlock alloc] initWithOwner:self]; 28 | return self; 29 | } 30 | 31 | - (void)dealloc 32 | { 33 | [expression release]; 34 | [commandBlock release]; 35 | [super dealloc]; 36 | } 37 | 38 | - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)template 39 | { 40 | [self eatKeyWord:@"while" fromScanner:aScanner isOptional:NO]; 41 | expression = [[self getExpressionFromScanner:aScanner] retain]; 42 | [template pushCommandBlock:commandBlock]; 43 | 44 | return YES; 45 | } 46 | 47 | - (void)handleEndWhileInTemplate:(MiscMergeTemplate *)template 48 | { 49 | [template popCommandBlock:commandBlock]; 50 | } 51 | 52 | - (MiscMergeCommandExitType)executeForMerge:(MiscMergeEngine *)aMerger 53 | { 54 | MiscMergeCommandExitType exitCode = MiscMergeCommandExitNormal; 55 | 56 | while (exitCode != MiscMergeCommandExitBreak && [expression evaluateAsBoolWithEngine:aMerger]) { 57 | exitCode = [aMerger executeCommandBlock:commandBlock]; 58 | } 59 | 60 | return MiscMergeCommandExitNormal; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /build-mogenerator-Info-plist.sh: -------------------------------------------------------------------------------- 1 | TMPDIR=${DERIVED_FILE_DIR} 2 | rm -f "${TMPDIR}/mogenerator-Info.plist" 3 | /usr/libexec/PlistBuddy \ 4 | -c "Clear" \ 5 | -c "Import :human.h.motemplate templates/human.h.motemplate" \ 6 | -c "Import :human.m.motemplate templates/human.m.motemplate" \ 7 | -c "Import :human.swift.motemplate templates/human.swift.motemplate" \ 8 | -c "Import :machine.h.motemplate templates/machine.h.motemplate" \ 9 | -c "Import :machine.m.motemplate templates/machine.m.motemplate" \ 10 | -c "Import :machine.swift.motemplate templates/machine.swift.motemplate" \ 11 | "${TMPDIR}/mogenerator-Info.plist" 12 | -------------------------------------------------------------------------------- /categories/NSString+MORegEx.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | NS_ASSUME_NONNULL_BEGIN 4 | @interface NSString (MORegEx) 5 | 6 | - (NSArray *)captureComponentsMatchedByRegex:(NSString *)pattern; 7 | 8 | - (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)pattern withString:(NSString *)replacementString; 9 | 10 | - (BOOL)isMatchedByRegex:(NSString *)pattern; 11 | 12 | @end 13 | NS_ASSUME_NONNULL_END -------------------------------------------------------------------------------- /categories/NSString+MORegEx.m: -------------------------------------------------------------------------------- 1 | #import "NSString+MORegEx.h" 2 | 3 | @implementation NSString (MORegEx) 4 | 5 | - (NSArray *)captureComponentsMatchedByRegex:(NSString *)pattern 6 | { 7 | NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; 8 | 9 | return [regex matchesInString:self options:0 range:NSMakeRange(0, [self length])]; 10 | } 11 | 12 | - (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)pattern withString:(NSString *)replacementString 13 | { 14 | NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; 15 | 16 | NSString *updatedString = [regex stringByReplacingMatchesInString:self options:0 range:NSMakeRange(0, [self length]) withTemplate:replacementString]; 17 | return updatedString; 18 | } 19 | 20 | - (BOOL)isMatchedByRegex:(NSString *)pattern 21 | { 22 | NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; 23 | 24 | NSUInteger matchCount = [regex numberOfMatchesInString:self options:0 range:NSMakeRange(0, [self length])]; 25 | return (matchCount > 0); 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /contributed templates/Brian Webster/Diff template readme.txt: -------------------------------------------------------------------------------- 1 | Diff mogenerator template 2 | ------------------------- 3 | This template was created for the use case of merging two versions of a .xcdatamodel file, 4 | e.g. when doing a merge in a version control system. Since data model files are stored as 5 | binary data, there is no way to directly diff them. Additionally, since it's an undocumented 6 | format, even if we're able to diff them, there still isn't any way to automatically apply those diffs. 7 | 8 | The template itself basically just dumps the relevant properties and relationships for each 9 | entity in the data model into a pseudo plist looking format, with each relevant attribute put 10 | on its own line. In order to merge two versions of a data model, you would perform the following 11 | steps: 12 | 13 | 1. Run mogenerator on each of the two versions of the data model and put the results into two 14 | different directories. 15 | 2. Use your favorite diff tool to diff the two resulting directories 16 | 3. Look at the changes in each class, then use the data model editor in Xcode to manually apply 17 | each change to one of the two versions of the data model, so that they match 18 | 4. Once you've gone through and made all the changes, you can re-run mogenerator on the edited 19 | version, re-diff them, and double check that you didn't miss anything 20 | 21 | The one major caveat here is that only entites in the data model are currently handled, so if 22 | your model has any fetch request templates in it, those will not be included in the output. 23 | If anyone wants to add them to the output, feel free. :) -------------------------------------------------------------------------------- /contributed templates/Brian Webster/machine.h.motemplate: -------------------------------------------------------------------------------- 1 | { 2 | name = <$name$>, 3 | managedObjectClassName = <$managedObjectClassName$>, 4 | renamingIdentifier = <$renamingIdentifier$>, 5 | isAbstract = <$isAbstract$>, 6 | userInfo = <$userInfo$>, 7 | relationships = ( 8 | <$foreach Relationship noninheritedRelationships do$> 9 | { 10 | name = <$Relationship.name$>, 11 | isIndexed = <$Relationship.isIndexed$>, 12 | isTransient = <$Relationship.isTransient$>, 13 | isOptional = <$Relationship.isOptional$>, 14 | userInfo = <$Relationship.userInfo$>, 15 | destinationEntity = <$Relationship.destinationEntity.name$>, 16 | inverseRelationship = <$Relationship.inverseRelationship.name$>, 17 | deleteRule = <$Relationship.deleteRule$>, 18 | maxCount = <$Relationship.maxCount$>, 19 | minCount = <$Relationship.minCount$>, 20 | isToMany = <$Relationship.isToMany$> 21 | } 22 | <$endforeach do$> 23 | ) 24 | attributes = ( 25 | <$foreach Attribute noninheritedAttributes do$> 26 | { 27 | name = <$Attribute.name$>, 28 | isIndexed = <$Attribute.isIndexed$>, 29 | isTransient = <$Attribute.isTransient$>, 30 | isOptional = <$Attribute.isOptional$>, 31 | userInfo = <$Attribute.userInfo$>, 32 | attributeType = <$Attribute.attributeType$>, 33 | attributeValueClassName = <$Attribute.attributeValueClassName$>, 34 | defaultValue = <$Attribute.defaultValue$>, 35 | valueTransformerName = <$Attribute.valueTransformerName$> 36 | } 37 | <$end> 38 | ) 39 | } -------------------------------------------------------------------------------- /contributed templates/Dan Wood/Generating Standard Objects from Core Data Models.webloc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | URL 6 | http://gigliwood.com/weblog/Cocoa/Generating_Standard.html 7 | 8 | 9 | -------------------------------------------------------------------------------- /contributed templates/Dan Wood/human.h.motemplate: -------------------------------------------------------------------------------- 1 | #import "_<$managedObjectClassName$>.h" 2 | 3 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> 4 | { 5 | 6 | } 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /contributed templates/Dan Wood/human.m.motemplate: -------------------------------------------------------------------------------- 1 | #import "<$managedObjectClassName$>.h" 2 | 3 | @implementation <$managedObjectClassName$> 4 | 5 | 6 | 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /contributed templates/Dan Wood/machine.h.motemplate: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 2 | // Make changes to <$managedObjectClassName$>.h instead. 3 | 4 | #import 5 | <$if hasCustomSuperentity$>#import "<$customSuperentity$>.h"<$endif$> 6 | 7 | <$foreach Relationship noninheritedRelationships do$> 8 | @class <$Relationship.destinationEntity.managedObjectClassName$>; 9 | <$endforeach do$> 10 | 11 | @interface _<$managedObjectClassName$> : <$customSuperentity$> { 12 | <$foreach Attribute noninheritedAttributes do$> 13 | <$if Attribute.hasScalarAttributeType$> 14 | <$Attribute.scalarAttributeType$> my<$Attribute.name.initialCapitalString$>; 15 | <$else$> 16 | <$if Attribute.hasDefinedAttributeType$> 17 | <$Attribute.attributeValueClassName$> *my<$Attribute.name.initialCapitalString$>; 18 | <$else$> 19 | id my<$Attribute.name.initialCapitalString$>; 20 | <$endif$> 21 | <$endif$> 22 | <$endforeach do$> 23 | <$foreach Relationship noninheritedRelationships do$> 24 | <$if Relationship.isToMany$> 25 | NSMutableSet *my<$Relationship.name.initialCapitalString$>s; 26 | <$else$> 27 | <$Relationship.destinationEntity.managedObjectClassName$> *my<$Relationship.name.initialCapitalString$>; 28 | <$endif$> 29 | <$endforeach do$> 30 | } 31 | <$foreach Attribute noninheritedAttributes do$> 32 | <$if Attribute.hasScalarAttributeType$> 33 | - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>; 34 | - (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.scalarAttributeType$>)value_; 35 | <$else$> 36 | <$if Attribute.hasDefinedAttributeType$> 37 | - (<$Attribute.attributeValueClassName$> *)<$Attribute.name$>; 38 | - (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.attributeValueClassName$> *)value_; 39 | <$else$> 40 | - (id)<$Attribute.name$>; 41 | - (void)set<$Attribute.name.initialCapitalString$>:(id)value_; 42 | <$endif$> 43 | <$endif$> 44 | <$endforeach do$> 45 | <$foreach Relationship noninheritedRelationships do$> 46 | <$if Relationship.isToMany$> 47 | - (void)add<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$> *)value_; 48 | - (void)remove<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$> *)value_; 49 | - (NSMutableSet *)<$Relationship.name$>s; 50 | - (void)set<$Relationship.name.initialCapitalString$>s:(NSMutableSet *)value_; 51 | <$else$> 52 | - (<$Relationship.destinationEntity.managedObjectClassName$> *)<$Relationship.name$>; 53 | - (void)set<$Relationship.name.initialCapitalString$>:(<$Relationship.destinationEntity.managedObjectClassName$> *)value_; 54 | <$endif$> 55 | <$endforeach do$> 56 | @end 57 | -------------------------------------------------------------------------------- /contributed templates/Louis Gerbarg/human.h.motemplate: -------------------------------------------------------------------------------- 1 | #import "_<$managedObjectClassName$>.h" 2 | 3 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> {} 4 | // Custom logic goes here. 5 | @end 6 | -------------------------------------------------------------------------------- /contributed templates/Louis Gerbarg/human.m.motemplate: -------------------------------------------------------------------------------- 1 | #import "<$managedObjectClassName$>.h" 2 | 3 | @implementation <$managedObjectClassName$> 4 | 5 | // Custom logic goes here. 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /contributed templates/Louis Gerbarg/machine.h.motemplate: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 2 | // Make changes to <$managedObjectClassName$>.h instead. 3 | 4 | #import 5 | <$if hasCustomSuperentity$>#import "<$customSuperentity$>.h"<$endif$> 6 | 7 | <$foreach Relationship noninheritedRelationships do$> 8 | @class <$Relationship.destinationEntity.managedObjectClassName$>; 9 | <$endforeach do$> 10 | 11 | @interface _<$managedObjectClassName$> : <$if hasCustomSuperentity$><$customSuperentity$><$else$>NSObject<$endif$> { 12 | <$foreach Attribute noninheritedAttributes do$> 13 | <$if Attribute.hasDefinedAttributeType$> 14 | <$Attribute.attributeValueClassName$> *<$Attribute.name$>; 15 | <$endif$> 16 | <$endforeach do$> 17 | <$foreach Relationship noninheritedRelationships do$> 18 | <$if Relationship.isToMany$> 19 | NSMutableArray *<$Relationship.name$>; 20 | <$else$> 21 | <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; 22 | <$endif$> 23 | <$endforeach do$> 24 | } 25 | 26 | <$foreach Attribute noninheritedAttributes do$> 27 | <$if Attribute.hasDefinedAttributeType$> 28 | @property (retain) <$Attribute.attributeValueClassName$> *<$Attribute.name$>; 29 | <$if Attribute.hasScalarAttributeType$> 30 | - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value; 31 | - (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_; 32 | <$endif$> 33 | <$endif$> 34 | <$endforeach do$> 35 | <$foreach Relationship noninheritedRelationships do$> 36 | <$if Relationship.isToMany$> 37 | @property (retain, nonatomic) NSMutableArray *<$Relationship.name$>; 38 | <$else$> 39 | @property (retain, nonatomic) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; 40 | <$endif$> 41 | <$endforeach do$> 42 | @end 43 | -------------------------------------------------------------------------------- /contributed templates/Louis Gerbarg/machine.m.motemplate: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 2 | // Make changes to <$managedObjectClassName$>.m instead. 3 | 4 | #import "_<$managedObjectClassName$>.h" 5 | 6 | @implementation _<$managedObjectClassName$> 7 | 8 | - (void) dealloc { 9 | <$foreach Attribute noninheritedAttributes do$> 10 | self.<$Attribute.name$> = nil; 11 | <$endforeach do$> 12 | <$foreach Relationship noninheritedRelationships do$> 13 | self.<$Relationship.name$> = nil; 14 | <$endforeach do$> 15 | [super dealloc]; 16 | } 17 | 18 | <$foreach Attribute noninheritedAttributes do$> 19 | <$if Attribute.hasDefinedAttributeType$> 20 | 21 | @synthesize <$Attribute.name$>; 22 | 23 | <$if Attribute.hasScalarAttributeType$> 24 | 25 | - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value { 26 | NSNumber *result = [self <$Attribute.name$>]; 27 | return result ? [result <$Attribute.scalarAttributeType.camelCaseString$>Value] : 0; 28 | } 29 | 30 | - (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ { 31 | [self set<$Attribute.name.initialCapitalString$>:[NSNumber numberWith<$Attribute.scalarAttributeType.camelCaseString.initialCapitalString$>:value_]]; 32 | } 33 | 34 | <$endif$> 35 | <$endif$> 36 | <$endforeach do$> 37 | 38 | <$foreach Relationship noninheritedRelationships do$> 39 | @synthesize <$Relationship.name$>; 40 | <$endforeach do$> 41 | @end 42 | -------------------------------------------------------------------------------- /contributed templates/Louis Gerbarg/tweet.webloc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | URL 6 | http://twitter.com/lgerbarg/statuses/817641236 7 | 8 | 9 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/README.txt: -------------------------------------------------------------------------------- 1 | PONSO - Plain Old NSObjects 2 | =========================== 3 | 4 | What is PONSO? 5 | -------------- 6 | The idea is to use mogenerator to generate lightweight, memory-only, type-safe ObjC data model classes from Xcode data models. 7 | 8 | Features 9 | -------- 10 | - Type-safe attributes 11 | - Supports one-to-one and one-to-many relationships 12 | - Relationships are always ordered - implemented with NSArrays 13 | - Supports inverse relationships, which should be always marked as 'transient' 14 | - Supports serialization of any model object to NSDictionary and initialization from NSDictionary 15 | - Supports writing and reading to binary property list files 16 | - 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. 17 | - 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. 18 | - 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. 19 | - Cycles between weak relationships are found automatically and are warned about during code generation. 20 | 21 | 22 | How to use 23 | ---------- 24 | - 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" 25 | - See "contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest" project for sample setup 26 | 27 | 28 | TODO 29 | ----- 30 | PONSO is a work in progress and can be enchanced in a various ways. 31 | 32 | Some missing features include: 33 | - Automatic setting of inverse one-to-one relationships in setters 34 | - Support for many-to-many relationships 35 | - Implementations of to-many relationships as ordered sets instead of arrays 36 | - Detection of retain cycles caused by both relationship directions being non-transient 37 | 38 | Feel free to fork & contribute. 39 | 40 | 41 | Contact info 42 | ------------- 43 | Nikita Zhuk, 2011 44 | Twitter: @nzhuk 45 | 46 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/code/ModelObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Marko Karppinen & Co. LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | ModelObject.h 17 | mogenerator / PONSO 18 | Created by Nikita Zhuk on 22.1.2011. 19 | */ 20 | 21 | /** 22 | Abstract superclass for all of our model classes. 23 | */ 24 | 25 | #import 26 | 27 | @interface ModelObject : NSObject 28 | { 29 | NSDictionary *sourceDictionaryRepresentation; 30 | } 31 | 32 | @property(nonatomic, retain) NSDictionary *sourceDictionaryRepresentation; 33 | 34 | /** 35 | Reads and deserializes a ModelObject from plist at given \c filePath 36 | \return Newly created ModelObject or nil if any of the following occurs: file doesn't exist, file cannot be read, plist cannot be parsed. 37 | */ 38 | + (id)createModelObjectFromFile:(NSString *)filePath; 39 | 40 | /** 41 | Serializes the receiver into binary plist and writes it to given \c filePath. Creates any intermediate directories in the path if necessary. 42 | \return YES on success, NO on error (binary serialization or I/O error). 43 | */ 44 | - (BOOL)writeToFile:(NSString *)filePath; 45 | 46 | - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary; 47 | - (NSDictionary *)dictionaryRepresentation; 48 | 49 | - (void)awakeFromDictionaryRepresentationInit; 50 | 51 | @end 52 | 53 | 54 | @interface NSMutableDictionary (PONSONSMutableDictionaryAdditions) 55 | 56 | - (void)setObjectIfNotNil:(id)obj forKey:(NSString *)key; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | MyModel.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PonsoTest' target in the 'PonsoTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import "Model.h" 8 | #endif 9 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/Model.h: -------------------------------------------------------------------------------- 1 | #import "ModelAssistant.h" 2 | #import "ModelCompany.h" 3 | #import "ModelDepartment.h" 4 | #import "ModelDepartmentAssistant.h" 5 | #import "ModelDepartmentEmployee.h" 6 | #import "ModelEmployee.h" 7 | 8 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelAssistant.h" 8 | 9 | @interface ModelAssistant : _ModelAssistant <_ModelAssistant> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelAssistant.h" 8 | 9 | @implementation ModelAssistant 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelCompany.h" 8 | 9 | @interface ModelCompany : _ModelCompany <_ModelCompany> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelCompany.h" 8 | 9 | @implementation ModelCompany 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartment.h" 8 | 9 | @interface ModelDepartment : _ModelDepartment <_ModelDepartment> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartment.h" 8 | 9 | @implementation ModelDepartment 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartmentAssistant.h" 8 | 9 | @interface ModelDepartmentAssistant : _ModelDepartmentAssistant <_ModelDepartmentAssistant> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartmentAssistant.h" 8 | 9 | @implementation ModelDepartmentAssistant 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID 15 | { 16 | NSAssert(self.department.company != nil, @""); 17 | 18 | return [[self.department.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartmentEmployee.h" 8 | 9 | @interface ModelDepartmentEmployee : _ModelDepartmentEmployee <_ModelDepartmentEmployee> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartmentEmployee.h" 8 | 9 | @implementation ModelDepartmentEmployee 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | - (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID 15 | { 16 | NSAssert(self.department.company != nil, @""); 17 | 18 | return [[self.department.company.employees filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelEmployee.h" 8 | 9 | @interface ModelEmployee : _ModelEmployee <_ModelEmployee> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelEmployee.h" 8 | 9 | @implementation ModelEmployee 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID 14 | { 15 | NSAssert(self.company != nil, @""); 16 | 17 | return [[self.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelAssistant.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelEmployee; 15 | @class ModelCompany; 16 | @class ModelDepartmentAssistant; 17 | 18 | 19 | @protocol _ModelAssistant 20 | 21 | @end 22 | 23 | 24 | @interface _ModelAssistant : ModelObject 25 | { 26 | NSDate *birthDate; 27 | NSString *name; 28 | 29 | 30 | ModelEmployee *boss; 31 | 32 | ModelCompany *company; 33 | 34 | NSArray *departments; 35 | 36 | } 37 | 38 | @property (nonatomic, retain, readwrite) NSDate *birthDate; 39 | @property (nonatomic, retain, readwrite) NSString *name; 40 | 41 | @property (nonatomic, assign, readwrite) ModelEmployee *boss; 42 | 43 | @property (nonatomic, assign, readwrite) ModelCompany *company; 44 | 45 | @property (nonatomic, retain, readonly) NSArray *departments; 46 | 47 | 48 | 49 | 50 | - (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_; 51 | - (void)removeDepartmentsObjects; 52 | - (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_; 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelAssistant.h instead. 8 | // 9 | 10 | #import "_ModelAssistant.h" 11 | 12 | #import "ModelEmployee.h" 13 | #import "ModelCompany.h" 14 | #import "ModelDepartmentAssistant.h" 15 | 16 | 17 | @interface _ModelAssistant() 18 | @property (nonatomic, retain, readwrite) NSArray *departments; 19 | 20 | @end 21 | 22 | /** \ingroup DataModel */ 23 | 24 | @implementation _ModelAssistant 25 | 26 | - (id)init 27 | { 28 | if((self = [super init])) 29 | { 30 | 31 | } 32 | 33 | return self; 34 | } 35 | 36 | #pragma mark Scalar values 37 | 38 | 39 | 40 | #pragma mark Dictionary representation 41 | 42 | - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary 43 | { 44 | if((self = [super initWithDictionaryRepresentation:dictionary])) 45 | { 46 | self.birthDate = [dictionary objectForKey:@"ModelAssistant.birthDate"]; 47 | self.name = [dictionary objectForKey:@"ModelAssistant.name"]; 48 | 49 | 50 | } 51 | 52 | return self; 53 | } 54 | 55 | - (NSDictionary *)dictionaryRepresentation 56 | { 57 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; 58 | [dict setObjectIfNotNil:self.birthDate forKey:@"ModelAssistant.birthDate"]; 59 | [dict setObjectIfNotNil:self.name forKey:@"ModelAssistant.name"]; 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | if([self.departments count] > 0) 70 | { 71 | 72 | } 73 | 74 | 75 | return dict; 76 | } 77 | 78 | - (void)awakeFromDictionaryRepresentationInit 79 | { 80 | if(self.sourceDictionaryRepresentation == nil) 81 | return; // awakeFromDictionaryRepresentationInit has been already executed on this object. 82 | 83 | 84 | 85 | 86 | 87 | 88 | [super awakeFromDictionaryRepresentationInit]; 89 | } 90 | 91 | #pragma mark Direct access 92 | 93 | 94 | - (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_ 95 | { 96 | if(self.departments == nil) 97 | { 98 | self.departments = [NSMutableArray array]; 99 | } 100 | 101 | [(NSMutableArray *)self.departments addObject:value_]; 102 | value_.assistant = (ModelAssistant*)self; 103 | } 104 | 105 | - (void)removeDepartmentsObjects 106 | { 107 | self.departments = [NSMutableArray array]; 108 | } 109 | 110 | - (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_ 111 | { 112 | value_.assistant = nil; 113 | [(NSMutableArray *)self.departments removeObject:value_]; 114 | } 115 | 116 | 117 | 118 | - (void)dealloc 119 | { 120 | self.birthDate = nil; 121 | self.name = nil; 122 | 123 | self.boss = nil; 124 | self.company = nil; 125 | self.departments = nil; 126 | 127 | [super dealloc]; 128 | } 129 | 130 | #pragma mark Synthesizes 131 | 132 | @synthesize birthDate; 133 | @synthesize name; 134 | 135 | @synthesize boss; 136 | @synthesize company; 137 | @synthesize departments; 138 | 139 | @end 140 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelCompany.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelAssistant; 15 | @class ModelDepartment; 16 | @class ModelEmployee; 17 | 18 | 19 | @protocol _ModelCompany 20 | 21 | @end 22 | 23 | 24 | @interface _ModelCompany : ModelObject 25 | { 26 | NSString *name; 27 | NSNumber *yearFounded; 28 | 29 | 30 | NSArray *assistants; 31 | 32 | NSArray *departments; 33 | 34 | NSArray *employees; 35 | 36 | } 37 | 38 | @property (nonatomic, retain, readwrite) NSString *name; 39 | @property (nonatomic, retain, readwrite) NSNumber *yearFounded; 40 | @property (nonatomic, assign, readwrite) int yearFoundedValue; 41 | 42 | @property (nonatomic, retain, readonly) NSArray *assistants; 43 | @property (nonatomic, retain, readonly) NSArray *departments; 44 | @property (nonatomic, retain, readonly) NSArray *employees; 45 | 46 | 47 | - (void)addAssistantsObject:(ModelAssistant*)value_; 48 | - (void)removeAssistantsObjects; 49 | - (void)removeAssistantsObject:(ModelAssistant*)value_; 50 | 51 | - (void)addDepartmentsObject:(ModelDepartment*)value_; 52 | - (void)removeDepartmentsObjects; 53 | - (void)removeDepartmentsObject:(ModelDepartment*)value_; 54 | 55 | - (void)addEmployeesObject:(ModelEmployee*)value_; 56 | - (void)removeEmployeesObjects; 57 | - (void)removeEmployeesObject:(ModelEmployee*)value_; 58 | 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartment.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelDepartmentAssistant; 15 | @class ModelCompany; 16 | @class ModelDepartmentEmployee; 17 | 18 | 19 | @protocol _ModelDepartment 20 | 21 | @end 22 | 23 | 24 | @interface _ModelDepartment : ModelObject 25 | { 26 | NSString *name; 27 | 28 | 29 | NSArray *assistants; 30 | 31 | ModelCompany *company; 32 | 33 | NSArray *employees; 34 | 35 | } 36 | 37 | @property (nonatomic, retain, readwrite) NSString *name; 38 | 39 | @property (nonatomic, retain, readonly) NSArray *assistants; 40 | @property (nonatomic, assign, readwrite) ModelCompany *company; 41 | 42 | @property (nonatomic, retain, readonly) NSArray *employees; 43 | 44 | 45 | - (void)addAssistantsObject:(ModelDepartmentAssistant*)value_; 46 | - (void)removeAssistantsObjects; 47 | - (void)removeAssistantsObject:(ModelDepartmentAssistant*)value_; 48 | 49 | 50 | - (void)addEmployeesObject:(ModelDepartmentEmployee*)value_; 51 | - (void)removeEmployeesObjects; 52 | - (void)removeEmployeesObject:(ModelDepartmentEmployee*)value_; 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentAssistant.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelAssistant; 15 | @class ModelDepartment; 16 | 17 | 18 | @protocol _ModelDepartmentAssistant 19 | 20 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; 21 | 22 | @end 23 | 24 | 25 | @interface _ModelDepartmentAssistant : ModelObject 26 | { 27 | NSDate *startedWorking; 28 | 29 | 30 | ModelAssistant *assistant; 31 | 32 | ModelDepartment *department; 33 | 34 | } 35 | 36 | @property (nonatomic, retain, readwrite) NSDate *startedWorking; 37 | 38 | @property (nonatomic, retain, readwrite) ModelAssistant *assistant; 39 | @property (nonatomic, assign, readwrite) ModelDepartment *department; 40 | 41 | 42 | 43 | 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentAssistant.h instead. 8 | // 9 | 10 | #import "_ModelDepartmentAssistant.h" 11 | 12 | #import "ModelAssistant.h" 13 | #import "ModelDepartment.h" 14 | 15 | 16 | @interface _ModelDepartmentAssistant() 17 | 18 | @end 19 | 20 | /** \ingroup DataModel */ 21 | 22 | @implementation _ModelDepartmentAssistant 23 | 24 | - (id)init 25 | { 26 | if((self = [super init])) 27 | { 28 | 29 | } 30 | 31 | return self; 32 | } 33 | 34 | #pragma mark Scalar values 35 | 36 | 37 | 38 | #pragma mark Dictionary representation 39 | 40 | - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary 41 | { 42 | if((self = [super initWithDictionaryRepresentation:dictionary])) 43 | { 44 | self.startedWorking = [dictionary objectForKey:@"ModelDepartmentAssistant.startedWorking"]; 45 | 46 | 47 | } 48 | 49 | return self; 50 | } 51 | 52 | - (NSDictionary *)dictionaryRepresentation 53 | { 54 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; 55 | [dict setObjectIfNotNil:self.startedWorking forKey:@"ModelDepartmentAssistant.startedWorking"]; 56 | 57 | 58 | [dict setObjectIfNotNil:[self.assistant valueForKeyPath:@"name"] forKey:@"ModelDepartmentAssistant.assistant"]; 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | return dict; 67 | } 68 | 69 | - (void)awakeFromDictionaryRepresentationInit 70 | { 71 | if(self.sourceDictionaryRepresentation == nil) 72 | return; // awakeFromDictionaryRepresentationInit has been already executed on this object. 73 | 74 | self.assistant = [(_ModelDepartmentAssistant<_ModelDepartmentAssistant> *)self fetchAssistantObjectWithIDForAssistantRelationship:[self.sourceDictionaryRepresentation objectForKey:@"ModelDepartmentAssistant.assistant"]]; 75 | [self.assistant addDepartmentsObject:(ModelDepartmentAssistant*)self]; 76 | 77 | 78 | 79 | 80 | [self.assistant awakeFromDictionaryRepresentationInit]; 81 | 82 | 83 | [super awakeFromDictionaryRepresentationInit]; 84 | } 85 | 86 | #pragma mark Direct access 87 | 88 | 89 | 90 | - (void)dealloc 91 | { 92 | self.startedWorking = nil; 93 | 94 | self.assistant = nil; 95 | self.department = nil; 96 | 97 | [super dealloc]; 98 | } 99 | 100 | #pragma mark Synthesizes 101 | 102 | @synthesize startedWorking; 103 | 104 | @synthesize assistant; 105 | @synthesize department; 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentEmployee.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelDepartment; 15 | @class ModelEmployee; 16 | 17 | 18 | @protocol _ModelDepartmentEmployee 19 | 20 | - (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID; 21 | 22 | @end 23 | 24 | 25 | @interface _ModelDepartmentEmployee : ModelObject 26 | { 27 | NSDate *startedWorking; 28 | 29 | 30 | ModelDepartment *department; 31 | 32 | ModelEmployee *employee; 33 | 34 | } 35 | 36 | @property (nonatomic, retain, readwrite) NSDate *startedWorking; 37 | 38 | @property (nonatomic, assign, readwrite) ModelDepartment *department; 39 | 40 | @property (nonatomic, retain, readwrite) ModelEmployee *employee; 41 | 42 | 43 | 44 | 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.m 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentEmployee.h instead. 8 | // 9 | 10 | #import "_ModelDepartmentEmployee.h" 11 | 12 | #import "ModelDepartment.h" 13 | #import "ModelEmployee.h" 14 | 15 | 16 | @interface _ModelDepartmentEmployee() 17 | 18 | @end 19 | 20 | /** \ingroup DataModel */ 21 | 22 | @implementation _ModelDepartmentEmployee 23 | 24 | - (id)init 25 | { 26 | if((self = [super init])) 27 | { 28 | 29 | } 30 | 31 | return self; 32 | } 33 | 34 | #pragma mark Scalar values 35 | 36 | 37 | 38 | #pragma mark Dictionary representation 39 | 40 | - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary 41 | { 42 | if((self = [super initWithDictionaryRepresentation:dictionary])) 43 | { 44 | self.startedWorking = [dictionary objectForKey:@"ModelDepartmentEmployee.startedWorking"]; 45 | 46 | 47 | } 48 | 49 | return self; 50 | } 51 | 52 | - (NSDictionary *)dictionaryRepresentation 53 | { 54 | NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[super dictionaryRepresentation]]; 55 | [dict setObjectIfNotNil:self.startedWorking forKey:@"ModelDepartmentEmployee.startedWorking"]; 56 | 57 | 58 | 59 | 60 | 61 | 62 | [dict setObjectIfNotNil:[self.employee valueForKeyPath:@"name"] forKey:@"ModelDepartmentEmployee.employee"]; 63 | 64 | 65 | 66 | return dict; 67 | } 68 | 69 | - (void)awakeFromDictionaryRepresentationInit 70 | { 71 | if(self.sourceDictionaryRepresentation == nil) 72 | return; // awakeFromDictionaryRepresentationInit has been already executed on this object. 73 | 74 | self.employee = [(_ModelDepartmentEmployee<_ModelDepartmentEmployee> *)self fetchEmployeeObjectWithIDForEmployeeRelationship:[self.sourceDictionaryRepresentation objectForKey:@"ModelDepartmentEmployee.employee"]]; 75 | [self.employee addDepartmentsObject:(ModelDepartmentEmployee*)self]; 76 | 77 | 78 | 79 | 80 | [self.employee awakeFromDictionaryRepresentationInit]; 81 | 82 | 83 | [super awakeFromDictionaryRepresentationInit]; 84 | } 85 | 86 | #pragma mark Direct access 87 | 88 | 89 | 90 | - (void)dealloc 91 | { 92 | self.startedWorking = nil; 93 | 94 | self.department = nil; 95 | self.employee = nil; 96 | 97 | [super dealloc]; 98 | } 99 | 100 | #pragma mark Synthesizes 101 | 102 | @synthesize startedWorking; 103 | 104 | @synthesize department; 105 | @synthesize employee; 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelEmployee.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | 14 | @class ModelAssistant; 15 | @class ModelCompany; 16 | @class ModelDepartmentEmployee; 17 | 18 | 19 | @protocol _ModelEmployee 20 | 21 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; 22 | 23 | @end 24 | 25 | 26 | @interface _ModelEmployee : ModelObject 27 | { 28 | NSDate *birthDate; 29 | NSNumber *isOnVacation; 30 | NSString *name; 31 | 32 | 33 | ModelAssistant *assistant; 34 | 35 | ModelCompany *company; 36 | 37 | NSArray *departments; 38 | 39 | } 40 | 41 | @property (nonatomic, retain, readwrite) NSDate *birthDate; 42 | @property (nonatomic, retain, readwrite) NSNumber *isOnVacation; 43 | @property (nonatomic, assign, readwrite) BOOL isOnVacationValue; 44 | @property (nonatomic, retain, readwrite) NSString *name; 45 | 46 | @property (nonatomic, retain, readwrite) ModelAssistant *assistant; 47 | @property (nonatomic, assign, readwrite) ModelCompany *company; 48 | 49 | @property (nonatomic, retain, readonly) NSArray *departments; 50 | 51 | 52 | 53 | 54 | - (void)addDepartmentsObject:(ModelDepartmentEmployee*)value_; 55 | - (void)removeDepartmentsObjects; 56 | - (void)removeDepartmentsObject:(ModelDepartmentEmployee*)value_; 57 | 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/templates/human.h.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_<$managedObjectClassName$>.h" 8 | 9 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> <_<$managedObjectClassName$>> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Nikita Zhuk/ponso/templates/human.m.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "<$managedObjectClassName$>.h" 8 | 9 | @implementation <$managedObjectClassName$> 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> 14 | - (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID 15 | { 16 | //! TODO: Return an object of type <$Relationship.destinationEntity.managedObjectClassName$> 17 | return nil; 18 | } 19 | <$endif$><$endif$><$endforeach do$> 20 | 21 | 22 | // Custom logic goes here. 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/README.txt: -------------------------------------------------------------------------------- 1 | PONSO - Plain Old NSObjects 2 | =========================== 3 | 4 | What is PONSO? 5 | -------------- 6 | The idea is to use mogenerator to generate lightweight, memory-only, type-safe ObjC data model classes from Xcode data models. 7 | 8 | Features 9 | -------- 10 | - Type-safe attributes 11 | - Supports one-to-one and one-to-many relationships 12 | - Relationships are always ordered - implemented with NSArrays 13 | - Supports inverse relationships, which should be always marked as 'transient' 14 | - Supports serialization of any model object to NSDictionary and initialization from NSDictionary 15 | - Supports writing and reading to binary property list files 16 | - 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. 17 | - 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. 18 | - 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. 19 | - Cycles between weak relationships are found automatically and are warned about during code generation. 20 | 21 | 22 | How to use 23 | ---------- 24 | - 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" 25 | - See "contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest" project for sample setup 26 | 27 | 28 | TODO 29 | ----- 30 | PONSO is a work in progress and can be enchanced in a various ways. 31 | 32 | Some missing features include: 33 | - Automatic setting of inverse one-to-one relationships in setters 34 | - Support for many-to-many relationships 35 | - Implementations of to-many relationships as ordered sets instead of arrays 36 | - Detection of retain cycles caused by both relationship directions being non-transient 37 | 38 | Feel free to fork & contribute. 39 | 40 | 41 | Contact info 42 | ------------- 43 | Nikita Zhuk, 2011 44 | Twitter: @nzhuk 45 | 46 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/code/ModelObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Marko Karppinen & Co. LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | ModelObject.h 17 | mogenerator / PONSO 18 | Created by Nikita Zhuk on 22.1.2011. 19 | */ 20 | 21 | /** 22 | Abstract superclass for all of our model classes. 23 | */ 24 | 25 | #import 26 | 27 | @interface ModelObject : NSObject 28 | { 29 | NSDictionary *sourceDictionaryRepresentation; 30 | } 31 | 32 | @property(nonatomic, retain) NSDictionary *sourceDictionaryRepresentation; 33 | 34 | /** 35 | Reads and deserializes a ModelObject from plist at given \c filePath 36 | \return Newly created ModelObject or nil if any of the following occurs: file doesn't exist, file cannot be read, plist cannot be parsed. 37 | */ 38 | + (id)createModelObjectFromFile:(NSString *)filePath; 39 | 40 | /** 41 | Serializes the receiver into binary plist and writes it to given \c filePath. Creates any intermediate directories in the path if necessary. 42 | \return YES on success, NO on error (binary serialization or I/O error). 43 | */ 44 | - (BOOL)writeToFile:(NSString *)filePath; 45 | 46 | - (id)initWithDictionaryRepresentation:(NSDictionary *)dictionary; 47 | - (NSDictionary *)dictionaryRepresentation; 48 | 49 | - (void)awakeFromDictionaryRepresentationInit; 50 | 51 | @end 52 | 53 | 54 | @interface NSMutableDictionary (PONSONSMutableDictionaryAdditions) 55 | 56 | - (void)setObjectIfNotNil:(id)obj forKey:(NSString *)key; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | MyModel.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/elements -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/MyModel.xcdatamodeld/MyModel.xcdatamodel/layout -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/t.trevorrow.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/t.trevorrow.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/xcuserdata/t.trevorrow.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PonsoTest.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 457C26871399FAC600BF00DD 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/PonsoTest/PonsoTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PonsoTest' target in the 'PonsoTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import "Model.h" 8 | #endif 9 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/Model.h: -------------------------------------------------------------------------------- 1 | #import "ModelAssistant.h" 2 | #import "ModelCompany.h" 3 | #import "ModelDepartment.h" 4 | #import "ModelDepartmentAssistant.h" 5 | #import "ModelDepartmentEmployee.h" 6 | #import "ModelEmployee.h" 7 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelAssistant.h" 8 | 9 | @interface ModelAssistant : _ModelAssistant <_ModelAssistant> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelAssistant.h" 8 | 9 | @implementation ModelAssistant 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelCompany.h" 8 | 9 | @interface ModelCompany : _ModelCompany <_ModelCompany> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelCompany.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelCompany.h" 8 | 9 | @implementation ModelCompany 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartment.h" 8 | 9 | @interface ModelDepartment : _ModelDepartment <_ModelDepartment> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartment.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartment.h" 8 | 9 | @implementation ModelDepartment 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | 15 | 16 | // Custom logic goes here. 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartmentAssistant.h" 8 | 9 | @interface ModelDepartmentAssistant : _ModelDepartmentAssistant <_ModelDepartmentAssistant> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentAssistant.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartmentAssistant.h" 8 | 9 | @implementation ModelDepartmentAssistant 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID 15 | { 16 | NSAssert(self.department.company != nil, @""); 17 | 18 | return [[self.department.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelDepartmentEmployee.h" 8 | 9 | @interface ModelDepartmentEmployee : _ModelDepartmentEmployee <_ModelDepartmentEmployee> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelDepartmentEmployee.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelDepartmentEmployee.h" 8 | 9 | @implementation ModelDepartmentEmployee 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | 14 | - (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID 15 | { 16 | NSAssert(self.department.company != nil, @""); 17 | 18 | return [[self.department.company.employees filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_ModelEmployee.h" 8 | 9 | @interface ModelEmployee : _ModelEmployee <_ModelEmployee> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/ModelEmployee.m: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "ModelEmployee.h" 8 | 9 | @implementation ModelEmployee 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID 14 | { 15 | NSAssert(self.company != nil, @""); 16 | 17 | return [[self.company.assistants filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"name = %@", objectID]] lastObject]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelAssistant.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelEmployee; 16 | @class ModelCompany; 17 | @class ModelDepartmentAssistant; 18 | 19 | 20 | @protocol _ModelAssistant 21 | 22 | @end 23 | 24 | 25 | @interface _ModelAssistant : ModelObject 26 | { 27 | NSDate *birthDate; 28 | NSString *name; 29 | 30 | 31 | ModelEmployee *boss; 32 | 33 | ModelCompany *company; 34 | 35 | NSSet *departments; 36 | 37 | } 38 | 39 | @property (nonatomic, retain, readwrite) NSDate *birthDate; 40 | @property (nonatomic, retain, readwrite) NSString *name; 41 | 42 | @property (nonatomic, assign, readwrite) ModelEmployee *boss; 43 | 44 | @property (nonatomic, assign, readwrite) ModelCompany *company; 45 | 46 | @property (nonatomic, retain, readonly) NSSet *departments; 47 | 48 | 49 | 50 | 51 | - (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse; 52 | - (void)addDepartmentsObject:(ModelDepartmentAssistant*)value_; 53 | - (void)removeDepartmentsObjects; 54 | - (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse; 55 | - (void)removeDepartmentsObject:(ModelDepartmentAssistant*)value_; 56 | 57 | 58 | - (void) setBoss: (ModelEmployee*) boss_ settingInverse: (BOOL) setInverse; 59 | 60 | - (void) setCompany: (ModelCompany*) company_ settingInverse: (BOOL) setInverse; 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelCompany.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelCompany.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelCompany.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelAssistant; 16 | @class ModelDepartment; 17 | @class ModelEmployee; 18 | 19 | 20 | @protocol _ModelCompany 21 | 22 | @end 23 | 24 | 25 | @interface _ModelCompany : ModelObject 26 | { 27 | NSString *name; 28 | NSNumber *yearFounded; 29 | 30 | 31 | NSSet *assistants; 32 | 33 | NSSet *departments; 34 | 35 | NSSet *employees; 36 | 37 | } 38 | 39 | @property (nonatomic, retain, readwrite) NSString *name; 40 | @property (nonatomic, retain, readwrite) NSNumber *yearFounded; 41 | @property (nonatomic, assign, readwrite) int yearFoundedValue; 42 | 43 | @property (nonatomic, retain, readonly) NSSet *assistants; 44 | @property (nonatomic, retain, readonly) NSSet *departments; 45 | @property (nonatomic, retain, readonly) NSSet *employees; 46 | 47 | 48 | - (void)addAssistantsObject:(ModelAssistant*)value_ settingInverse: (BOOL) setInverse; 49 | - (void)addAssistantsObject:(ModelAssistant*)value_; 50 | - (void)removeAssistantsObjects; 51 | - (void)removeAssistantsObject:(ModelAssistant*)value_ settingInverse: (BOOL) setInverse; 52 | - (void)removeAssistantsObject:(ModelAssistant*)value_; 53 | 54 | - (void)addDepartmentsObject:(ModelDepartment*)value_ settingInverse: (BOOL) setInverse; 55 | - (void)addDepartmentsObject:(ModelDepartment*)value_; 56 | - (void)removeDepartmentsObjects; 57 | - (void)removeDepartmentsObject:(ModelDepartment*)value_ settingInverse: (BOOL) setInverse; 58 | - (void)removeDepartmentsObject:(ModelDepartment*)value_; 59 | 60 | - (void)addEmployeesObject:(ModelEmployee*)value_ settingInverse: (BOOL) setInverse; 61 | - (void)addEmployeesObject:(ModelEmployee*)value_; 62 | - (void)removeEmployeesObjects; 63 | - (void)removeEmployeesObject:(ModelEmployee*)value_ settingInverse: (BOOL) setInverse; 64 | - (void)removeEmployeesObject:(ModelEmployee*)value_; 65 | 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartment.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartment.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartment.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelDepartmentAssistant; 16 | @class ModelCompany; 17 | @class ModelDepartmentEmployee; 18 | 19 | 20 | @protocol _ModelDepartment 21 | 22 | @end 23 | 24 | 25 | @interface _ModelDepartment : ModelObject 26 | { 27 | NSString *name; 28 | 29 | 30 | NSSet *assistants; 31 | 32 | ModelCompany *company; 33 | 34 | NSSet *employees; 35 | 36 | } 37 | 38 | @property (nonatomic, retain, readwrite) NSString *name; 39 | 40 | @property (nonatomic, retain, readonly) NSSet *assistants; 41 | @property (nonatomic, assign, readwrite) ModelCompany *company; 42 | 43 | @property (nonatomic, retain, readonly) NSSet *employees; 44 | 45 | 46 | - (void)addAssistantsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse; 47 | - (void)addAssistantsObject:(ModelDepartmentAssistant*)value_; 48 | - (void)removeAssistantsObjects; 49 | - (void)removeAssistantsObject:(ModelDepartmentAssistant*)value_ settingInverse: (BOOL) setInverse; 50 | - (void)removeAssistantsObject:(ModelDepartmentAssistant*)value_; 51 | 52 | 53 | - (void)addEmployeesObject:(ModelDepartmentEmployee*)value_ settingInverse: (BOOL) setInverse; 54 | - (void)addEmployeesObject:(ModelDepartmentEmployee*)value_; 55 | - (void)removeEmployeesObjects; 56 | - (void)removeEmployeesObject:(ModelDepartmentEmployee*)value_ settingInverse: (BOOL) setInverse; 57 | - (void)removeEmployeesObject:(ModelDepartmentEmployee*)value_; 58 | 59 | 60 | - (void) setCompany: (ModelCompany*) company_ settingInverse: (BOOL) setInverse; 61 | 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentAssistant.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentAssistant.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentAssistant.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelAssistant; 16 | @class ModelDepartment; 17 | 18 | 19 | @protocol _ModelDepartmentAssistant 20 | 21 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; 22 | 23 | @end 24 | 25 | 26 | @interface _ModelDepartmentAssistant : ModelObject 27 | { 28 | NSDate *startedWorking; 29 | 30 | 31 | ModelAssistant *assistant; 32 | 33 | ModelDepartment *department; 34 | 35 | } 36 | 37 | @property (nonatomic, retain, readwrite) NSDate *startedWorking; 38 | 39 | @property (nonatomic, retain, readwrite) ModelAssistant *assistant; 40 | @property (nonatomic, assign, readwrite) ModelDepartment *department; 41 | 42 | 43 | 44 | 45 | 46 | 47 | - (void) setAssistant: (ModelAssistant*) assistant_ settingInverse: (BOOL) setInverse; 48 | 49 | - (void) setDepartment: (ModelDepartment*) department_ settingInverse: (BOOL) setInverse; 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelDepartmentEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelDepartmentEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelDepartmentEmployee.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelDepartment; 16 | @class ModelEmployee; 17 | 18 | 19 | @protocol _ModelDepartmentEmployee 20 | 21 | - (ModelEmployee *)fetchEmployeeObjectWithIDForEmployeeRelationship:(id)objectID; 22 | 23 | @end 24 | 25 | 26 | @interface _ModelDepartmentEmployee : ModelObject 27 | { 28 | NSDate *startedWorking; 29 | 30 | 31 | ModelDepartment *department; 32 | 33 | ModelEmployee *employee; 34 | 35 | } 36 | 37 | @property (nonatomic, retain, readwrite) NSDate *startedWorking; 38 | 39 | @property (nonatomic, assign, readwrite) ModelDepartment *department; 40 | 41 | @property (nonatomic, retain, readwrite) ModelEmployee *employee; 42 | 43 | 44 | 45 | 46 | 47 | - (void) setDepartment: (ModelDepartment*) department_ settingInverse: (BOOL) setInverse; 48 | 49 | - (void) setEmployee: (ModelEmployee*) employee_ settingInverse: (BOOL) setInverse; 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/sample project/PonsoTest/Sources/DataModel/_ModelEmployee.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelEmployee.h 3 | // 4 | // $Id$ 5 | // 6 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 7 | // Make changes to ModelEmployee.h instead. 8 | // 9 | 10 | 11 | #import 12 | #import "ModelObject.h" 13 | #import "ModelObject.h" 14 | 15 | @class ModelAssistant; 16 | @class ModelCompany; 17 | @class ModelDepartmentEmployee; 18 | 19 | 20 | @protocol _ModelEmployee 21 | 22 | - (ModelAssistant *)fetchAssistantObjectWithIDForAssistantRelationship:(id)objectID; 23 | 24 | @end 25 | 26 | 27 | @interface _ModelEmployee : ModelObject 28 | { 29 | NSDate *birthDate; 30 | NSNumber *isOnVacation; 31 | NSString *name; 32 | 33 | 34 | ModelAssistant *assistant; 35 | 36 | ModelCompany *company; 37 | 38 | NSSet *departments; 39 | 40 | } 41 | 42 | @property (nonatomic, retain, readwrite) NSDate *birthDate; 43 | @property (nonatomic, retain, readwrite) NSNumber *isOnVacation; 44 | @property (nonatomic, assign, readwrite) BOOL isOnVacationValue; 45 | @property (nonatomic, retain, readwrite) NSString *name; 46 | 47 | @property (nonatomic, retain, readwrite) ModelAssistant *assistant; 48 | @property (nonatomic, assign, readwrite) ModelCompany *company; 49 | 50 | @property (nonatomic, retain, readonly) NSSet *departments; 51 | 52 | 53 | 54 | 55 | - (void)addDepartmentsObject:(ModelDepartmentEmployee*)value_ settingInverse: (BOOL) setInverse; 56 | - (void)addDepartmentsObject:(ModelDepartmentEmployee*)value_; 57 | - (void)removeDepartmentsObjects; 58 | - (void)removeDepartmentsObject:(ModelDepartmentEmployee*)value_ settingInverse: (BOOL) setInverse; 59 | - (void)removeDepartmentsObject:(ModelDepartmentEmployee*)value_; 60 | 61 | 62 | - (void) setAssistant: (ModelAssistant*) assistant_ settingInverse: (BOOL) setInverse; 63 | 64 | - (void) setCompany: (ModelCompany*) company_ settingInverse: (BOOL) setInverse; 65 | 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/human.h.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.h 3 | // <#ProjectName#> 4 | // 5 | // Created by <#ModelAuthor#> on <#GenerateDate#>. 6 | // Copyright (c) <#GenerateYear#> Speedwell eBusiness Solutions Pty Ltd. All rights reserved. 7 | // 8 | // $Id$ 9 | // 10 | 11 | #import "_<$managedObjectClassName$>.h" 12 | 13 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> <_<$managedObjectClassName$>, NSCoding> 14 | // Custom logic goes here. 15 | @end 16 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/NSCoding/human.m.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.m 3 | // <#ProjectName#> 4 | // 5 | // Created by <#ModelAuthor#> on <#GenerateDate#>. 6 | // Copyright (c) <#GenerateYear#> Speedwell eBusiness Solutions Pty Ltd. All rights reserved. 7 | // 8 | // $Id$ 9 | // 10 | 11 | #import "<$managedObjectClassName$>.h" 12 | 13 | @implementation <$managedObjectClassName$> 14 | 15 | #pragma mark - NSCoding 16 | 17 | - (id) initWithCoder: (NSCoder*) aDecoder 18 | { 19 | self = [super initWithCoder: aDecoder]; 20 | if (self) { 21 | // Implement custom loading logic here 22 | } 23 | return self; 24 | } 25 | 26 | - (void) encodeWithCoder: (NSCoder*) aCoder 27 | { 28 | [super encodeWithCoder: aCoder]; 29 | // Implement custom saving logic here 30 | } 31 | 32 | #pragma mark Abstract method overrides 33 | 34 | <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> 35 | - (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID 36 | { 37 | //! TODO: Return an object of type <$Relationship.destinationEntity.managedObjectClassName$> 38 | return nil; 39 | } 40 | <$endif$><$endif$><$endforeach do$> 41 | 42 | 43 | // Custom logic goes here. 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/human.h.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_<$managedObjectClassName$>.h" 8 | 9 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> <_<$managedObjectClassName$>> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/NSSet/human.m.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "<$managedObjectClassName$>.h" 8 | 9 | @implementation <$managedObjectClassName$> 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> 14 | - (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID 15 | { 16 | //! TODO: Return an object of type <$Relationship.destinationEntity.managedObjectClassName$> 17 | return nil; 18 | } 19 | <$endif$><$endif$><$endforeach do$> 20 | 21 | 22 | // Custom logic goes here. 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/human.h.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.h 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "_<$managedObjectClassName$>.h" 8 | 9 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> <_<$managedObjectClassName$>> 10 | // Custom logic goes here. 11 | @end 12 | -------------------------------------------------------------------------------- /contributed templates/Tyrone Trevorrow/ponso/templates/human.m.motemplate: -------------------------------------------------------------------------------- 1 | // 2 | // <$managedObjectClassName$>.m 3 | // 4 | // $Id$ 5 | // 6 | 7 | #import "<$managedObjectClassName$>.h" 8 | 9 | @implementation <$managedObjectClassName$> 10 | 11 | #pragma mark Abstract method overrides 12 | 13 | <$foreach Relationship noninheritedRelationshipsInIDKeyPathTopologicalOrder do$><$if ! Relationship.isTransient$><$if Relationship.userInfo.destinationEntityIDKeyPath $> 14 | - (<$Relationship.destinationEntity.managedObjectClassName$> *)fetch<$Relationship.destinationEntity.name$>ObjectWithIDFor<$Relationship.name.initialCapitalString$>Relationship:(id)objectID 15 | { 16 | //! TODO: Return an object of type <$Relationship.destinationEntity.managedObjectClassName$> 17 | return nil; 18 | } 19 | <$endif$><$endif$><$endforeach do$> 20 | 21 | 22 | // Custom logic goes here. 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /contributed templates/rentzsch non-dynamic/human.h.motemplate: -------------------------------------------------------------------------------- 1 | #import "_<$managedObjectClassName$>.h" 2 | 3 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> {} 4 | // Custom logic goes here. 5 | @end 6 | -------------------------------------------------------------------------------- /contributed templates/rentzsch non-dynamic/human.m.motemplate: -------------------------------------------------------------------------------- 1 | #import "<$managedObjectClassName$>.h" 2 | 3 | @implementation <$managedObjectClassName$> 4 | 5 | // Custom logic goes here. 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /ddcli/DDCliParseException.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2008 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | @import Foundation; 26 | 27 | 28 | /** 29 | * A option parsing exception. This should cause the program to 30 | * terminate with the given exit code. 31 | */ 32 | @interface DDCliParseException : NSException 33 | { 34 | @private 35 | int mExitCode; 36 | } 37 | 38 | /** 39 | * Create a new exception with a given reason and exit code. 40 | * 41 | * @param reason Reason for the exception 42 | * @param exitCode Desired exit code 43 | * @return Autoreleased exception 44 | */ 45 | + (DDCliParseException *) parseExceptionWithReason: (NSString *) reason 46 | exitCode: (int) exitCode; 47 | 48 | /** 49 | * Create a new exception with a given reason and exit code. 50 | * 51 | * @param reason Reason for the exception 52 | * @param exitCode Desired exit code 53 | * @return New exception 54 | */ 55 | - (instancetype) initWithReason: (NSString *) reason 56 | exitCode: (int) exitCode; 57 | 58 | /** 59 | * Returns the desired exit code. 60 | * 61 | * @return The desired exit code 62 | */ 63 | - (int) exitCode; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /ddcli/DDCliParseException.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2008 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import "DDCliParseException.h" 26 | 27 | 28 | @implementation DDCliParseException 29 | 30 | + (DDCliParseException *) parseExceptionWithReason: (NSString *) reason 31 | exitCode: (int) exitCode; 32 | { 33 | return [[[self alloc] initWithReason: reason 34 | exitCode: exitCode] autorelease]; 35 | } 36 | 37 | - (instancetype) initWithReason: (NSString *) reason 38 | exitCode: (int) exitCode; 39 | { 40 | self = [super initWithName: NSStringFromClass([self class]) 41 | reason: reason 42 | userInfo: nil]; 43 | mExitCode = exitCode; 44 | return self; 45 | } 46 | 47 | - (int) exitCode; 48 | { 49 | return mExitCode; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /ddcli/DDCliUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2008 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | @import Foundation; 26 | 27 | /** 28 | * @ingroup functions 29 | * @{ 30 | */ 31 | 32 | /** 33 | * Like printf, but with Objective-C formatting. 34 | * 35 | * @param format String format specification 36 | */ 37 | void ddprintf(NSString * format, ...); 38 | 39 | /** 40 | * Like fprintf, but with Objective-C formatting. 41 | * 42 | * @param stream Standard I/O stream 43 | * @param format String format specification 44 | */ 45 | void ddfprintf(FILE * stream, NSString * format, ...); 46 | 47 | /** @} */ 48 | -------------------------------------------------------------------------------- /ddcli/DDCliUtil.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2008 Dave Dribin 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, copy, 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies 9 | * of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #import "DDCliUtil.h" 26 | 27 | 28 | void ddfprintf(FILE * stream, NSString * format, ...) 29 | { 30 | va_list arguments; 31 | va_start(arguments, format); 32 | NSString * string = [[NSString alloc] initWithFormat: format 33 | arguments: arguments]; 34 | va_end(arguments); 35 | 36 | fprintf(stream, "%s", [string UTF8String]); 37 | [string release]; 38 | } 39 | 40 | void ddprintf(NSString * format, ...) 41 | { 42 | va_list arguments; 43 | va_start(arguments, format); 44 | NSString * string = [[NSString alloc] initWithFormat: format 45 | arguments: arguments]; 46 | va_end(arguments); 47 | 48 | printf("%s", [string UTF8String]); 49 | [string release]; 50 | } 51 | -------------------------------------------------------------------------------- /mogenerator_Prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | @import Foundation; 3 | #endif 4 | -------------------------------------------------------------------------------- /momcom/NSAttributeDescription+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSAttributeDescription+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | extern const NSString *const kUsesScalarAttributeType; 12 | 13 | @interface NSAttributeDescription (momcom) 14 | 15 | + (NSAttributeDescription *)baseEntityForXML:(NSXMLElement *)xmlNode; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /momcom/NSEntityDescription+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSEntityDescription+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/17/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSEntityDescription (momcom) 12 | 13 | + (NSEntityDescription *)baseEntityForXML:(NSXMLElement *)xmlNode; 14 | 15 | - (void)postProcessEntityRelationshipsWithXML:(NSXMLElement *)xmlElement; 16 | @end 17 | -------------------------------------------------------------------------------- /momcom/NSFetchRequest+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSFetchRequest+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/23/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSFetchRequest (momcom) 12 | 13 | + (NSFetchRequest *)fetchRequestForXML:(NSXMLElement *)fetchRequestXMLNode inManagedObjectModel:(NSManagedObjectModel *)model; 14 | @end 15 | -------------------------------------------------------------------------------- /momcom/NSFetchedPropertyDescription+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSFetchedPropertyDescription+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSFetchedPropertyDescription (momcom) 12 | 13 | + (NSFetchedPropertyDescription *)baseEntityForXML:(NSXMLElement *)xmlNode; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /momcom/NSFetchedPropertyDescription+momcom.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSFetchedPropertyDescription+momc.m 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | #import "NSFetchedPropertyDescription+momcom.h" 10 | #import "NSPropertyDescription+momcom.h" 11 | 12 | @implementation NSFetchedPropertyDescription (momcom) 13 | 14 | + (NSFetchedPropertyDescription *)baseEntityForXML:(NSXMLElement *)xmlNode 15 | { 16 | NSFetchedPropertyDescription *fetchedPropertyDescription = [super baseEntityForXML:xmlNode]; 17 | 18 | // Nothing much happens here because it's impossible to create the fetch request without a reference 19 | // to the target entity. That happens in NSEntityDescription's post-process phase. 20 | // And no, +[NSFetchRequest fetchRequestWithEntityName:] here would not be not a convenient workaround, 21 | // it's a good way to get an exception thrown at you. 22 | 23 | return fetchedPropertyDescription; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /momcom/NSManagedObjectModel+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSManagedObjectModel+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/17/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSManagedObjectModel (momcom) 12 | 13 | + (NSManagedObjectModel *)compileFromDocument:(NSXMLDocument *)sourceModelDocument error:(NSError **)error; 14 | + (NSString *)compileModelAtPath:(NSString *)modelPath inDirectory:(NSString *)resultDirectoryPath error:(NSError **)error; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /momcom/NSPropertyDescription+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSPropertyDescription+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSPropertyDescription (momcom) 12 | 13 | + (id)baseEntityForXML:(NSXMLElement *)xmlNode; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /momcom/NSPropertyDescription+momcom.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSPropertyDescription+momc.m 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | #import "NSPropertyDescription+momcom.h" 10 | 11 | @implementation NSPropertyDescription (momcom) 12 | 13 | + (id)baseEntityForXML:(NSXMLElement *)xmlNode 14 | { 15 | if ([self isMemberOfClass:[NSPropertyDescription class]]) { 16 | NSException *exception = [NSException exceptionWithName:NSGenericException reason:@"Can't create an NSPropertyDescription from an XML element, use an NSPropertyDescription subclass." userInfo:nil]; 17 | [exception raise]; 18 | return nil; 19 | } 20 | 21 | NSPropertyDescription *propertyDescription = [[self alloc] init]; 22 | BOOL optional = NO; 23 | BOOL transient = NO; 24 | BOOL indexed = NO; 25 | BOOL syncable = NO; 26 | 27 | for (NSXMLNode *xmlAttribute in [xmlNode attributes]) { 28 | NSString *attributeName = [xmlAttribute name]; 29 | NSString *attributeString = [xmlAttribute stringValue]; 30 | if ([attributeName isEqualToString:@"name"]) { 31 | [propertyDescription setName:attributeString]; 32 | } else if ([attributeName isEqualToString:@"optional"]) { 33 | optional = [attributeString isEqualToString:@"YES"]; 34 | } else if ([attributeName isEqualToString:@"transient"]) { 35 | transient = [attributeString isEqualToString:@"YES"]; 36 | } else if ([attributeName isEqualToString:@"indexed"]) { 37 | indexed = [attributeString isEqualToString:@"YES"]; 38 | } else if ([attributeName isEqualToString:@"syncable"]) { 39 | syncable = [attributeString isEqualToString:@"YES"]; 40 | } else if ([attributeName isEqualToString:@"versionHashModifier"]) { 41 | [propertyDescription setVersionHashModifier:attributeString]; 42 | } else if ([attributeName isEqualToString:@"renamingIdentifier"]) { 43 | [propertyDescription setRenamingIdentifier:attributeString]; 44 | } 45 | } 46 | 47 | [propertyDescription setOptional:optional]; 48 | [propertyDescription setTransient:transient]; 49 | [propertyDescription setIndexed:indexed]; 50 | 51 | 52 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; 53 | 54 | // Need to add com.apple.syncservices.Syncable = NO to self's userInfo unless syncable=YES appears in XML attributes. 55 | if (!syncable) { 56 | [userInfo setObject:@"NO" forKey:@"com.apple.syncservices.Syncable"]; 57 | } 58 | 59 | for (NSXMLElement *childNode in [xmlNode children]) { 60 | if ([[childNode name] isEqualToString:@"userInfo"]) { 61 | for (NSXMLElement *entryElement in [childNode children]) { 62 | NSXMLNode *keyAttribute = [entryElement attributeForName:@"key"]; 63 | NSXMLNode *valueAttribute = [entryElement attributeForName:@"value"]; 64 | [userInfo setObject:[valueAttribute stringValue] forKey:[keyAttribute stringValue]]; 65 | } 66 | } 67 | } 68 | 69 | [propertyDescription setUserInfo:userInfo]; 70 | 71 | return propertyDescription; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /momcom/NSRelationshipDescription+momcom.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSRelationshipDescription+momcom.h 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | @import CoreData; 10 | 11 | @interface NSRelationshipDescription (momcom) 12 | 13 | + (NSRelationshipDescription *)baseEntityForXML:(NSXMLElement *)xmlNode; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /momcom/NSRelationshipDescription+momcom.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSRelationshipDescription+momc.m 3 | // momc 4 | // 5 | // Created by Tom Harrington on 4/18/13. 6 | // Copyright (c) 2013 Tom Harrington. All rights reserved. 7 | // 8 | 9 | #import "NSRelationshipDescription+momcom.h" 10 | #import "NSPropertyDescription+momcom.h" 11 | 12 | @implementation NSRelationshipDescription (momcom) 13 | 14 | + (NSRelationshipDescription *)baseEntityForXML:(NSXMLElement *)xmlNode; 15 | { 16 | NSRelationshipDescription *relationshipDescription = [super baseEntityForXML:xmlNode]; 17 | 18 | NSXMLNode *minCountNode = [xmlNode attributeForName:@"minCount"]; 19 | if (minCountNode != nil) { 20 | [relationshipDescription setMinCount:[[minCountNode stringValue] integerValue]]; 21 | } 22 | NSXMLNode *maxCountNode = [xmlNode attributeForName:@"maxCount"]; 23 | if (maxCountNode != nil) { 24 | [relationshipDescription setMaxCount:[[maxCountNode stringValue] integerValue]]; 25 | } 26 | NSXMLNode *deletionRuleNode = [xmlNode attributeForName:@"deletionRule"]; 27 | if (deletionRuleNode != nil) { 28 | NSString *deletionRuleString = [deletionRuleNode stringValue]; 29 | if ([deletionRuleString isEqualToString:@"Nullify"]) { 30 | [relationshipDescription setDeleteRule:NSNullifyDeleteRule]; 31 | } else if ([deletionRuleString isEqualToString:@"Cascade"]) { 32 | [relationshipDescription setDeleteRule:NSCascadeDeleteRule]; 33 | } else if ([deletionRuleString isEqualToString:@"Deny"]) { 34 | [relationshipDescription setDeleteRule:NSDenyDeleteRule]; 35 | } 36 | } 37 | NSXMLNode *orderedNode = [xmlNode attributeForName:@"ordered"]; 38 | if (orderedNode != nil) { 39 | [relationshipDescription setOrdered:[[orderedNode stringValue] boolValue]]; 40 | } 41 | 42 | // Destination entity and inverse are not handled here, they get post processed once related entities exist. 43 | 44 | return relationshipDescription; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ponso/MKCDAGNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Marko Karppinen & Co. LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | MKCDAGNode.h 17 | Created by Nikita Zhuk on 22.1.2011. 18 | */ 19 | 20 | @import Foundation; 21 | 22 | /** 23 | Generic DAG (Directed Acyclic Graph) implementation 24 | */ 25 | @interface MKCDAGNode : NSObject 26 | { 27 | id object; 28 | NSMutableArray *nodes; 29 | } 30 | 31 | //! Generic payload object, not used in the algorithm. Can be nil. 32 | @property(nonatomic, retain) id object; 33 | 34 | //! All objects of nodes in topological order which are reachable from the receiver. 35 | @property(nonatomic, readonly) NSArray *objectsInTopologicalOrder; 36 | 37 | - (instancetype)initWithObject:(id)object; 38 | 39 | /** 40 | Creates dependency between receiver and the given node and adds the given node into the DAG. 41 | The dependency direction is from the receiver to the given node, e.g. [a addNode:b] means that 'a' depends on 'b'. 42 | If the new node would create a cycle in the DAG it's not added and NO is returned. 43 | YES is returned otherwise. 44 | */ 45 | - (BOOL)addNode:(MKCDAGNode *)node; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ponso/MKCNSEntityDescriptionAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Marko Karppinen & Co. LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | MKCNSEntityDescriptionAdditions.h 17 | Created by Nikita Zhuk on 22.1.2011. 18 | */ 19 | 20 | @import CoreData; 21 | 22 | 23 | @interface NSEntityDescription(MKCNSEntityDescriptionAdditions) 24 | 25 | /** @TypeInfo NSAttributeDescription */ 26 | @property(nonatomic, readonly) NSArray *noninheritedRelationshipsInIDKeyPathTopologicalOrder; 27 | 28 | // Checks if the managed object model of the receiver contains cycles in non-transient relationships. 29 | // If cycles are found, an exception is raised. 30 | - (void)checkNonTransientRelationshipCycles; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ponso/MKCNSManagedObjectModelAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2011 Marko Karppinen & Co. LLC. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | MKCNSManagedObjectModelAdditions.h 17 | Created by Nikita Zhuk on 22.1.2011. 18 | */ 19 | 20 | @import CoreData; 21 | 22 | 23 | @protocol MKCNSRelationshipDescriptionDependencyFilter 24 | - (BOOL)includeRelationship:(NSRelationshipDescription *)relationship; 25 | @end 26 | 27 | @interface NSManagedObjectModel(MKCNSManagedObjectModelAdditions) 28 | 29 | /** 30 | Array of NSEntityDescription objects, sorted in topological order 31 | based on relationships between entity descriptions. 32 | If there are cyclic dependencies, a nil is returned. 33 | This method counts all relationships as dependencies if they are not marked as being 'transient'. 34 | */ 35 | 36 | - (NSArray *) entitiesInTopologicalOrder; 37 | 38 | /* 39 | Same as entitiesInTopologicalOrder, but uses the given dependencyFilter to decide whether a 40 | relationship should be counted as dependency or not. 41 | */ 42 | - (NSArray *) entitiesInTopologicalOrderUsingDependencyFilter:(id) dependencyFilter; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ponso/generate.sh: -------------------------------------------------------------------------------- 1 | if [ ! -f "$MOGENERATOR_BIN" ] 2 | then 3 | echo "mogenerator binary doesn't exist at $MOGENERATOR_BIN" 4 | exit 1 5 | fi 6 | 7 | echo "Generating Data Model Classes from $DATA_MODEL_FILE ..." 8 | if [ ! -d "$DATA_MODEL_FILE" ] 9 | then 10 | echo "Data model file doesn't exist at $DATA_MODEL_FILE" 11 | exit 1 12 | fi 13 | 14 | mkdir -p "$DATA_MODEL_SOURCE_DIR" 15 | 16 | MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS=YES \ 17 | MOMC_SUPPRESS_INVERSE_TRANSIENT_ERROR=YES \ 18 | "$MOGENERATOR_BIN" \ 19 | -m "$DATA_MODEL_FILE" \ 20 | --base-class "$BASE_CLASS" \ 21 | --includeh "$AGGREGATE_HEADER" \ 22 | --template-path "$MOGENERATOR_TEMPLATES" \ 23 | -O "$DATA_MODEL_SOURCE_DIR" || exit 1 24 | 25 | echo "Generated Data Model Classes to $DATA_MODEL_SOURCE_DIR" 26 | -------------------------------------------------------------------------------- /resources/README.md: -------------------------------------------------------------------------------- 1 | # `mogenerator` related resources 2 | 3 | ## For template editors 4 | 5 | If you're editing `mogenerator` template files with Visual Studio Code, you can add syntax highlighting support for `.motemplate` files like [the ones included with `mogenerator`](../templates). 6 | 7 | ![](mogenerator-template-vscode/sample.png) 8 | 9 | To use syntax highlighting, copy the `mogenerator-template-vscode` directory into `~/.vscode/extensions/` on your Mac, and relaunch Visual Studio Code. 10 | -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "runtimeExecutable": "${execPath}", 13 | "args": [ 14 | "--extensionDevelopmentPath=${workspaceFolder}" 15 | ] 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "mogenerator-template" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | - Initial release -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/README.md: -------------------------------------------------------------------------------- 1 | # mogenerator-template README 2 | 3 | This is the README for your extension "mogenerator-template". After writing up a brief description, we recommend including the following sections. 4 | 5 | ## Features 6 | 7 | Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. 8 | 9 | For example if there is an image subfolder under your extension project workspace: 10 | 11 | \!\[feature X\]\(images/feature-x.png\) 12 | 13 | > Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. 14 | 15 | ## Requirements 16 | 17 | If you have any requirements or dependencies, add a section describing those and how to install and configure them. 18 | 19 | ## Extension Settings 20 | 21 | Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. 22 | 23 | For example: 24 | 25 | This extension contributes the following settings: 26 | 27 | * `myExtension.enable`: enable/disable this extension 28 | * `myExtension.thing`: set to `blah` to do something 29 | 30 | ## Known Issues 31 | 32 | Calling out known issues can help limit users opening duplicate issues against your extension. 33 | 34 | ## Release Notes 35 | 36 | Users appreciate release notes as you update your extension. 37 | 38 | ### 1.0.0 39 | 40 | Initial release of ... 41 | 42 | ### 1.0.1 43 | 44 | Fixed issue #. 45 | 46 | ### 1.1.0 47 | 48 | Added features X, Y, and Z. 49 | 50 | ----------------------------------------------------------------------------------------------------------- 51 | 52 | ## Working with Markdown 53 | 54 | **Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: 55 | 56 | * Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux) 57 | * Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux) 58 | * Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets 59 | 60 | ### For more information 61 | 62 | * [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) 63 | * [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) 64 | 65 | **Enjoy!** 66 | -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | //"blockComment": [ "<$comment", "$>" ] 7 | }, 8 | // symbols used as brackets 9 | "brackets": [ 10 | ["{", "}"], 11 | ["[", "]"], 12 | ["(", ")"] 13 | //["<\\$", "\\$>"] 14 | ], 15 | // symbols that are auto closed when typing 16 | "autoClosingPairs": [ 17 | ["{", "}"], 18 | ["[", "]"], 19 | ["(", ")"], 20 | ["\"", "\""], 21 | ["'", "'"] 22 | ], 23 | // symbols that that can be used to surround a selection 24 | "surroundingPairs": [ 25 | ["{", "}"], 26 | ["[", "]"], 27 | ["(", ")"], 28 | ["\"", "\""], 29 | ["'", "'"] 30 | ] 31 | } -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mogenerator-template", 3 | "displayName": "Mogenerator template", 4 | "description": "Syntax highlighting for mogenerator template files", 5 | "version": "0.0.1", 6 | "engines": { 7 | "vscode": "^1.30.0" 8 | }, 9 | "categories": [ 10 | "Programming Languages" 11 | ], 12 | "homepage": "https://github.com/rentzsch/mogenerator", 13 | "contributes": { 14 | "languages": [{ 15 | "id": "mogenerator-template", 16 | "aliases": ["Mogenerator template", "mogenerator-template"], 17 | "extensions": [".motemplate"], 18 | "configuration": "./language-configuration.json" 19 | }], 20 | "grammars": [{ 21 | "language": "mogenerator-template", 22 | "scopeName": "source.motemplate", 23 | "path": "./syntaxes/mogenerator-template.tmLanguage.json" 24 | }] 25 | } 26 | } -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rentzsch/mogenerator/8d463ac94d60523d24680ac201d2a5f95aecffdc/resources/mogenerator-template-vscode/sample.png -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/syntaxes/mogenerator-template.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Mogenerator template", 4 | "patterns": [ 5 | { 6 | "include": "#comment" 7 | }, 8 | { 9 | "include": "#keywords" 10 | } 11 | ], 12 | "repository": { 13 | "keywords": { 14 | "name": "keyword.other.mogenerator-template", 15 | "begin": "<\\$\\s*", 16 | "end": "\\$>", 17 | "patterns": [{ 18 | "name": "keyword.control.mogenerator-template", 19 | "match": "(if|else|elseif|endif|foreach|endforeach|break|continue|date)" 20 | }] 21 | }, 22 | "strings": { 23 | "name": "string.quoted.double.mogenerator-template", 24 | "begin": "\"", 25 | "end": "\"", 26 | "patterns": [ 27 | { 28 | "name": "constant.character.escape.mogenerator-template", 29 | "match": "\\\\." 30 | } 31 | ] 32 | }, 33 | "comment": { 34 | "name": "comment.block.motemplate", 35 | "begin": "<\\$comment", 36 | "end": "\\$>", 37 | "patterns": [ 38 | { 39 | "name": "constant.character.escape.mogenerator-template", 40 | "match": "\\\\." 41 | } 42 | ], 43 | "contentName": "constant.character.escape.mogenerator-template" 44 | } 45 | }, 46 | "scopeName": "source.motemplate" 47 | } -------------------------------------------------------------------------------- /resources/mogenerator-template-vscode/vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension. 5 | * `package.json` - this is the manifest file in which you declare your language support and define 6 | the location of the grammar file that has been copied into your extension. 7 | * `syntaxes/mogenerator-template.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. 8 | * `language-configuration.json` - this is the language configuration, defining the tokens that are used for 9 | comments and brackets. 10 | 11 | ## Get up and running straight away 12 | * Make sure the language configuration settings in `language-configuration.json` are accurate. 13 | * Press `F5` to open a new window with your extension loaded. 14 | * Create a new file with a file name suffix matching your language. 15 | * Verify that syntax highlighting works and that the language configuration settings are working. 16 | 17 | ## Make changes 18 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 19 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 20 | 21 | ## Add more language features 22 | * To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at 23 | https://code.visualstudio.com/docs 24 | 25 | ## Install your extension 26 | * To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. 27 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 28 | -------------------------------------------------------------------------------- /templates/MyBaseClass.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MyBaseClass : NSManagedObject { 4 | double ivar; 5 | } 6 | 7 | - (double)ivar; 8 | - (void)setIvar:(double)ivar_; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /templates/MyBaseClass.m: -------------------------------------------------------------------------------- 1 | #import "MyBaseClass.h" 2 | 3 | @implementation MyBaseClass 4 | 5 | - (double)ivar { 6 | return ivar; 7 | } 8 | 9 | - (void)setIvar:(double)ivar_ { 10 | ivar = ivar_; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /templates/human.h.motemplate: -------------------------------------------------------------------------------- 1 | #import "_<$managedObjectClassName$>.h" 2 | 3 | @interface <$managedObjectClassName$> : _<$managedObjectClassName$> 4 | // Custom logic goes here. 5 | @end 6 | -------------------------------------------------------------------------------- /templates/human.m.motemplate: -------------------------------------------------------------------------------- 1 | #import "<$managedObjectClassName$>.h" 2 | 3 | 4 | @interface <$managedObjectClassName$> () 5 | 6 | // Private interface goes here. 7 | 8 | @end 9 | 10 | 11 | @implementation <$managedObjectClassName$> 12 | 13 | // Custom logic goes here. 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /templates/human.swift.motemplate: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | @objc(<$managedObjectClassName$>) 4 | open class <$managedObjectClassName$>: _<$managedObjectClassName$> { 5 | // Custom logic goes here. 6 | } 7 | -------------------------------------------------------------------------------- /test/JREnum/JREnumTest/JREnumTest/JREnumTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'JREnumTest' target in the 'JREnumTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /test/JREnum/JREnumTest/JREnumTest/SplitEnums.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "JREnum.h" 3 | 4 | JREnumDeclare(SplitEnumWith1ConstantSansExplicitValues, 5 | SplitEnumWith1ConstantSansExplicitValues_Constant1); 6 | 7 | JREnumDeclare(SplitEnumWith2ConstantsSansExplicitValues, 8 | SplitEnumWith2ConstantsSansExplicitValues_Constant1, 9 | SplitEnumWith2ConstantsSansExplicitValues_Constant2); 10 | 11 | JREnumDeclare(SplitEnumWith1ConstantWithExplicitValues, 12 | SplitEnumWith1ConstantWithExplicitValues_Constant1 = 42); 13 | 14 | JREnumDeclare(TestClassState, 15 | TestClassState_Closed, 16 | TestClassState_Opening, 17 | TestClassState_Open, 18 | TestClassState_Closing); 19 | 20 | JREnumDeclare(Align, 21 | AlignLeft = 1 << 0, 22 | AlignRight = 1 << 1, 23 | AlignTop = 1 << 2, 24 | AlignBottom = 1 << 3, 25 | AlignTopLeft = 0x05, 26 | AlignBottomLeft = 0x09, 27 | AlignTopRight = 0x06, 28 | AlignBottomRight = 0x0A, 29 | ); -------------------------------------------------------------------------------- /test/JREnum/JREnumTest/JREnumTest/SplitEnums.m: -------------------------------------------------------------------------------- 1 | #import "SplitEnums.h" 2 | 3 | JREnumDefine(SplitEnumWith1ConstantSansExplicitValues); 4 | 5 | JREnumDefine(SplitEnumWith2ConstantsSansExplicitValues); 6 | 7 | JREnumDefine(SplitEnumWith1ConstantWithExplicitValues); 8 | 9 | JREnumDefine(TestClassState); 10 | 11 | JREnumDefine(Align); -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2014 Jonathan 'Wolf' Rentzsch. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | MogenSwiftTest.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest.xcdatamodeld/MogenSwiftTest.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest/MyEntityMO.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | @objc 3 | class MyEntityMO: _MyEntityMO { 4 | 5 | // Custom logic goes here. 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest/UnorderedToManyDstMO.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | @objc 3 | class UnorderedToManyDstMO: _UnorderedToManyDstMO { 4 | 5 | // Custom logic goes here. 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest/UnorderedToManySrcMO.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | @objc 3 | class UnorderedToManySrcMO: _UnorderedToManySrcMO { 4 | 5 | // Custom logic goes here. 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest/_MyEntityMO.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 2 | // Make changes to MyEntityMO.swift instead. 3 | 4 | import CoreData 5 | 6 | enum MyEntityMOAttributes: String { 7 | case integerAttribute = "integerAttribute" 8 | case stringAttribute = "stringAttribute" 9 | } 10 | 11 | @objc 12 | class _MyEntityMO: NSManagedObject { 13 | 14 | /// pragma mark - Class methods 15 | 16 | class func entityName () -> String { 17 | return "MyEntity" 18 | } 19 | 20 | class func entity(_ managedObjectContext: NSManagedObjectContext!) -> NSEntityDescription! { 21 | return NSEntityDescription.entity(forEntityName: self.entityName(), in: managedObjectContext); 22 | } 23 | 24 | /// pragma mark - Life cycle methods 25 | 26 | override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) { 27 | super.init(entity: entity, insertInto: context) 28 | } 29 | 30 | convenience init(managedObjectContext: NSManagedObjectContext!) { 31 | let entity = _MyEntityMO.entity(managedObjectContext) 32 | self.init(entity: entity!, insertInto: managedObjectContext) 33 | } 34 | 35 | /// pragma mark - Properties 36 | 37 | @NSManaged 38 | var integerAttribute: NSNumber? 39 | 40 | // func validateIntegerAttribute(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} 41 | 42 | @NSManaged 43 | var stringAttribute: String 44 | 45 | // func validateStringAttribute(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} 46 | 47 | /// pragma mark - Relationships 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/MogenSwiftTest/_UnorderedToManyDstMO.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. This file is machine-generated and constantly overwritten. 2 | // Make changes to UnorderedToManyDstMO.swift instead. 3 | 4 | import CoreData 5 | 6 | enum UnorderedToManyDstMOAttributes: String { 7 | case tag = "tag" 8 | } 9 | 10 | enum UnorderedToManyDstMORelationships: String { 11 | case relationship = "relationship" 12 | } 13 | 14 | @objc 15 | class _UnorderedToManyDstMO: NSManagedObject { 16 | 17 | /// pragma mark - Class methods 18 | 19 | class func entityName () -> String { 20 | return "UnorderedToManyDst" 21 | } 22 | 23 | class func entity(_ managedObjectContext: NSManagedObjectContext!) -> NSEntityDescription! { 24 | return NSEntityDescription.entity(forEntityName: self.entityName(), in: managedObjectContext); 25 | } 26 | 27 | /// pragma mark - Life cycle methods 28 | 29 | override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) { 30 | super.init(entity: entity, insertInto: context) 31 | } 32 | 33 | convenience init(managedObjectContext: NSManagedObjectContext!) { 34 | let entity = _UnorderedToManyDstMO.entity(managedObjectContext) 35 | self.init(entity: entity!, insertInto: managedObjectContext) 36 | } 37 | 38 | /// pragma mark - Properties 39 | 40 | @NSManaged 41 | var tag: NSNumber? 42 | 43 | // func validateTag(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} 44 | 45 | /// pragma mark - Relationships 46 | 47 | @NSManaged 48 | var relationship: UnorderedToManySrcMO 49 | 50 | // func validateRelationship(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTest/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // MogenSwiftTest 4 | // 5 | // Created by Wolf Rentzsch on 7/10/14. 6 | // Copyright (c) 2014 Jonathan 'Wolf' Rentzsch. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv) 12 | -------------------------------------------------------------------------------- /test/MogenSwiftTest/MogenSwiftTestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/objc/Gender.h: -------------------------------------------------------------------------------- 1 | @import Foundation; 2 | 3 | #import "JREnum/JREnum.h" 4 | 5 | // Mostly stolen from http://abcnews.go.com/blogs/headlines/2014/02/heres-a-list-of-58-gender-options-for-facebook-users/ 6 | 7 | JREnumDeclare( 8 | Gender, 9 | Gender_Undefined, 10 | Gender_Female, 11 | Gender_Male, 12 | Gender_Other, 13 | Gender_Agender, 14 | Gender_Androgyne, 15 | Gender_Androgynous, 16 | Gender_Bigender, 17 | Gender_Cisgender, 18 | Gender_CisgenderFemale, 19 | Gender_CisgenderMale, 20 | Gender_FemaleToMale, 21 | Gender_GenderFluid, 22 | Gender_GenderNonconforming, 23 | Gender_GenderQuestioning, 24 | Gender_GenderVariant, 25 | Gender_Genderqueer, 26 | Gender_Intersex, 27 | Gender_MaleToFemale, 28 | Gender_Neither, 29 | Gender_Neutrois, 30 | Gender_Nonbinary, 31 | Gender_Pangender, 32 | Gender_Trans, 33 | Gender_TransStar, 34 | Gender_TransFemale, 35 | Gender_TransStarFemale, 36 | Gender_TransMale, 37 | Gender_TransStarMale, 38 | Gender_TransPerson, 39 | Gender_TransStarPerson, 40 | Gender_Transfeminine, 41 | Gender_Transgender, 42 | Gender_TransgenderFemale, 43 | Gender_TransgenderMale, 44 | Gender_TransgenderPerson, 45 | Gender_Transmasculine, 46 | Gender_Transsexual, 47 | Gender_TranssexualFemale, 48 | Gender_TranssexualMale, 49 | Gender_TranssexualPerson, 50 | ); 51 | -------------------------------------------------------------------------------- /test/objc/Gender.m: -------------------------------------------------------------------------------- 1 | #import "Gender.h" 2 | 3 | JREnumDefine(Gender); -------------------------------------------------------------------------------- /test/objc/MyBaseClass.h: -------------------------------------------------------------------------------- 1 | @import Cocoa; 2 | 3 | @interface MyBaseClass : NSManagedObject { 4 | double ivar; 5 | } 6 | 7 | - (double)ivar; 8 | - (void)setIvar:(double)ivar_; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /test/objc/MyBaseClass.m: -------------------------------------------------------------------------------- 1 | #import "MyBaseClass.h" 2 | 3 | @implementation MyBaseClass 4 | 5 | - (double)ivar { 6 | return ivar; 7 | } 8 | 9 | - (void)setIvar:(double)ivar_ { 10 | ivar = ivar_; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /test/objc/test-prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'MogenTest' target in the 'MogenTest' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | @import Foundation; 7 | #endif 8 | -------------------------------------------------------------------------------- /test/objc/test.m: -------------------------------------------------------------------------------- 1 | @import Cocoa; 2 | 3 | #import "../MOs/MyBaseClass.h" 4 | #import "../MOs/ParentMO.h" 5 | #import "../MOs/ChildMO.h" 6 | #import "../MOs/Gender.h" 7 | 8 | int main(int argc, char *argv[]) { 9 | @autoreleasepool { 10 | NSManagedObjectContext *moc; 11 | {{ 12 | NSURL *modelURL = [NSURL fileURLWithPath:@"test.mom"]; 13 | assert(modelURL); 14 | 15 | NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; 16 | assert(model); 17 | 18 | NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; 19 | assert(persistentStoreCoordinator); 20 | 21 | NSError *inMemoryStoreError = nil; 22 | NSPersistentStore *persistentStore = [persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType 23 | configuration:nil 24 | URL:nil 25 | options:nil 26 | error:&inMemoryStoreError]; 27 | 28 | assert(persistentStore); 29 | assert(!inMemoryStoreError); 30 | 31 | moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; 32 | moc.persistentStoreCoordinator = persistentStoreCoordinator; 33 | assert(moc); 34 | }} 35 | 36 | //-- 37 | 38 | ParentMO *homer = [ParentMO insertInManagedObjectContext:moc]; 39 | homer.humanName = homer.parentName = @"homer"; 40 | [homer setIvar:1.0]; 41 | homer.genderValue = Gender_Male; 42 | 43 | ParentMO *marge = [ParentMO insertInManagedObjectContext:moc]; 44 | marge.humanName = marge.parentName = @"marge"; 45 | [marge setIvar:1.0]; 46 | marge.genderValue = Gender_Female; 47 | 48 | assert([homer.children count] == 0); 49 | assert([marge.children count] == 0); 50 | 51 | //-- 52 | 53 | ChildMO *bart = [ChildMO insertInManagedObjectContext:moc]; 54 | bart.humanName = bart.childName = @"bart"; 55 | [bart setIvar:1.0]; 56 | bart.type = [NSNumber numberWithInt:64]; 57 | bart.typeValue++; 58 | 59 | ChildMO *lisa = [ChildMO insertInManagedObjectContext:moc]; 60 | lisa.humanName = lisa.childName = @"lisa"; 61 | [lisa setIvar:1.0]; 62 | 63 | //-- 64 | 65 | NSError *saveError = nil; 66 | BOOL saveSuccess = [moc save:&saveError]; 67 | assert(saveSuccess); 68 | assert(!saveError); 69 | 70 | //-- 71 | 72 | assert(homer.genderValue == Gender_Male); 73 | assert(marge.genderValue == Gender_Female); 74 | assert(bart.genderValue == Gender_Undefined); 75 | assert([GenderToString(homer.genderValue) isEqualToString:@"Gender_Male"]); 76 | } 77 | puts("success"); 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /test/swift/Gender.swift: -------------------------------------------------------------------------------- 1 | 2 | // Mostly stolen from http://abcnewsgocom/blogs/headlines/2014/02/heres-a-list-of-58-gender-options-for-facebook-users/ 3 | enum Gender: Int { 4 | case Undefined = 0, 5 | Female, 6 | Male, 7 | Other, 8 | Agender, 9 | Androgyne, 10 | Androgynous, 11 | Bigender, 12 | Cisgender, 13 | CisgenderFemale, 14 | CisgenderMale, 15 | FemaleToMale, 16 | GenderFluid, 17 | GenderNonconforming, 18 | GenderQuestioning, 19 | GenderVariant, 20 | Genderqueer, 21 | Intersex, 22 | MaleToFemale, 23 | Neither, 24 | Neutrois, 25 | Nonbinary, 26 | Pangender, 27 | Trans, 28 | TransStar, 29 | TransFemale, 30 | TransStarFemale, 31 | TransMale, 32 | TransStarMale, 33 | TransPerson, 34 | TransStarPerson, 35 | Transfeminine, 36 | Transgender, 37 | TransgenderFemale, 38 | TransgenderMale, 39 | TransgenderPerson, 40 | Transmasculine, 41 | Transsexual, 42 | TranssexualFemale, 43 | TranssexualMale, 44 | TranssexualPerson 45 | 46 | func toString() -> String { 47 | return String(describing: self) 48 | } 49 | } 50 | 51 | func ==(lhs: Gender, rhs: Gender) -> Bool { 52 | return lhs.rawValue == rhs.rawValue 53 | } 54 | -------------------------------------------------------------------------------- /test/swift/MyBaseClass.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import CoreData 3 | 4 | open class MyBaseClass: NSManagedObject { 5 | var ivar: Double = -1.0 6 | } 7 | -------------------------------------------------------------------------------- /test/swift/main.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import CoreData 3 | 4 | struct CoreDataStore { 5 | let moc: NSManagedObjectContext 6 | 7 | init() { 8 | let modelURL = URL(fileURLWithPath: "test.mom") 9 | let model = NSManagedObjectModel(contentsOf: modelURL as URL) 10 | let psc = NSPersistentStoreCoordinator(managedObjectModel: model!) 11 | 12 | do { 13 | let _ = try psc.addPersistentStore(ofType: NSInMemoryStoreType, configurationName: nil, at: nil, options: nil) 14 | } catch { 15 | assertionFailure("Can't bring up PSC") 16 | } 17 | 18 | moc = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType) 19 | moc.persistentStoreCoordinator = psc 20 | } 21 | } 22 | 23 | let dataStore = CoreDataStore() 24 | let moc = dataStore.moc 25 | // 26 | let homer = ParentMO(managedObjectContext: moc)! 27 | homer.humanName = "homer" 28 | homer.parentName = homer.humanName 29 | homer.ivar = 1.0 30 | homer.gender = NSNumber(value: Gender.Male.rawValue) 31 | 32 | let marge = ParentMO(managedObjectContext: moc)! 33 | marge.humanName = "marge" 34 | marge.parentName = marge.humanName 35 | marge.ivar = 1.0 36 | marge.gender = NSNumber(value: Gender.Female.rawValue) 37 | 38 | assert(homer.children.count == 0) 39 | assert(marge.children.count == 0) 40 | 41 | let bart = ChildMO(managedObjectContext: moc)! 42 | bart.humanName = "bart" 43 | bart.childName = bart.humanName 44 | bart.ivar = 1.0 45 | bart.type = 64 46 | 47 | let lisa = ChildMO(managedObjectContext: moc)! 48 | lisa.humanName = "lisa" 49 | lisa.childName = lisa.humanName 50 | lisa.ivar = 1.0 51 | 52 | do { 53 | try moc.save() 54 | assert(Gender(rawValue: homer.gender!.intValue) == .Male) 55 | assert(Gender(rawValue: marge.gender!.intValue) == .Female) 56 | assert(Gender(rawValue: bart.gender!.intValue) == .Undefined) 57 | assert(Gender(rawValue: homer.gender!.intValue)!.toString() == "Male") 58 | 59 | } catch { 60 | assertionFailure("Failed to save") 61 | } 62 | 63 | print("Success") 64 | --------------------------------------------------------------------------------