diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..4d1d1ffd --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,19 @@ +### Feature Request + +_What would you like to see that is not currently available?_ + +### Question + +_What is not clear?_ + +### Expected Behavior + +_What should happen?_ + +### Actual Behavior + +_What happens instead?_ + +### Additional Information + +_Platform / Use Case / etc._ diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..0f838527 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +### Summary of Changes + +_Please offer a description of the code changes in your pull request._ + +### Addresses + +_Tag any [issues](https://github.com/rentzch/mogenerator/issues) that are being addressed._ diff --git a/.gitignore b/.gitignore index 515ce9c0..49330c7a 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ dist **/*.xcodeproj/* !**/*.xcodeproj/project.pbxproj /mogenerator.xcodeproj/project.xcworkspace/ +!/mogenerator.xcodeproj/xcshareddata/ /mogenerator.xcodeproj/xcuserdata/ /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/project.xcworkspace/xcuserdata/ /contributed templates/Nikita Zhuk/ponso/sample project/PonsoTest/PonsoTest.xcodeproj/xcuserdata/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a978ab13 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: objective-c +osx_image: xcode8 +#xcode_project: mogenerator.xcodeproj +#xcode_scheme: mogenerator +script: cd test && rake diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1f0c08f..d24e2b71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,5 @@ +# Contributing to mogenerator + Thanks for your interest in making mogenerator better. It's easy to contribute to mogenerator: @@ -11,4 +13,12 @@ It's easy to contribute to mogenerator: * Push your changes to GitHub. * Issue your Pull Request to me. -Thanks for playing! \ No newline at end of file +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. + +### Code Guidelines + +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. :) + +Thanks for playing! + +[issue]: https://github.com/rentzsch/mogenerator/issues/new diff --git a/MiscMerge/FoundationAdditions.m b/MiscMerge/FoundationAdditions.m index 05a88cd9..77ba7269 100644 --- a/MiscMerge/FoundationAdditions.m +++ b/MiscMerge/FoundationAdditions.m @@ -30,7 +30,7 @@ */ #import "FoundationAdditions.h" -#import +@import Foundation; #import "NSString+MiscAdditions.h" diff --git a/MiscMerge/MiscMergeExpression.h b/MiscMerge/MiscMergeExpression.h index e354666d..b8658424 100755 --- a/MiscMerge/MiscMergeExpression.h +++ b/MiscMerge/MiscMergeExpression.h @@ -14,7 +14,7 @@ // for a list of all applicable permissions and restrictions. // -#import +@import Foundation; @class MiscMergeEngine; diff --git a/MiscMerge/MiscMergeTemplate.m b/MiscMerge/MiscMergeTemplate.m index b85813a8..2c3a8f08 100755 --- a/MiscMerge/MiscMergeTemplate.m +++ b/MiscMerge/MiscMergeTemplate.m @@ -65,29 +65,29 @@ @implementation MiscMergeTemplate "*/ /*" - * Returns the default string used to start a merge command, "�". A + * Returns the default string used to start a merge command, "«". A * subclass of MiscMergeTemplate could override this method. "*/ + (NSString *)defaultStartDelimiter { // return @"("; - // return @"�"; + // return @"«"; /* This works better for whatever reason. Due to some unknown pecularities, a constant NSString doesn't work under Windows with Apple's implementation. */ - return [NSString stringWithCString:"�" encoding:NSUTF8StringEncoding]; + return [NSString stringWithCString:"«" encoding:NSUTF8StringEncoding]; } /*" - * Returns the default string used to end a merge command, "�". A + * Returns the default string used to end a merge command, "»". A * subclass of MiscMergeTemplate could override this method. "*/ + (NSString *)defaultEndDelimiter { // return @")"; - // return @"�"; + // return @"»"; /* This works better than a constant NSString for whatever reason. See above. */ - return [NSString stringWithCString:"�" encoding:NSUTF8StringEncoding]; + return [NSString stringWithCString:"»" encoding:NSUTF8StringEncoding]; } /*" Creates a new, autoreleased MiscMergeTemplate. "*/ @@ -133,10 +133,10 @@ + (NSString *)defaultEndDelimiter - (NSString *) contentsOfFileWithName:(NSString *)filename { NSError *error = nil; NSString *fileString = [NSString stringWithContentsOfFile:filename - encoding:NSASCIIStringEncoding + encoding:NSUTF8StringEncoding error:&error]; - if (error != nil) { + if (fileString == nil) { NSLog(@"%@: Could not read template file %@ because %@", [self class], filename, [error localizedDescription]); } return fileString; @@ -343,8 +343,8 @@ - (Class)_classForCommand:(NSString *)realCommand * classes with specific names. The name that is looked up is build from * the first word found in %{aCommand}. The first word is turned to all * lower case, with the first letter upper case, and then sandwiched - * between "Merge" and "Command". For example, the merge command "�if xxx - * = y�" has the word "if" as the first word. Thus, the class + * between "Merge" and "Command". For example, the merge command "«if xxx + * = y»" has the word "if" as the first word. Thus, the class * "MergeIfCommand" will be searched for. If the desired class cannot be * found, then it is assumed that the merge command is giving the name of a * field which should be inserted into the output document. diff --git a/MiscMerge/NSNull.h b/MiscMerge/NSNull.h index 78e76f3b..9aa2a459 100755 --- a/MiscMerge/NSNull.h +++ b/MiscMerge/NSNull.h @@ -44,7 +44,7 @@ - (id)copy; - (void)encodeWithCoder:(NSCoder *)aCoder; -- (id)initWithCoder:(NSCoder *)aDecoder; +- (instancetype)initWithCoder:(NSCoder *)aDecoder; - (id)replacementObjectForCoder:(NSCoder *)aCoder; diff --git a/MiscMerge/_MiscMergeDebugCommand.m b/MiscMerge/_MiscMergeDebugCommand.m index f59af187..77be4bf9 100755 --- a/MiscMerge/_MiscMergeDebugCommand.m +++ b/MiscMerge/_MiscMergeDebugCommand.m @@ -15,7 +15,7 @@ // #import "_MiscMergeDebugCommand.h" -#import +@import Foundation; #import "NSString+MiscAdditions.h" #import "NSScanner+MiscMerge.h" diff --git a/MiscMerge/_MiscMergeIfCommand.m b/MiscMerge/_MiscMergeIfCommand.m index f45194a1..199470ba 100755 --- a/MiscMerge/_MiscMergeIfCommand.m +++ b/MiscMerge/_MiscMergeIfCommand.m @@ -23,7 +23,7 @@ @implementation _MiscMergeIfCommand -- (id)init +- (instancetype)init { [super init]; trueBlock = [[MiscMergeCommandBlock alloc] initWithOwner:self]; diff --git a/MiscMerge/_MiscMergeIncludeCommand.m b/MiscMerge/_MiscMergeIncludeCommand.m index 0675a28e..8731cc55 100755 --- a/MiscMerge/_MiscMergeIncludeCommand.m +++ b/MiscMerge/_MiscMergeIncludeCommand.m @@ -54,7 +54,7 @@ - (BOOL)parseFromScanner:(NSScanner *)aScanner template:(MiscMergeTemplate *)tem NSError *error = nil; if ([resolvedFilename length] > 0) - fileString = [NSString stringWithContentsOfFile:resolvedFilename encoding:NSASCIIStringEncoding error:&error]; + fileString = [NSString stringWithContentsOfFile:resolvedFilename encoding:NSUTF8StringEncoding error:&error]; if (fileString) { diff --git a/MiscMerge/_MiscMergeProcedureCommand.m b/MiscMerge/_MiscMergeProcedureCommand.m index 44f1bacd..c7f06fd6 100755 --- a/MiscMerge/_MiscMergeProcedureCommand.m +++ b/MiscMerge/_MiscMergeProcedureCommand.m @@ -15,7 +15,7 @@ // #import "_MiscMergeProcedureCommand.h" -#import +@import Foundation; #import "MiscMergeEngine.h" #import "MiscMergeTemplate.h" #import "MiscMergeCommandBlock.h" diff --git a/README.markdown b/README.markdown index 08e8e93e..6773d68d 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -# mogenerator +# mogenerator Visit the [project's pretty homepage](http://rentzsch.github.com/mogenerator). @@ -14,6 +14,110 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http:// ## Version History +### v1.30.1: Thu Apr 7 2016 [download](https://github.com/rentzsch/mogenerator/releases/download/1.30.1/mogenerator-1.30.1.dmg) + +* [FIX] Use `will`/`didChange` & `will`/`didAccess` in generated code when using `scalarsWhenNonOptional`. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/1646a154c8d9bb2e12b3f23eaca3bbfe9f9bc7c8)) + +* [FIX] Only use `@import` if supported (which Objective-C++ does not). [issue 325](https://github.com/rentzsch/mogenerator/issues/325) ([Samuel Bichsel](https://github.com/melbic)) + +* [FIX] Add space between property type and name. [issue 323](https://github.com/rentzsch/mogenerator/pull/323) ([Daniel Rodríguez Troitiño](https://github.com/drodriguez)) + + + +### v1.30: Mon Mar 21 2016 [download](https://github.com/rentzsch/mogenerator/releases/download/1.30/mogenerator-1.30.dmg) + +Thanks to lieutenant [Justin Williams](https://github.com/justin) for helping with this release. + +* [NEW] Official bundled Swift 2 templates. (Justin Williams [1](https://github.com/rentzsch/mogenerator/commit/8489f4d5e5b8b7bf570ef0d7934f2f9e7a8ecd92) [2](https://github.com/rentzsch/mogenerator/commit/a7f8e53f6357ad1ef9af7d9f7e7f3ec450df334b)) + +* [NEW] "Modern" Objective-C and Swift is default. Apple has made it exceptionally difficult to target older versions of OS X and iOS, so we've given up. The grand `--v2` experiment, which I loved, has been killed (the option will still be accepted to not break existing scripts but is now a no-op). From now on if you need to target an older OS, use an older mogenerator. Sorry. ([Justin Williams](https://github.com/rentzsch/mogenerator/pull/305)) + +* [NEW] Generate Objective-C Lightweight Generics. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/c141670d7f0ee11061ebb67de56c38a260315128)) + +* [NEW] Generate `instancetype`. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/83f031de783f876d843f4987377aac27452171e2)) + +* [NEW] Generate nullability attributes for Objective-C machine templates (`NS_ASSUME_NONNULL_BEGIN`/`nullable`). ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/b12d7a45cec823775ddefaafc0cfcc3c7a99ef32)) + +* [NEW] mogenerator project is now using [Travis CI](https://travis-ci.org/rentzsch/mogenerator). Travis automatically builds and runs mogenerator's test suite on each commit, reporting the results, making it easier+faster to process Pull Requests. (rentzsch) + +* [NEW] Change of branch philosophy: master used to be the "stable" branch. Now it's the branch we're going to land incoming Pull Requests. Pull Requests will be accepted onto master pretty freely, Travis will help catch breaking changes. I want to reduce latency and friction for folks to help out with mogenerator. Related reading: [Drew Crawford's Conduct unbecoming of a hacker](http://sealedabstract.com/rants/conduct-unbecoming-of-a-hacker/). (rentzsch) + +* [NEW] Specifying `--template-var scalarsWhenNonOptional=true` will have mogenerator generate only scalar properties for non-optional entity scalar attributes. For example, consider an `age` attribute. Without this option, mogenerator will generate two properties: `@property (…) NSNumber *age` and `@property (…) uint16_t ageValue`. With this option, only `@property (…) uint16_t age` would be generated, simplifying things since the age attribute can never be `nil`. ([Mr Anonymous](https://github.com/rentzsch/mogenerator/commit/51e8124101121ce8a863e68d597bab9ccd3628cc)) + +* [CHANGE] Replace [Mike Ash-style constant structures](http://www.mikeash.com/pyblog/friday-qa-2011-08-19-namespaced-constants-and-functions.html) in favor of more ARC-friendly NSObject subclasses. Should be source-compatible with with Mike Ash-style. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/69eb701ac7e5b84c8fc0297bf25d9f9f47844705)) + +* [FIX] You can specify an entity's module in Xcode's Core Data Model editor. However, when specifying the current module, the entity class name is prefixed with a period, resulting in an invalid class name. This period is now suppressed. ([Saul Mora](https://github.com/rentzsch/mogenerator/pull/311)) + +* [FIX] momcom: `NSPropertyDescription`'s `optional` wasn't being set correctly. [issue 286](https://github.com/rentzsch/mogenerator/issues/286) ([Matthias Bauch](https://github.com/rentzsch/mogenerator/commit/a04b88de5f872f4a3899de7716db2c9738b55a61)) + +* [FIX] override and explicitly include `xcshareddata` in `.gitignore` and add the default shared schemes. This fixes the problem where `xcodebuild` would fail with an `The project 'mogenerator' does not contain a scheme named 'mogenerator'` error until you first opened it in Xcode. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/8846237ca957437d664b48365c27dd2eb8b87773)) + +* [FIX] Generated indentation. ([Markus Chmelar](https://github.com/iv-mexx) [1](https://github.com/rentzsch/mogenerator/commit/7942420b3156d9cf3e38c17b7a956bd804187bf9) [2](https://github.com/rentzsch/mogenerator/commit/3030a8b1ab6c49ddadbc1033cd0e9a5c5d2d5a71)) + +* [FIX] Use `DERIVED_FILE_DIR` instead of `TMPDIR`. ([Jonathan MacMillan](https://github.com/rentzsch/mogenerator/issues/298)) + +* [CHANGE] Move the constant structures to the end of the machine header file. It's just uninteresting support code. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/f48402f4948790d08ceaeba30666a5998c057350)) + +* [MODERNIZE] MiscMerge: switch to Objective-C Modules. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/030e72a3a6e4edc73a61327ce161659762dc5bed)) + +* [MODERNIZE] Use instancetype internally. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/ddf66cd44e81d2fc196030914c1de4bad15f7e16)) + +* [MODERNIZE] 64-bit only. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/1fc894fe6bb493e202e4798665b17e3076384da6)) + +* [MODERNIZE] Replace `nsenumerate` macro with `for...in`. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/2afdfc84ad1da947e8530f0cb6d5eedf12007e57)) + +* [MODERNIZE] MiscMerge: encode all source files as UTF8. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/8a1a9f625773b7a5e867efdafc6e1a78bea37355)) + +* [MODERNIZE] Set minimum deployment target to 10.8. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/9f652bdc7d508d78ff9248b39bf02c814061b4ca)) + +* [MODERNIZE] Replace RegexKitLite with NSRegularExpression. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/ada5b2ae637001d6c1ce2b08539982b58b77f1f0)) + +* [MODERNIZE] Replace `arrayWithObjects` and `dictionaryWithObjectsAndKeys` with literals. ([Markus Chmelar](https://github.com/iv-mexx) [1](https://github.com/rentzsch/mogenerator/commit/c1139ef2eff8ba26397fbc9be9bab3aece02f40c) [2](https://github.com/rentzsch/mogenerator/commit/7b4d9faffeeb3615d33667a1f8625073876b43ee)) + +* [MODERNIZE] Replace `objectAtIndex:0` with `firstObject`. ([Markus Chmelar](https://github.com/rentzsch/mogenerator/commit/b317ac21b756b01c4eadacc677115583fab7a887)) + +* [REMOVED] //validate machine comments. They were just guides on writing your own validation methods and aren't worth the code clutter. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/92cf5905b8410d26ffb9531bd2f507b07c925754)) + +* [REMOVED] Xmo'd. It hasn't worked for a very long time and I have no immediate plans on putting in the time to get working again. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/47db28b8c07331b9c218603b99ca16fbd3076376)) + + + +### v1.29: Thu Aug 20 2015 [download](https://github.com/rentzsch/mogenerator/releases/download/1.29/mogenerator-1.29.dmg) + +Much thanks to lieutenants [Tom Harrington](https://github.com/atomicbird) and [Justin Williams](https://github.com/justin) for handling this release. + +* [NEW] Use built-in model compiler ([momcom](https://github.com/atomicbird/momcom)) instead of relying on Xcode's `momc`. ([Tom Harrington](https://github.com/rentzsch/mogenerator/pull/225)) + +* [NEW] Documentation generation using User Info keys. ([Daniel Tull](https://github.com/rentzsch/mogenerator/pull/268)) + +* [NEW] Multiuser support (use per-user `$TMPDIR` instead of `/tmp`). ([Annard Brouwer](https://github.com/rentzsch/mogenerator/pull/255)) + +* [NEW] Swift: support for additionalHeaderFileName. ([Leonardo Yvens](https://github.com/rentzsch/mogenerator/pull/285)) + +* [CHANGE] Swift: make generated machine classes and their attributes public. ([Fritz Anderson](https://github.com/rentzsch/mogenerator/commit/2c8b11cae06113d64361b5b049b7948294e72977)) + +* [CHANGE] Swift: make initializers public. ([Dave Reed](https://github.com/rentzsch/mogenerator/commit/015f98758eaf9136b95973a0fc2833b1030c0da8)) + +* [CHANGE] Swift: make enums public. ([Dave Reed](https://github.com/rentzsch/mogenerator/commit/6db379e890c0733cdf8f0e92789aa796ed0cf2de)) + +* [CHANGE] Swift: make mogenerator:readonly work for Swift by rendering the attribute as a read-only computed property. ([Tom Harrington](https://github.com/rentzsch/mogenerator/commit/fc99ca406560ad0fb43b12b995a2ccda6ea23a28)) + +* [CHANGE] Swift: method signatures for validate methods. [issue 281](https://github.com/rentzsch/mogenerator/issues/281). ([Tom Harrington](https://github.com/rentzsch/mogenerator/commit/5d5af8ec63c664ba1fe7cad07f057d5ccc0701cb)) + +* [FIX] Don't generate `-primativeType` and `-setPrimativeType:`. [issue 202](https://github.com/rentzsch/mogenerator/issues/202). ([rentzsch](https://github.com/rentzsch/mogenerator/commit/4ef709cef373138ac8d9368bf8dc034db6c88420)) + +* [FIX] Swift: ordered relationships. [issue 290](https://github.com/rentzsch/mogenerator/issues/290). ([Oleksii Taran](https://github.com/rentzsch/mogenerator/commit/ce927af0f0ebd79903b685091bf20bb31f3fda9c), [Tom Burns](https://github.com/rentzsch/mogenerator/pull/293)) + +* [FIX] Swift: model specified fetch requests. ([Dave Reed](https://github.com/rentzsch/mogenerator/commit/1542d9224dad8ef3c4c58724af604d6fff86f6f5), [Tom Harrington](https://github.com/rentzsch/mogenerator/commit/43f61d066d9daa65d6f941e01b9c0be8e56afb28)) + +* [FIX] Swift: MogenSwiftTest. ([Justin Williams](https://github.com/rentzsch/mogenerator/commit/517e527aa35e7da6ef89e1c11fa45393071085dd), [Dave Reed](https://github.com/rentzsch/mogenerator/commit/3f843651182fc75f9607ba6ed24039b91b9c0bd4)) + +* [FIX] Swift: generation of `override` method declarations. (Tom Harrington [1](https://github.com/rentzsch/mogenerator/commit/6f57408e7a1db0ebd07fb8a8190f819082293014), [2](https://github.com/rentzsch/mogenerator/commit/78e62b1247cfee13bc19131d5bf00fa59794c448)) + +* [FIX] Quote paths in test/Rakefile. ([Jonah Williams](https://github.com/rentzsch/mogenerator/commit/2f2f034d35cc0600ad2e12dd343dc5ccff888b35)) + + + ### v1.28: Wed Sep 10 2014 [download](https://github.com/rentzsch/mogenerator/releases/download/1.28/mogenerator-1.28.dmg) * [NEW] `--v2` argument. I wanted to enable ARC by default, but decided to take it a step further (while not breaking existing scripts). The new `--v2` argument is basically [semantic versioning](http://semver.org) for tool arguments. @@ -39,33 +143,33 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http:// * [NEW] Ordered relationships actually work. [OMG](https://twitter.com/rentzsch/status/281816512489218048). I have them working in a new separate OS X test app, even though [mogenerator's test dir](https://github.com/rentzsch/mogenerator/tree/master/test) fails. I still haven't figured out why, but I'm not holding this back. ([Daniel Tull](https://github.com/rentzsch/mogenerator/pull/140), [Joshua Greene](https://github.com/rentzsch/mogenerator/commit/a971c391b7f720f30934de439519bd3ecda4d453), [Dave Wood](https://github.com/rentzsch/mogenerator/commit/6a5f27b68c70b3b7688cb02c6a4c957c49baba17), [Jonathan del Strother](https://github.com/rentzsch/mogenerator/pull/231)) -- [NEW] Custom scalar types. Specify `attributeValueScalarType` for the name of the property's custom type and `additionalHeaderFileName` if you need to bring in an additional header file for compilation. With this, mogenerator supports C-style and [JREnum](https://github.com/rentzsch/JREnum)-style enums. ([Quentin ARNAULT](https://github.com/rentzsch/mogenerator/commit/43eff6a69098747d95417ed4f5f7b5e686504473)) +* [NEW] Custom scalar types. Specify `attributeValueScalarType` for the name of the property's custom type and `additionalHeaderFileName` if you need to bring in an additional header file for compilation. With this, mogenerator supports C-style and [JREnum](https://github.com/rentzsch/JREnum)-style enums. ([Quentin ARNAULT](https://github.com/rentzsch/mogenerator/commit/43eff6a69098747d95417ed4f5f7b5e686504473)) -- [NEW] Remove unnecessary empty lines in the generated files. ([Stephan Michels](https://github.com/rentzsch/mogenerator/pull/184)) +* [NEW] Remove unnecessary empty lines in the generated files. ([Stephan Michels](https://github.com/rentzsch/mogenerator/pull/184)) * [NEW] Ability to forward-declare `@protocol`s for i.e. transformable types. Specify them via a comma delimited string in the entity's user info under the `attributeTransformableProtocols` key. ([Renaud Tircher](https://github.com/rentzsch/mogenerator/pull/147)) * [NEW] Generate `*UserInfo` key/value pairs as const structs. ([Jeremy Foo](https://github.com/rentzsch/mogenerator/pull/131), [rentzsch](https://github.com/rentzsch/mogenerator/issues/158)) -- [NEW] `--template-var literals` which, when enabled, generates Obj-C literals. ([Brandon Williams](https://github.com/rentzsch/mogenerator/commit/fc6537d97f187121a38ddfe85c52796c8a3be2d0), [Thomas van der Heijden](https://github.com/rentzsch/mogenerator/commit/8b203a03fc4456b28087c7f3e0dc4d7637a89cdc), [rentzsch](https://github.com/rentzsch/mogenerator/commit/63d2ac2ee30cd59db126302eb5f46fb99fe6d460)) +* [NEW] `--template-var literals` which, when enabled, generates Obj-C literals. ([Brandon Williams](https://github.com/rentzsch/mogenerator/commit/fc6537d97f187121a38ddfe85c52796c8a3be2d0), [Thomas van der Heijden](https://github.com/rentzsch/mogenerator/commit/8b203a03fc4456b28087c7f3e0dc4d7637a89cdc), [rentzsch](https://github.com/rentzsch/mogenerator/commit/63d2ac2ee30cd59db126302eb5f46fb99fe6d460)) -- [NEW] Specify `--template-var modules=true` option to avoid `treating #import as an import of module 'CoreData' [-Wauto-import]" warning`. ([Daniel Tull](https://github.com/rentzsch/mogenerator/pull/194)) +* [NEW] Specify `--template-var modules=true` option to avoid `treating #import as an import of module 'CoreData' [-Wauto-import]" warning`. ([Daniel Tull](https://github.com/rentzsch/mogenerator/pull/194)) -- [NEW] Unsigned integers are generated when a property's minimum is set to `0` in the Xcode modeler. ([Dan Pourhadi](https://github.com/rentzsch/mogenerator/commit/e70cab5bf1a721831e43cb756778ee8825f1e011)) +* [NEW] Unsigned integers are generated when a property's minimum is set to `0` in the Xcode modeler. ([Dan Pourhadi](https://github.com/rentzsch/mogenerator/commit/e70cab5bf1a721831e43cb756778ee8825f1e011)) -- [NEW] Add support for setting command-line options via a JSON config file. ([Simon Whitaker](https://github.com/rentzsch/mogenerator/pull/163)) +* [NEW] Add support for setting command-line options via a JSON config file. ([Simon Whitaker](https://github.com/rentzsch/mogenerator/pull/163)) -- [NEW] Add CONTRIBUTING.md file. It's now even easier to contribute to mogenerator :) ([rentzsch](https://github.com/rentzsch/mogenerator/commit/e8a05a3161be2a25cb072041936196c28dbdda07)) +* [NEW] Add CONTRIBUTING.md file. It's now even easier to contribute to mogenerator :) ([rentzsch](https://github.com/rentzsch/mogenerator/commit/e8a05a3161be2a25cb072041936196c28dbdda07)) -- [NEW] Add MIT LICENSE file to make it clear templates are under the same license. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/b8b57d1d88d59680c932096eb27d327b7324f56d)) +* [NEW] Add MIT LICENSE file to make it clear templates are under the same license. ([rentzsch](https://github.com/rentzsch/mogenerator/commit/b8b57d1d88d59680c932096eb27d327b7324f56d)) * [CHANGE] Suppress generation of `-setPrimativeType:` method. [issue 16](https://github.com/rentzsch/mogenerator/issues/16). ([rentzsch](https://github.com/rentzsch/mogenerator/commit/cd9809de0ec266995069c4350feb0bf78ebc6795)) -- [CHANGE] Add a warning when skipping an attribute named 'type'. ([Simon Whitaker](https://github.com/rentzsch/mogenerator/pull/165)) +* [CHANGE] Add a warning when skipping an attribute named 'type'. ([Simon Whitaker](https://github.com/rentzsch/mogenerator/pull/165)) * [CHANGE] Add explicit `atomic` to sooth `-Weverything`. ([Daniel Tull](https://github.com/rentzsch/mogenerator/pull/153)) -- [CHANGE] iOS 8 changes objectID from a getter into a property, resulting in a warning. Templates updated to match. ([Ryan Johnson](https://github.com/rentzsch/mogenerator/pull/201)) +* [CHANGE] iOS 8 changes objectID from a getter into a property, resulting in a warning. Templates updated to match. ([Ryan Johnson](https://github.com/rentzsch/mogenerator/pull/201)) * [FIX] Support newly-created models when `--model=*.xcdatamodeld`. [issue 137](https://github.com/rentzsch/mogenerator/issues/137). ([Sergey](https://github.com/rentzsch/mogenerator/pull/138)) @@ -87,6 +191,8 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http:// * [TEST] Escape spaces in mogenerator build path. ([Daniel Tull](https://github.com/rentzsch/mogenerator/issues/151)) + + ### v1.27: Mon Nov 12 2012 [download](http://github.com/downloads/rentzsch/mogenerator/mogenerator-1.27.dmg) * [NEW] You can now pass .xcdatamodeld paths to mogenerator. mogenerator will look inside the directory, read its hidden `.xccurrentversion` file and use the "current" .xcdatamodel file. ([Alexander Zats](https://github.com/rentzsch/mogenerator/pull/102)) @@ -244,7 +350,7 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http:// * [NEW] Xmo'd works with versioned data models. ([rentzsch](http://github.com/rentzsch/mogenerator/commit/5195153e8ffce08eb82a63c8fde6aea20b0e6d34)) * [NEW] Support for fetched properties ([Nikita Zhuk](http://github.com/rentzsch/mogenerator/commit/7481add810ef798c0f678d782d7d8fb9e6ff4d46)) - + * [NEW] `NSParameterAssert(moc)` in fetch request wrappers. ([rentzsch](http://github.com/rentzsch/mogenerator/commit/015aa0bec7dae21058c057bfa6b4f6748e444e00)) @@ -255,9 +361,9 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http:// * [NEW] `--list-source-files` option, which lists model-related source files. ([rentzsch](http://github.com/rentzsch/mogenerator/commit/19fe5be5d9c0e13721cda4cdb18f8209222657f6)) -* [NEW] Add `--orphaned` option. ([rentzsch](http://github.com/rentzsch/mogenerator/commit/b64370f7532bcaf709fc8e0da8561306fa09a412)) +* [NEW] Add `--orphaned` option. ([rentzsch](http://github.com/rentzsch/mogenerator/commit/b64370f7532bcaf709fc8e0da8561306fa09a412)) -Couple `--orphaned` with `--model` to get a listing of source files that no longer have corresponding entities in the model. The intent is to be able to pipe its output to xargs + git to remove deleted and renamed entities in one command, something like: +Couple `--orphaned` with `--model` to get a listing of source files that no longer have corresponding entities in the model. The intent is to be able to pipe its output to xargs + git to remove deleted and renamed entities in one command, something like: $ mogenerator --model ../MyModel.xcdatamodel --orphaned | xargs git rm @@ -277,7 +383,7 @@ Couple `--orphaned` with `--model` to get a listing of source files that no long ### v1.15: Mon 2 Nov 2009 [download](http://cloud.github.com/downloads/rentzsch/mogenerator/mogenerator-1.15.dmg) -* [CHANGE] Xmo'd: now adds `.h` human+machine header files to project (in addition +* [CHANGE] Xmo'd: now adds `.h` human+machine header files to project (in addition to current `.m` + `.mm` files). ([rentzsch](http://github.com/rentzsch/mogenerator/commit/5c88445e366b15d4a4700b7f9a10a6915ff6b20b)) * [NEW] Now supports key paths in fetch request predicates so long as they're relationships. ([Jon Olson](http://github.com/rentzsch/mogenerator/commit/6bd8051a70d32fe73c1965cb449d2f40d403260a)) diff --git a/RegexKitLite.h b/RegexKitLite.h deleted file mode 100644 index 920cb439..00000000 --- a/RegexKitLite.h +++ /dev/null @@ -1,220 +0,0 @@ -// -// RegexKitLite.h -// http://regexkit.sourceforge.net/ -// Licensed under the terms of the BSD License, as specified below. -// - -/* - Copyright (c) 2008-2009, John Engelhart - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of the Zang Industries nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifdef __OBJC__ -#import -#import -#import -#import -#import -#endif // __OBJC__ - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef REGEXKITLITE_VERSION_DEFINED -#define REGEXKITLITE_VERSION_DEFINED - -#define _RKL__STRINGIFY(b) #b -#define _RKL_STRINGIFY(a) _RKL__STRINGIFY(a) -#define _RKL_JOIN_VERSION(a,b) _RKL_STRINGIFY(a##.##b) -#define _RKL_VERSION_STRING(a,b) _RKL_JOIN_VERSION(a,b) - -#define REGEXKITLITE_VERSION_MAJOR 3 -#define REGEXKITLITE_VERSION_MINOR 3 - -#define REGEXKITLITE_VERSION_CSTRING _RKL_VERSION_STRING(REGEXKITLITE_VERSION_MAJOR, REGEXKITLITE_VERSION_MINOR) -#define REGEXKITLITE_VERSION_NSSTRING @REGEXKITLITE_VERSION_CSTRING - -#endif // REGEXKITLITE_VERSION_DEFINED - -// For Mac OS X < 10.5. -#ifndef NSINTEGER_DEFINED -#define NSINTEGER_DEFINED -#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) -typedef long NSInteger; -typedef unsigned long NSUInteger; -#define NSIntegerMin LONG_MIN -#define NSIntegerMax LONG_MAX -#define NSUIntegerMax ULONG_MAX -#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) -typedef int NSInteger; -typedef unsigned int NSUInteger; -#define NSIntegerMin INT_MIN -#define NSIntegerMax INT_MAX -#define NSUIntegerMax UINT_MAX -#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) -#endif // NSINTEGER_DEFINED - -#ifndef RKLREGEXOPTIONS_DEFINED -#define RKLREGEXOPTIONS_DEFINED - -// These must be idential to their ICU regex counterparts. See http://www.icu-project.org/userguide/regexp.html -enum { - RKLNoOptions = 0, - RKLCaseless = 2, - RKLComments = 4, - RKLDotAll = 32, - RKLMultiline = 8, - RKLUnicodeWordBoundaries = 256 -}; -typedef uint32_t RKLRegexOptions; // This must be identical to the ICU 'flags' argument type. - -#endif // RKLREGEXOPTIONS_DEFINED - -#ifndef _REGEXKITLITE_H_ -#define _REGEXKITLITE_H_ - -#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465) -#define RKL_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) -#else -#define RKL_DEPRECATED_ATTRIBUTE -#endif - -// This requires a few levels of rewriting to get the desired results. -#define _RKL_CONCAT_2(c,d) c ## d -#define _RKL_CONCAT(a,b) _RKL_CONCAT_2(a,b) - -#ifdef RKL_PREPEND_TO_METHODS -#define RKL_METHOD_PREPEND(x) _RKL_CONCAT(RKL_PREPEND_TO_METHODS, x) -#else // RKL_PREPEND_TO_METHODS -#define RKL_METHOD_PREPEND(x) x -#endif // RKL_PREPEND_TO_METHODS - -// If it looks like low memory notifications might be available, add code to register and respond to them. -// This is (should be) harmless if it turns out that this isn't the case, since the notification that we register for, -// UIApplicationDidReceiveMemoryWarningNotification, is dynamically looked up via dlsym(). -#if ((defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0))) && (!defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) || (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS != 0)) -#define RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS 1 -#endif - -#ifdef __OBJC__ - -// NSException exception name. -extern NSString * const RKLICURegexException; - -// NSError error domains and user info keys. -extern NSString * const RKLICURegexErrorDomain; - -extern NSString * const RKLICURegexErrorCodeErrorKey; -extern NSString * const RKLICURegexErrorNameErrorKey; -extern NSString * const RKLICURegexLineErrorKey; -extern NSString * const RKLICURegexOffsetErrorKey; -extern NSString * const RKLICURegexPreContextErrorKey; -extern NSString * const RKLICURegexPostContextErrorKey; -extern NSString * const RKLICURegexRegexErrorKey; -extern NSString * const RKLICURegexRegexOptionsErrorKey; - -@interface NSString (RegexKitLiteAdditions) - -+ (void)RKL_METHOD_PREPEND(clearStringCache); - -// Although these are marked as deprecated, a bug in GCC prevents a warning from being issues for + class methods. Filed bug with Apple, #6736857. -+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex RKL_DEPRECATED_ATTRIBUTE; -+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error RKL_DEPRECATED_ATTRIBUTE; - -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex; -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range; -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; - -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex; -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range; -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error; - -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex; -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture; -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range; -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; - -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex; -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture; -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range; -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; - -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; - - //// - -- (NSInteger)RKL_METHOD_PREPEND(captureCount); -- (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error; - -- (BOOL)RKL_METHOD_PREPEND(isRegexValid); -- (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error; - -- (void)RKL_METHOD_PREPEND(flushCachedRegexData); - -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex; -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture; -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range; -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error; - - -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex; -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; - -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex; -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range; -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error; - -@end - -@interface NSMutableString (RegexKitLiteAdditions) - -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement; -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange; -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error; - -@end - -#endif // __OBJC__ - -#endif // _REGEXKITLITE_H_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/RegexKitLite.m b/RegexKitLite.m deleted file mode 100644 index d8e4ba21..00000000 --- a/RegexKitLite.m +++ /dev/null @@ -1,1655 +0,0 @@ -// -// RegexKitLite.m -// http://regexkit.sourceforge.net/ -// Licensed under the terms of the BSD License, as specified below. -// - -/* - Copyright (c) 2008-2009, John Engelhart - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of the Zang Industries nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#import -#import -#import -#import -#import -#import -#ifdef __OBJC_GC__ -#import -#define RKL_STRONG_REF __strong -#else // __OBJC_GC__ -#define RKL_STRONG_REF -#endif // __OBJC_GC__ - -#if (defined(TARGET_OS_EMBEDDED) && (TARGET_OS_EMBEDDED != 0)) || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0)) || (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)) -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#import "RegexKitLite.h" - -// If the gcc flag -mmacosx-version-min is used with, for example, '=10.2', give a warning that the libicucore.dylib is only available on >= 10.3. -// If you are reading this comment because of this warning, this is to let you know that linking to /usr/lib/libicucore.dylib will cause your executable to fail on < 10.3. -// You will need to build your own version of the ICU library and link to that in order for RegexKitLite to work successfully on < 10.3. This is not simple. - -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1030 -#warning The ICU dynamic shared library, /usr/lib/libicucore.dylib, is only available on Mac OS X 10.3 and later. -#warning You will need to supply a version of the ICU library to use RegexKitLite on Mac OS X 10.2 and earlier. -#endif - -//////////// -#pragma mark Compile time tuneables - -#ifndef RKL_CACHE_SIZE -#define RKL_CACHE_SIZE (23UL) -#endif - -#ifndef RKL_FIXED_LENGTH -#define RKL_FIXED_LENGTH (2048UL) -#endif - -#ifndef RKL_STACK_LIMIT -#define RKL_STACK_LIMIT (128UL * 1024UL) -#endif - -#ifdef RKL_APPEND_TO_ICU_FUNCTIONS -#define RKL_ICU_FUNCTION_APPEND(x) _RKL_CONCAT(x, RKL_APPEND_TO_ICU_FUNCTIONS) -#else // RKL_APPEND_TO_ICU_FUNCTIONS -#define RKL_ICU_FUNCTION_APPEND(x) x -#endif // RKL_APPEND_TO_ICU_FUNCTIONS - -#if defined(RKL_DTRACE) && (RKL_DTRACE != 0) -#define _RKL_DTRACE_ENABLED -#endif // defined(RKL_DTRACE) && (RKL_DTRACE != 0) - -// These are internal, non-public tuneables. -#define RKL_SCRATCH_BUFFERS (4UL) -#define RKL_CACHE_LINE_SIZE (64UL) -#define RKL_DTRACE_REGEXUTF8_SIZE (64UL) - -////////////// -#pragma mark - -#pragma mark GCC / Compiler macros - -#if defined (__GNUC__) && (__GNUC__ >= 4) -#define RKL_ATTRIBUTES(attr, ...) __attribute__((attr, ##__VA_ARGS__)) -#define RKL_EXPECTED(cond, expect) __builtin_expect((long)(cond), (expect)) -#define RKL_PREFETCH(ptr) __builtin_prefetch(ptr) -#define RKL_PREFETCH_UNICHAR(ptr, off) { const char *p = ((const char *)(ptr)) + ((off) * sizeof(UniChar)) + RKL_CACHE_LINE_SIZE; RKL_PREFETCH(p); RKL_PREFETCH(p + RKL_CACHE_LINE_SIZE); } -#define RKL_HAVE_CLEANUP -#define RKL_CLEANUP(func) RKL_ATTRIBUTES(cleanup(func)) -#else // defined (__GNUC__) && (__GNUC__ >= 4) -#define RKL_ATTRIBUTES(attr, ...) -#define RKL_EXPECTED(cond, expect) (cond) -#define RKL_PREFETCH(ptr) -#define RKL_PREFETCH_UNICHAR(ptr, off) -#define RKL_CLEANUP(func) -#endif // defined (__GNUC__) && (__GNUC__ >= 4) - -#define RKL_STATIC_INLINE static __inline__ RKL_ATTRIBUTES(always_inline) -#define RKL_UNUSED_ARG RKL_ATTRIBUTES(unused) -#define RKL_NONNULL_ARGS(arg, ...) RKL_ATTRIBUTES(nonnull(arg, ##__VA_ARGS__)) -#define RKL_NONNULL_ARGS_WARN_UNUSED(arg, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(arg, ##__VA_ARGS__)) - -#if defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) -#define RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__), alloc_size(as)) -#else // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) -#define RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(as, nn, ...) RKL_ATTRIBUTES(warn_unused_result, nonnull(nn, ##__VA_ARGS__)) -#endif // defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3) - - -//////////// -#pragma mark - -#pragma mark Assertion macros - -// These macros are nearly identical to their NSCParameterAssert siblings. -// This is required because nearly everything is done while cacheSpinLock is locked. -// We need to safely unlock before throwing any of these exceptions. -// @try {} @finally {} significantly slows things down so it's not used. - -#define RKLCAssertDictionary(d, ...) rkl_makeAssertDictionary(__PRETTY_FUNCTION__, __FILE__, __LINE__, (d), ##__VA_ARGS__) -#define RKLCDelayedHardAssert(c, e, g) do { id *_e=(e); int _c=(c); if(RKL_EXPECTED(_e == NULL, 0L) || RKL_EXPECTED(*_e != NULL, 0L)) { goto g; } if(RKL_EXPECTED(!_c, 0L)) { *_e = RKLCAssertDictionary(@"Invalid parameter not satisfying: %s", #c); goto g; } } while(0) - -#ifdef NS_BLOCK_ASSERTIONS -#define RKLCDelayedAssert(c, e, g) -#define RKL_UNUSED_ASSERTION_ARG RKL_ATTRIBUTES(unused) -#else // NS_BLOCK_ASSERTIONS -#define RKLCDelayedAssert(c, e, g) RKLCDelayedHardAssert(c, e, g) -#define RKL_UNUSED_ASSERTION_ARG -#endif // NS_BLOCK_ASSERTIONS - -#define RKL_EXCEPTION(e, f, ...) [NSException exceptionWithName:(e) reason:rkl_stringFromClassAndMethod((self), (_cmd), (f), ##__VA_ARGS__) userInfo:NULL] -#define RKL_RAISE_EXCEPTION(e, f, ...) [RKL_EXCEPTION(e, f, ##__VA_ARGS__) raise] - -//////////// -#pragma mark - -#pragma mark Utility functions and macros - -RKL_STATIC_INLINE BOOL NSRangeInsideRange(NSRange cin, NSRange win) RKL_ATTRIBUTES(warn_unused_result); -RKL_STATIC_INLINE BOOL NSRangeInsideRange(NSRange cin, NSRange win) { return((((cin.location - win.location) <= win.length) && ((NSMaxRange(cin) - win.location) <= win.length)) ? YES : NO); } - -#define NSMakeRange(loc, len) ((NSRange){.location=(NSUInteger)(loc), .length=(NSUInteger)(len)}) -#define CFMakeRange(loc, len) ((CFRange){.location= (CFIndex)(loc), .length= (CFIndex)(len)}) -#define NSNotFoundRange ((NSRange){.location=(NSUInteger)NSNotFound, .length= 0UL}) -#define NSMaxiumRange ((NSRange){.location= 0UL, .length= NSUIntegerMax}) - -//////////// -#pragma mark - -#pragma mark Exported NSString symbols for exception names, error domains, error keys, etc - -NSString * const RKLICURegexException = @"RKLICURegexException"; - -NSString * const RKLICURegexErrorDomain = @"RKLICURegexErrorDomain"; - -NSString * const RKLICURegexErrorCodeErrorKey = @"RKLICURegexErrorCode"; -NSString * const RKLICURegexErrorNameErrorKey = @"RKLICURegexErrorName"; -NSString * const RKLICURegexLineErrorKey = @"RKLICURegexLine"; -NSString * const RKLICURegexOffsetErrorKey = @"RKLICURegexOffset"; -NSString * const RKLICURegexPreContextErrorKey = @"RKLICURegexPreContext"; -NSString * const RKLICURegexPostContextErrorKey = @"RKLICURegexPostContext"; -NSString * const RKLICURegexRegexErrorKey = @"RKLICURegexRegex"; -NSString * const RKLICURegexRegexOptionsErrorKey = @"RKLICURegexRegexOptions"; - -//////////// -#pragma mark - -#pragma mark Type / struct definitions - -// In general, the ICU bits and pieces here must exactly match the definition in the ICU sources. - -#define U_STRING_NOT_TERMINATED_WARNING -124 -#define U_ZERO_ERROR 0 -#define U_INDEX_OUTOFBOUNDS_ERROR 8 -#define U_BUFFER_OVERFLOW_ERROR 15 -#define U_PARSE_CONTEXT_LEN 16 - -typedef struct uregex uregex; // Opaque ICU regex type. - -typedef struct UParseError { // This must be exactly the same as the 'real' ICU declaration. - int32_t line; - int32_t offset; - UniChar preContext[U_PARSE_CONTEXT_LEN]; - UniChar postContext[U_PARSE_CONTEXT_LEN]; -} UParseError; - -// For use with GCC's cleanup() __attribute__. -#define RKLLockedCacheSpinLock ((NSUInteger)(1UL<<0)) -#define RKLUnlockedCacheSpinLock ((NSUInteger)(1UL<<1)) - -enum { - RKLSplitOp = 1, - RKLReplaceOp = 2, - RKLRangeOp = 3, - RKLArrayOfStringsOp = 4, - RKLArrayOfCapturesOp = 5, - RKLCapturesArrayOp = 6, - RKLMaskOp = 0xf, - RKLReplaceMutable = 1 << 4, - RKLSubcapturesArray = 1 << 5, -}; -typedef NSUInteger RKLRegexOp; - -typedef struct { - NSRange *ranges, findInRange; - NSInteger capacity, found, findUpTo, capture; - size_t size, stackUsed; - void **rangesScratchBuffer; - RKL_STRONG_REF void **stringsScratchBuffer; - RKL_STRONG_REF void **arraysScratchBuffer; -} RKLFindAll; - -typedef struct { - CFStringRef string; - CFHashCode hash; - CFIndex length; - RKL_STRONG_REF UniChar *uniChar; -} RKLBuffer; - -typedef struct { - CFStringRef regexString; - RKLRegexOptions options; - uregex *icu_regex; - NSInteger captureCount; - - CFStringRef setToString; - CFHashCode setToHash; - CFIndex setToLength; - NSUInteger setToIsImmutable:1; - NSUInteger setToNeedsConversion:1; - const UniChar *setToUniChar; - NSRange setToRange, lastFindRange, lastMatchRange; -#ifndef __LP64__ - NSUInteger pad[1]; // For 32 bits, this makes the struct 64 bytes exactly, which is good for cache line alignment. -#endif // __LP64__ -} RKLCacheSlot; - -//////////// -#pragma mark - -#pragma mark Translation unit scope global variables - -static UniChar fixedUniChar[(RKL_FIXED_LENGTH)]; // This is the fixed sized UTF-16 conversion buffer. -static RKLCacheSlot rkl_cacheSlots[(RKL_CACHE_SIZE)], *lastCacheSlot; -static OSSpinLock cacheSpinLock = OS_SPINLOCK_INIT; -static RKLBuffer dynamicBuffer, fixedBuffer = {NULL, 0UL, 0L, &fixedUniChar[0]}; -static const UniChar emptyUniCharString[1]; // For safety, icu_regexes are 'set' to this when the string they were searched is cleared. -static RKL_STRONG_REF void *scratchBuffer[(RKL_SCRATCH_BUFFERS)]; // Used to hold temporary allocations that are allocated via reallocf(). - -//////////// -#pragma mark - -#pragma mark CFArray call backs - -// These are used when running under manual memory management for the array that rkl_splitArray creates. -// The split strings are created, but not autoreleased. The (immutable) array is created using these callbacks, which skips the CFRetain() call, effectively transferring ownership to the CFArray object. -// For each split string this saves the overhead of an autorelease, then an array retain, then an NSAutoreleasePool release. This is good for a ~30% speed increase. - -static void RKLCFArrayRelease (CFAllocatorRef allocator RKL_UNUSED_ARG, const void *ptr) { CFRelease((CFTypeRef)ptr); } -static const CFArrayCallBacks rkl_transferOwnershipArrayCallBacks = { (CFIndex)0L, NULL, RKLCFArrayRelease, CFCopyDescription, CFEqual }; - -#ifdef __OBJC_GC__ -//////////// -#pragma mark - -#pragma mark Low-level Garbage Collection aware memory/resource allocation utilities -// If compiled with Garbage Collection, we need to be able to do a few things slightly differently. -// The basic premiss is that under GC we use a trampoline function pointer which is set to a _start function to catch the first invocation. -// The _start function checks if GC is running and then overwrites the function pointer with the appropriate routine. Think of it as 'lazy linking'. - -enum { RKLScannedOption = NSScannedOption }; - -// rkl_collectingEnabled uses objc_getClass() to get the NSGarbageCollector class, which doesn't exist on earlier systems. -// This allows for graceful failure should we find ourselves running on an earlier version of the OS without NSGarbageCollector. -static BOOL rkl_collectingEnabled_first (void); -static BOOL rkl_collectingEnabled_yes (void) { return(YES); } -static BOOL rkl_collectingEnabled_no (void) { return(NO); } -static BOOL(*rkl_collectingEnabled) (void) = rkl_collectingEnabled_first; -static BOOL rkl_collectingEnabled_first (void) { - BOOL gcEnabled = ([objc_getClass("NSGarbageCollector") defaultCollector] != NULL) ? YES : NO; - if(gcEnabled == YES) { - // This section of code is required due to what I consider to be a fundamental design flaw in Cocoas GC system. - // Earlier versions of "Garbage Collection Programming Guide" stated that (paraphrased) "all globals are automatically roots". - // Current versions of the guide now include the following warning: - // "You may pass addresses of strong globals or statics into routines expecting pointers to object pointers (such as id* or NSError**) - // only if they have first been assigned to directly, rather than through a pointer dereference." - // This is a surprisingly non-trivial condition to actually meet in practice and is a recipe for impossible to debug race condition bugs. - // We just happen to be very, very, very lucky in the fact that we can initilize our root set before the first use. - int x; - for(x = 0; x < (int)(RKL_SCRATCH_BUFFERS); x++) { scratchBuffer[x] = NSAllocateCollectable(16UL, 0UL); scratchBuffer[x] = NULL; } - dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)NSAllocateCollectable(16UL, 0UL); dynamicBuffer.uniChar = NULL; - } - return((rkl_collectingEnabled = (gcEnabled == YES) ? rkl_collectingEnabled_yes : rkl_collectingEnabled_no)()); -} - -// rkl_realloc() -static void *rkl_realloc_first (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags); -static void *rkl_realloc_std (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags RKL_UNUSED_ARG) { return((*ptr = reallocf(*ptr, size))); } -static void *rkl_realloc_gc (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) { return((*ptr = NSReallocateCollectable(*ptr, (NSUInteger)size, flags))); } -static void *(*rkl_realloc) (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(2,1) = rkl_realloc_first; -static void *rkl_realloc_first (RKL_STRONG_REF void **ptr, size_t size, NSUInteger flags) { if(rkl_collectingEnabled()==YES) { rkl_realloc = rkl_realloc_gc; } else { rkl_realloc = rkl_realloc_std; } return(rkl_realloc(ptr, size, flags)); } - -// rkl_free() -static void * rkl_free_first (RKL_STRONG_REF void **ptr); -static void * rkl_free_std (RKL_STRONG_REF void **ptr) { if(*ptr != NULL) { free(*ptr); *ptr = NULL; } return(NULL); } -static void * rkl_free_gc (RKL_STRONG_REF void **ptr) { if(*ptr != NULL) { *ptr = NULL; } return(NULL); } -static void *(*rkl_free) (RKL_STRONG_REF void **ptr) RKL_NONNULL_ARGS(1) = rkl_free_first; -static void *rkl_free_first (RKL_STRONG_REF void **ptr) { if(rkl_collectingEnabled()==YES) { rkl_free = rkl_free_gc; } else { rkl_free = rkl_free_std; } return(rkl_free(ptr)); } - -// rkl_CFAutorelease() -static id rkl_CFAutorelease_first (CFTypeRef obj); -static id rkl_CFAutorelease_std (CFTypeRef obj) { return([(id)obj autorelease]); } -static id rkl_CFAutorelease_gc (CFTypeRef obj) { return(NSMakeCollectable(obj)); } -static id(*rkl_CFAutorelease) (CFTypeRef obj) = rkl_CFAutorelease_first; -static id rkl_CFAutorelease_first (CFTypeRef obj) { return((rkl_CFAutorelease = (rkl_collectingEnabled()==YES) ? rkl_CFAutorelease_gc : rkl_CFAutorelease_std)(obj)); } - -// rkl_CreateStringWithSubstring() -static id rkl_CreateStringWithSubstring_first (id string, NSRange range); -static id rkl_CreateStringWithSubstring_std (id string, NSRange range) { return((id)CFStringCreateWithSubstring(NULL, (CFStringRef)string, CFMakeRange((CFIndex)range.location, (CFIndex)range.length))); } -static id rkl_CreateStringWithSubstring_gc (id string, NSRange range) { return([string substringWithRange:range]); } -static id(*rkl_CreateStringWithSubstring) (id string, NSRange range) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateStringWithSubstring_first; -static id rkl_CreateStringWithSubstring_first (id string, NSRange range) { return((rkl_CreateStringWithSubstring = (rkl_collectingEnabled()==YES) ? rkl_CreateStringWithSubstring_gc : rkl_CreateStringWithSubstring_std)(string, range)); } - -// rkl_ReleaseObject() -static id rkl_ReleaseObject_first (id obj); -static id rkl_ReleaseObject_std (id obj) { CFRelease((CFTypeRef)obj); return(NULL); } -static id rkl_ReleaseObject_gc (id obj RKL_UNUSED_ARG) { return(NULL); } -static id (*rkl_ReleaseObject) (id obj) RKL_NONNULL_ARGS(1) = rkl_ReleaseObject_first; -static id rkl_ReleaseObject_first (id obj) { return((rkl_ReleaseObject = (rkl_collectingEnabled()==YES) ? rkl_ReleaseObject_gc : rkl_ReleaseObject_std)(obj)); } - -// rkl_CreateArrayWithObjects() -static id rkl_CreateArrayWithObjects_first (void **objects, NSUInteger count); -static id rkl_CreateArrayWithObjects_std (void **objects, NSUInteger count) { return((id)CFArrayCreate(NULL, (const void **)objects, (CFIndex)count, &rkl_transferOwnershipArrayCallBacks)); } -static id rkl_CreateArrayWithObjects_gc (void **objects, NSUInteger count) { return([NSArray arrayWithObjects:(const id *)objects count:count]); } -static id(*rkl_CreateArrayWithObjects) (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateArrayWithObjects_first; -static id rkl_CreateArrayWithObjects_first (void **objects, NSUInteger count) { return((rkl_CreateArrayWithObjects = (rkl_collectingEnabled()==YES) ? rkl_CreateArrayWithObjects_gc : rkl_CreateArrayWithObjects_std)(objects, count)); } - -// rkl_CreateAutoreleasedArray() -static id rkl_CreateAutoreleasedArray_first (void **objects, NSUInteger count); -static id rkl_CreateAutoreleasedArray_std (void **objects, NSUInteger count) { return((id)rkl_CFAutorelease(rkl_CreateArrayWithObjects(objects, count))); } -static id rkl_CreateAutoreleasedArray_gc (void **objects, NSUInteger count) { return( rkl_CreateArrayWithObjects(objects, count) ); } -static id(*rkl_CreateAutoreleasedArray) (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1) = rkl_CreateAutoreleasedArray_first; -static id rkl_CreateAutoreleasedArray_first (void **objects, NSUInteger count) { return((rkl_CreateAutoreleasedArray = (rkl_collectingEnabled()==YES) ? rkl_CreateAutoreleasedArray_gc : rkl_CreateAutoreleasedArray_std)(objects, count)); } - -#else // __OBJC_GC__ not defined -//////////// -#pragma mark - -#pragma mark Low-level explicit memory/resource allocation utilities - -enum { RKLScannedOption = 0 }; - -#define rkl_collectingEnabled() (NO) - -RKL_STATIC_INLINE void *rkl_realloc (void **ptr, size_t size, NSUInteger flags) RKL_ALLOC_SIZE_NON_NULL_ARGS_WARN_UNUSED(2,1); -RKL_STATIC_INLINE void *rkl_free (void **ptr) RKL_NONNULL_ARGS(1); -RKL_STATIC_INLINE id rkl_CFAutorelease (CFTypeRef obj); -RKL_STATIC_INLINE id rkl_CreateAutoreleasedArray (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1); -RKL_STATIC_INLINE id rkl_CreateArrayWithObjects (void **objects, NSUInteger count) RKL_NONNULL_ARGS_WARN_UNUSED(1); -RKL_STATIC_INLINE id rkl_CreateStringWithSubstring (id string, NSRange range) RKL_NONNULL_ARGS_WARN_UNUSED(1); -RKL_STATIC_INLINE id rkl_ReleaseObject (id obj) RKL_NONNULL_ARGS(1); - -RKL_STATIC_INLINE void *rkl_realloc (void **ptr, size_t size, NSUInteger flags RKL_UNUSED_ARG) { return((*ptr = reallocf(*ptr, size))); } -RKL_STATIC_INLINE void *rkl_free (void **ptr) { if(*ptr != NULL) { free(*ptr); *ptr = NULL; } return(NULL); } -RKL_STATIC_INLINE id rkl_CFAutorelease (CFTypeRef obj) { return([(id)obj autorelease]); } -RKL_STATIC_INLINE id rkl_CreateArrayWithObjects (void **objects, NSUInteger count) { return((id)CFArrayCreate(NULL, (const void **)objects, (CFIndex)count, &rkl_transferOwnershipArrayCallBacks)); } -RKL_STATIC_INLINE id rkl_CreateAutoreleasedArray (void **objects, NSUInteger count) { return(rkl_CFAutorelease(rkl_CreateArrayWithObjects(objects, count))); } -RKL_STATIC_INLINE id rkl_CreateStringWithSubstring (id string, NSRange range) { return((id)CFStringCreateWithSubstring(NULL, (CFStringRef)string, CFMakeRange((CFIndex)range.location, (CFIndex)range.length))); } -RKL_STATIC_INLINE id rkl_ReleaseObject (id obj) { CFRelease((CFTypeRef)obj); return(NULL); } - -#endif // __OBJC_GC__ - -//////////// -#pragma mark - -#pragma mark ICU function prototypes - -// ICU functions. See http://www.icu-project.org/apiref/icu4c/uregex_8h.html Tweaked slightly from the originals, but functionally identical. -const char *RKL_ICU_FUNCTION_APPEND(u_errorName) (int32_t status) RKL_ATTRIBUTES(pure); -int32_t RKL_ICU_FUNCTION_APPEND(u_strlen) (const UniChar *s) RKL_ATTRIBUTES(nonnull(1), pure); -int32_t RKL_ICU_FUNCTION_APPEND(uregex_appendReplacement) (uregex *regexp, const UniChar *replacementText, int32_t replacementLength, UniChar **destBuf, int32_t *destCapacity, int32_t *status) RKL_NONNULL_ARGS(1,2,4,5,6); -int32_t RKL_ICU_FUNCTION_APPEND(uregex_appendTail) (uregex *regexp, UniChar **destBuf, int32_t *destCapacity, int32_t *status) RKL_NONNULL_ARGS(1,2,3,4); -void RKL_ICU_FUNCTION_APPEND(uregex_close) (uregex *regexp) RKL_NONNULL_ARGS(1); -int32_t RKL_ICU_FUNCTION_APPEND(uregex_end) (uregex *regexp, int32_t groupNum, int32_t *status) RKL_NONNULL_ARGS(1,3); -BOOL RKL_ICU_FUNCTION_APPEND(uregex_find) (uregex *regexp, int32_t location, int32_t *status) RKL_NONNULL_ARGS(1,3); -BOOL RKL_ICU_FUNCTION_APPEND(uregex_findNext) (uregex *regexp, int32_t *status) RKL_NONNULL_ARGS(1,2); -int32_t RKL_ICU_FUNCTION_APPEND(uregex_groupCount) (uregex *regexp, int32_t *status) RKL_NONNULL_ARGS(1,2); -uregex *RKL_ICU_FUNCTION_APPEND(uregex_open) (const UniChar *pattern, int32_t patternLength, RKLRegexOptions flags, UParseError *parseError, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,4,5); -void RKL_ICU_FUNCTION_APPEND(uregex_reset) (uregex *regexp, int32_t newIndex, int32_t *status) RKL_NONNULL_ARGS(1,3); -void RKL_ICU_FUNCTION_APPEND(uregex_setText) (uregex *regexp, const UniChar *text, int32_t textLength, int32_t *status) RKL_NONNULL_ARGS(1,2,4); -int32_t RKL_ICU_FUNCTION_APPEND(uregex_start) (uregex *regexp, int32_t groupNum, int32_t *status) RKL_NONNULL_ARGS(1,3); - -//////////// -#pragma mark - -#pragma mark RegexKitLite internal, private function prototypes - -static RKLCacheSlot *rkl_getCachedRegex (NSString *regexString, RKLRegexOptions options, NSError **error, id *exception) RKL_NONNULL_ARGS_WARN_UNUSED(1,4); -static NSUInteger rkl_setCacheSlotToString (RKLCacheSlot *cacheSlot, const NSRange *range, int32_t *status, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,3,4); -static RKLCacheSlot *rkl_getCachedRegexSetToString (NSString *regexString, RKLRegexOptions options, NSString *matchString, NSUInteger *matchLengthPtr, NSRange *matchRange, NSError **error, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4,5,7,8); -static id rkl_performRegexOp (id self, SEL _cmd, RKLRegexOp regexOp, NSString *regexString, RKLRegexOptions options, NSInteger capture, id matchString, NSRange *matchRange, NSString *replacementString, NSError **error, void *result) RKL_NONNULL_ARGS(1,2); -static void rkl_handleDelayedAssert (id self, SEL _cmd, id exception) RKL_NONNULL_ARGS(1,2,3); - -static NSUInteger rkl_search (RKLCacheSlot *cacheSlot, NSRange *searchRange, NSUInteger updateSearchRange, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,5); - -static BOOL rkl_findRanges (RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4,5); -static NSUInteger rkl_growFindRanges (RKLCacheSlot *cacheSlot, NSUInteger lastLocation, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4); -static NSArray *rkl_makeArray (RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) RKL_NONNULL_ARGS_WARN_UNUSED(1,3,4); - -static NSString *rkl_replaceString (RKLCacheSlot *cacheSlot, id searchString, NSUInteger searchU16Length, NSString *replacementString, NSUInteger replacementU16Length, NSUInteger *replacedCount, NSUInteger replaceMutable, id *exception, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,8,9); -static int32_t rkl_replaceAll (RKLCacheSlot *cacheSlot, const UniChar *replacementUniChar, int32_t replacementU16Length, UniChar *replacedUniChar, int32_t replacedU16Capacity, NSUInteger *replacedCount, int32_t *needU16Capacity, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4,6,7,8,9); - -static NSUInteger rkl_isRegexValid (id self, SEL _cmd, NSString *regex, RKLRegexOptions options, NSInteger *captureCountPtr, NSError **error) RKL_NONNULL_ARGS(1,2); - -static void rkl_clearStringCache (void); -static void rkl_clearBuffer (RKLBuffer *buffer, NSUInteger freeDynamicBuffer) RKL_NONNULL_ARGS(1); -static void rkl_clearCacheSlotRegex (RKLCacheSlot *cacheSlot) RKL_NONNULL_ARGS(1); -static void rkl_clearCacheSlotSetTo (RKLCacheSlot *cacheSlot) RKL_NONNULL_ARGS(1); - -static NSDictionary *rkl_userInfoDictionary (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status, ...) RKL_ATTRIBUTES(sentinel, nonnull(1), warn_unused_result); -static NSError *rkl_NSErrorForRegex (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) RKL_NONNULL_ARGS_WARN_UNUSED(1); -static NSException *rkl_NSExceptionForRegex (NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) RKL_NONNULL_ARGS_WARN_UNUSED(1); -static NSDictionary *rkl_makeAssertDictionary (const char *function, const char *file, int line, NSString *format, ...) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4); -static NSString *rkl_stringFromClassAndMethod (id object, SEL selector, NSString *format, ...) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,3); - -RKL_STATIC_INLINE int32_t rkl_getRangeForCapture(RKLCacheSlot *cs, int32_t *s, int32_t c, NSRange *r) RKL_NONNULL_ARGS_WARN_UNUSED(1,2,4); -RKL_STATIC_INLINE int32_t rkl_getRangeForCapture(RKLCacheSlot *cs, int32_t *s, int32_t c, NSRange *r) { uregex *re = cs->icu_regex; int32_t start = RKL_ICU_FUNCTION_APPEND(uregex_start)(re, c, s); if(RKL_EXPECTED((*s > U_ZERO_ERROR), 0L) || (start == -1)) { *r = NSNotFoundRange; } else { r->location = (NSUInteger)start; r->length = (NSUInteger)RKL_ICU_FUNCTION_APPEND(uregex_end)(re, c, s) - r->location; r->location += cs->setToRange.location; } return(*s); } - -RKL_STATIC_INLINE RKLFindAll rkl_makeFindAll(NSRange *r, NSRange fir, NSInteger c, size_t s, size_t su, void **rsb, RKL_STRONG_REF void **ssb, RKL_STRONG_REF void **asb, NSInteger f, NSInteger cap, NSInteger fut) RKL_ATTRIBUTES(warn_unused_result); -RKL_STATIC_INLINE RKLFindAll rkl_makeFindAll(NSRange *r, NSRange fir, NSInteger c, size_t s, size_t su, void **rsb, RKL_STRONG_REF void **ssb, RKL_STRONG_REF void **asb, NSInteger f, NSInteger cap, NSInteger fut) { return(((RKLFindAll){ .ranges=r, .findInRange=fir, .capacity=c, .found=f, .findUpTo=fut, .capture=cap, .size=s, .stackUsed=su, .rangesScratchBuffer=rsb, .stringsScratchBuffer=ssb, .arraysScratchBuffer=asb})); } - -//////////// -#pragma mark - -#pragma mark RKL_FAST_MUTABLE_CHECK implementation - -#ifdef RKL_FAST_MUTABLE_CHECK -// We use a trampoline function pointer to check at run time if the function __CFStringIsMutable is available. -// If it is, the trampoline function pointer is replaced with the address of that function. -// Otherwise, we assume the worst case that every string is mutable. -// This hopefully helps to protect us since we're using an undocumented, non-public API call. -// We will keep on working if it ever does go away, just with a bit less performance due to the overhead of mutable checks. - -static BOOL rkl_CFStringIsMutable_first (CFStringRef str); -static BOOL rkl_CFStringIsMutable_yes (CFStringRef str RKL_UNUSED_ARG) { return(YES); } -static BOOL(*rkl_CFStringIsMutable) (CFStringRef str) = rkl_CFStringIsMutable_first; -static BOOL rkl_CFStringIsMutable_first (CFStringRef str) { if((rkl_CFStringIsMutable = (BOOL(*)(CFStringRef))dlsym(RTLD_DEFAULT, "__CFStringIsMutable")) == NULL) { rkl_CFStringIsMutable = rkl_CFStringIsMutable_yes; } return(rkl_CFStringIsMutable(str)); } -#else // RKL_FAST_MUTABLE_CHECK is not defined. Assume that all strings are potentially mutable. -#define rkl_CFStringIsMutable(s) (YES) -#endif // RKL_FAST_MUTABLE_CHECK - - -//////////// -#pragma mark - -#pragma mark iPhone / iPod touch low memory notification handler - -#if defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) && (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS == 1) - -// The next few lines are specifically for the iPhone to catch low memory conditions. -// The basic idea is that rkl_RegisterForLowMemoryNotifications() is set to be run once by the linker at load time via __attribute((constructor)). -// rkl_RegisterForLowMemoryNotifications() tries to find the iPhone low memory notification symbol. If it can find it, -// it registers with the default NSNotificationCenter to call the RKLLowMemoryWarningObserver class method +lowMemoryWarning:. -// rkl_RegisterForLowMemoryNotifications() uses an atomic compare and swap to guarantee that it initalizes exactly once. -// +lowMemoryWarning tries to acquire the cache lock. If it gets the lock, it clears the cache. If it can't, it calls performSelector: -// with a delay of half a second to try again. This will hopefully prevent any deadlocks, such as a RegexKitLite request for -// memory triggering a notifcation while the lock is held. - -static void rkl_RegisterForLowMemoryNotifications(void) RKL_ATTRIBUTES(used); - -@interface RKLLowMemoryWarningObserver : NSObject +(void)lowMemoryWarning:(id)notification; @end -@implementation RKLLowMemoryWarningObserver -+(void)lowMemoryWarning:(id)notification { - if(OSSpinLockTry(&cacheSpinLock)) { rkl_clearStringCache(); OSSpinLockUnlock(&cacheSpinLock); } - else { [[RKLLowMemoryWarningObserver class] performSelector:@selector(lowMemoryWarning:) withObject:notification afterDelay:(NSTimeInterval)0.1]; } -} -@end - -static volatile int rkl_HaveRegisteredForLowMemoryNotifications = 0; - -__attribute__((constructor)) static void rkl_RegisterForLowMemoryNotifications(void) { - _Bool didSwap = false; - void **memoryWarningNotification = NULL; - - while((rkl_HaveRegisteredForLowMemoryNotifications == 0) && ((didSwap = OSAtomicCompareAndSwapIntBarrier(0, 1, &rkl_HaveRegisteredForLowMemoryNotifications)) == false)) { /* Allows for spurious CAS failures. */ } - if(didSwap == true) { - if((memoryWarningNotification = (void **)dlsym(RTLD_DEFAULT, "UIApplicationDidReceiveMemoryWarningNotification")) != NULL) { - [[NSNotificationCenter defaultCenter] addObserver:[RKLLowMemoryWarningObserver class] selector:@selector(lowMemoryWarning:) name:(NSString *)*memoryWarningNotification object:NULL]; - } - } -} - -#endif // defined(RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS) && (RKL_REGISTER_FOR_IPHONE_LOWMEM_NOTIFICATIONS == 1) - -#ifdef _RKL_DTRACE_ENABLED - -// compiledRegexCache(unsigned long eventID, const char *regexUTF8, int options, int captures, int hitMiss, int icuStatusCode, const char *icuErrorMessage, double *hitRate); -// utf16ConversionCache(unsigned long eventID, unsigned int lookupResultFlags, double *hitRate, const void *string, unsigned long NSRange.location, unsigned long NSRange.length, long length); - -/* -provider RegexKitLite { - probe compiledRegexCache(unsigned long, const char *, unsigned int, int, int, int, const char *, double *); - probe utf16ConversionCache(unsigned long, unsigned int, double *, const void *, unsigned long, unsigned long, long); -}; - -#pragma D attributes Unstable/Unstable/Common provider RegexKitLite provider -#pragma D attributes Private/Private/Common provider RegexKitLite module -#pragma D attributes Private/Private/Common provider RegexKitLite function -#pragma D attributes Unstable/Unstable/Common provider RegexKitLite name -#pragma D attributes Unstable/Unstable/Common provider RegexKitLite args -*/ - -#define REGEXKITLITE_STABILITY "___dtrace_stability$RegexKitLite$v1$4_4_5_1_1_5_1_1_5_4_4_5_4_4_5" -#define REGEXKITLITE_TYPEDEFS "___dtrace_typedefs$RegexKitLite$v1" -#define REGEXKITLITE_COMPILEDREGEXCACHE(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { __asm__ volatile(".reference " REGEXKITLITE_TYPEDEFS); __dtrace_probe$RegexKitLite$compiledRegexCache$v1$756e7369676e6564206c6f6e67$63686172202a$756e7369676e656420696e74$696e74$696e74$696e74$63686172202a$646f75626c65202a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); __asm__ volatile(".reference " REGEXKITLITE_STABILITY); } -#define REGEXKITLITE_COMPILEDREGEXCACHE_ENABLED() __dtrace_isenabled$RegexKitLite$compiledRegexCache$v1() -#define REGEXKITLITE_CONVERTEDSTRINGU16CACHE(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { __asm__ volatile(".reference " REGEXKITLITE_TYPEDEFS); __dtrace_probe$RegexKitLite$utf16ConversionCache$v1$756e7369676e6564206c6f6e67$756e7369676e656420696e74$646f75626c65202a$766f6964202a$756e7369676e6564206c6f6e67$756e7369676e6564206c6f6e67$6c6f6e67(arg0, arg1, arg2, arg3, arg4, arg5, arg6); __asm__ volatile(".reference " REGEXKITLITE_STABILITY); } -#define REGEXKITLITE_CONVERTEDSTRINGU16CACHE_ENABLED() __dtrace_isenabled$RegexKitLite$utf16ConversionCache$v1() - -extern void __dtrace_probe$RegexKitLite$compiledRegexCache$v1$756e7369676e6564206c6f6e67$63686172202a$756e7369676e656420696e74$696e74$696e74$696e74$63686172202a$646f75626c65202a(unsigned long, const char *, unsigned int, int, int, int, const char *, double *); -extern int __dtrace_isenabled$RegexKitLite$compiledRegexCache$v1(void); -extern void __dtrace_probe$RegexKitLite$utf16ConversionCache$v1$756e7369676e6564206c6f6e67$756e7369676e656420696e74$646f75626c65202a$766f6964202a$756e7369676e6564206c6f6e67$756e7369676e6564206c6f6e67$6c6f6e67(unsigned long, unsigned int, double *, const void *, unsigned long, unsigned long, long); -extern int __dtrace_isenabled$RegexKitLite$utf16ConversionCache$v1(void); - -//////////////////////////// - -enum { - RKLCacheHitLookupFlag = 1 << 0, - RKLConversionRequiredLookupFlag = 1 << 1, - RKLSetTextLookupFlag = 1 << 2, - RKLDynamicBufferLookupFlag = 1 << 3, - RKLErrorLookupFlag = 1 << 4, -}; - -#define rkl_dtrace_addLookupFlag(a,b) do { a |= (unsigned int)(b); } while(0) - -static char rkl_dtrace_regexUTF8[(RKL_CACHE_SIZE) + 1][(RKL_DTRACE_REGEXUTF8_SIZE)]; -static NSUInteger rkl_dtrace_eventID, rkl_dtrace_compiledCacheLookups, rkl_dtrace_compiledCacheHits, rkl_dtrace_conversionBufferLookups, rkl_dtrace_conversionBufferHits; - -#define rkl_dtrace_incrementEventID() do { rkl_dtrace_eventID++; } while(0) -#define rkl_dtrace_compiledRegexCache(a0, a1, a2, a3, a4, a5) do { int _a3 = (a3); rkl_dtrace_compiledCacheLookups++; if(_a3 == 1) { rkl_dtrace_compiledCacheHits++; } if(RKL_EXPECTED(REGEXKITLITE_COMPILEDREGEXCACHE_ENABLED(), 0L)) { double hitRate = 0.0; if(rkl_dtrace_compiledCacheLookups > 0UL) { hitRate = ((double)rkl_dtrace_compiledCacheHits / (double)rkl_dtrace_compiledCacheLookups) * 100.0; } REGEXKITLITE_COMPILEDREGEXCACHE(rkl_dtrace_eventID, a0, a1, a2, _a3, a4, a5, &hitRate); } } while(0) -#define rkl_dtrace_utf16ConversionCache(a0, a1, a2, a3, a4) do { unsigned int _a0 = (a0); if((_a0 & RKLConversionRequiredLookupFlag) != 0U) { rkl_dtrace_conversionBufferLookups++; if((_a0 & RKLCacheHitLookupFlag) != 0U) { rkl_dtrace_conversionBufferHits++; } } if(RKL_EXPECTED(REGEXKITLITE_CONVERTEDSTRINGU16CACHE_ENABLED(), 0L)) { double hitRate = 0.0; if(rkl_dtrace_conversionBufferLookups > 0UL) { hitRate = ((double)rkl_dtrace_conversionBufferHits / (double)rkl_dtrace_conversionBufferLookups) * 100.0; } REGEXKITLITE_CONVERTEDSTRINGU16CACHE(rkl_dtrace_eventID, _a0, &hitRate, a1, a2, a3, a4); } } while(0) - - -// \342\200\246 == UTF8 for HORIZONTAL ELLIPSIS, aka triple dots '...' -#define RKL_UTF8_ELLIPSE "\342\200\246" - -// rkl_dtrace_getRegexUTF8 will copy the str argument to utf8Buffer using UTF8 as the string encoding. -// If the utf8 encoding would take up more bytes than the utf8Buffers length, then the unicode character 'HORIZONTAL ELLIPSIS' ('...') is appened to indicate truncation occured. -static void rkl_dtrace_getRegexUTF8(CFStringRef str, char *utf8Buffer) RKL_NONNULL_ARGS(2); -static void rkl_dtrace_getRegexUTF8(CFStringRef str, char *utf8Buffer) { - if((str == NULL) || (utf8Buffer == NULL)) { return; } - CFIndex maxLength = ((CFIndex)(RKL_DTRACE_REGEXUTF8_SIZE) - 2L), maxBytes = (maxLength - (CFIndex)sizeof(RKL_UTF8_ELLIPSE) - 1L), stringU16Length = CFStringGetLength(str), usedBytes = 0L; - CFStringGetBytes(str, CFMakeRange(0L, ((stringU16Length < maxLength) ? stringU16Length : maxLength)), kCFStringEncodingUTF8, (UInt8)'?', (Boolean)0, (UInt8 *)utf8Buffer, maxBytes, &usedBytes); - if(usedBytes == maxBytes) { strncpy(utf8Buffer + usedBytes, RKL_UTF8_ELLIPSE, ((size_t)(RKL_DTRACE_REGEXUTF8_SIZE) - (size_t)usedBytes) - 2UL); } else { utf8Buffer[usedBytes] = (char)0; } -} - -#else // _RKL_DTRACE_ENABLED - -#define rkl_dtrace_incrementEventID() -#define rkl_dtrace_compiledRegexCache(a0, a1, a2, a3, a4, a5) -#define rkl_dtrace_utf16ConversionCache(a0, a1, a2, a3, a4) -#define rkl_dtrace_getRegexUTF8(str, buf) -#define rkl_dtrace_addLookupFlag(a,b) - -#endif // _RKL_DTRACE_ENABLED - -//////////// -#pragma mark - -#pragma mark RegexKitLite low-level internal functions - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called with cacheSpinLock already locked! -// ---------- - -static RKLCacheSlot *rkl_getCachedRegex(NSString *regexString, RKLRegexOptions options, NSError **error, id *exception) { - RKLCacheSlot *cacheSlot = NULL; - CFHashCode regexHash = 0UL; - int32_t status = 0; - - RKLCDelayedAssert((cacheSpinLock != (OSSpinLock)0) && (regexString != NULL), exception, exitNow); - - // Fast path the common case where this regex is exactly the same one used last time. - // The pointer equality test is valid under these circumstances since the cacheSlot->regexString is an immutable copy. - // If the regexString argument is mutable, this test will fail, and we'll use the the slow path cache check below. - if(RKL_EXPECTED(lastCacheSlot != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->options == options, 1L) && RKL_EXPECTED(lastCacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString == (CFStringRef)regexString, 1L)) { - rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(lastCacheSlot - &rkl_cacheSlots[0])][0], lastCacheSlot->options, (int)lastCacheSlot->captureCount, 1, 0, NULL); - return(lastCacheSlot); - } - - lastCacheSlot = NULL; - regexHash = CFHash((CFTypeRef)regexString); - cacheSlot = &rkl_cacheSlots[(regexHash % (CFHashCode)(RKL_CACHE_SIZE))]; // Retrieve the cache slot for this regex. - - // Return the cached entry if it's a match, otherwise clear the slot and create a new ICU regex in its place. - // If regexString is mutable, the pointer equality test will fail, and CFEqual() is used to determine true - // equality with the immutable cacheSlot copy. CFEqual() performs a slow character by character check. - if(RKL_EXPECTED(cacheSlot->options == options, 1L) && RKL_EXPECTED(cacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(cacheSlot->regexString != NULL, 1L) && (RKL_EXPECTED(cacheSlot->regexString == (CFStringRef)regexString, 1L) || RKL_EXPECTED(CFEqual((CFTypeRef)regexString, (CFTypeRef)cacheSlot->regexString) == YES, 1L))) { - lastCacheSlot = cacheSlot; - rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(lastCacheSlot - &rkl_cacheSlots[0])][0], lastCacheSlot->options, (int)lastCacheSlot->captureCount, 1, 0, NULL); - return(cacheSlot); - } - - rkl_clearCacheSlotRegex(cacheSlot); - - if(RKL_EXPECTED((cacheSlot->regexString = CFStringCreateCopy(NULL, (CFStringRef)regexString)) == NULL, 0L)) { goto exitNow; } ; // Get a cheap immutable copy. - rkl_dtrace_getRegexUTF8(cacheSlot->regexString, &rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0]); - cacheSlot->options = options; - - CFIndex regexStringU16Length = CFStringGetLength(cacheSlot->regexString); // In UTF16 code units. - UParseError parseError = (UParseError){-1, -1, {0}, {0}}; - const UniChar *regexUniChar = NULL; - - if(RKL_EXPECTED(regexStringU16Length >= (CFIndex)INT_MAX, 0L)) { *exception = [NSException exceptionWithName:NSRangeException reason:@"Regex string length exceeds INT_MAX" userInfo:NULL]; goto exitNow; } - - // Try to quickly obtain regexString in UTF16 format. - if((regexUniChar = CFStringGetCharactersPtr(cacheSlot->regexString)) == NULL) { // We didn't get the UTF16 pointer quickly and need to perform a full conversion in a temp buffer. - UniChar *uniCharBuffer = NULL; - if(((size_t)regexStringU16Length * sizeof(UniChar)) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)alloca( (size_t)regexStringU16Length * sizeof(UniChar) )) == NULL, 0L)) { goto exitNow; } } // Try to use the stack. - else { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], (size_t)regexStringU16Length * sizeof(UniChar), 0UL)) == NULL, 0L)) { goto exitNow; } } // Otherwise use the heap. - CFStringGetCharacters(cacheSlot->regexString, CFMakeRange(0L, regexStringU16Length), uniCharBuffer); // Convert regexString to UTF16. - regexUniChar = uniCharBuffer; - } - - // Create the ICU regex. - if(RKL_EXPECTED((cacheSlot->icu_regex = RKL_ICU_FUNCTION_APPEND(uregex_open)(regexUniChar, (int32_t)regexStringU16Length, options, &parseError, &status)) == NULL, 0L)) { goto exitNow; } - if(RKL_EXPECTED(status <= U_ZERO_ERROR, 1L)) { cacheSlot->captureCount = (NSInteger)RKL_ICU_FUNCTION_APPEND(uregex_groupCount)(cacheSlot->icu_regex, &status); } - if(RKL_EXPECTED(status <= U_ZERO_ERROR, 1L)) { lastCacheSlot = cacheSlot; } - -exitNow: - if(RKL_EXPECTED(scratchBuffer[0] != NULL, 0L)) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } - if(RKL_EXPECTED(status > U_ZERO_ERROR, 0L)) { rkl_clearCacheSlotRegex(cacheSlot); cacheSlot = NULL; if(error != NULL) { *error = rkl_NSErrorForRegex(regexString, options, &parseError, status); } } - -#ifdef _RKL_DTRACE_ENABLED - if(RKL_EXPECTED(cacheSlot != NULL, 1L)) { rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0], cacheSlot->options, (int)cacheSlot->captureCount, 0, status, NULL); } - else { char regexUTF8[(RKL_DTRACE_REGEXUTF8_SIZE)]; const char *err = NULL; if(status != U_ZERO_ERROR) { err = RKL_ICU_FUNCTION_APPEND(u_errorName)(status); } rkl_dtrace_getRegexUTF8((CFStringRef)regexString, regexUTF8); rkl_dtrace_compiledRegexCache(regexUTF8, options, -1, -1, status, err); } -#endif // _RKL_DTRACE_ENABLED - - return(cacheSlot); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called with cacheSpinLock already locked! -// ---------- - -static NSUInteger rkl_setCacheSlotToString(RKLCacheSlot *cacheSlot, const NSRange *range, int32_t *status, id *exception RKL_UNUSED_ASSERTION_ARG) { - RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->setToString != NULL) && ((range != NULL) && (NSEqualRanges(*range, NSNotFoundRange) == NO)) && (status != NULL), exception, exitNow); - const UniChar *stringUniChar = NULL; -#ifdef _RKL_DTRACE_ENABLED - unsigned int lookupResultFlags = 0U; -#endif - - if(cacheSlot->setToNeedsConversion == 0U) { - if(RKL_EXPECTED((stringUniChar = CFStringGetCharactersPtr(cacheSlot->setToString)) == NULL, 0L)) { cacheSlot->setToNeedsConversion = 1U; } - else { if(RKL_EXPECTED(cacheSlot->setToUniChar != stringUniChar, 0L)) { cacheSlot->setToRange = NSNotFoundRange; cacheSlot->setToUniChar = stringUniChar; } goto setRegexText; } - } - rkl_dtrace_addLookupFlag(lookupResultFlags, RKLConversionRequiredLookupFlag); - - NSUInteger useFixedBuffer = (cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? 1UL : 0UL; - RKLBuffer *buffer = useFixedBuffer ? &fixedBuffer : &dynamicBuffer; - rkl_dtrace_addLookupFlag(lookupResultFlags, (useFixedBuffer ? 0U : RKLDynamicBufferLookupFlag)); - - if((buffer->uniChar != NULL) && (cacheSlot->setToString == buffer->string) && (cacheSlot->setToLength == buffer->length) && (cacheSlot->setToHash == buffer->hash)) { rkl_dtrace_addLookupFlag(lookupResultFlags, RKLCacheHitLookupFlag); cacheSlot->setToUniChar = buffer->uniChar; goto setRegexText; } - - if((cacheSlot->setToNeedsConversion == 1U) && RKL_EXPECTED((stringUniChar = CFStringGetCharactersPtr(cacheSlot->setToString)) != NULL, 0L)) { cacheSlot->setToNeedsConversion = 0U; cacheSlot->setToRange = NSNotFoundRange; cacheSlot->setToUniChar = stringUniChar; goto setRegexText; } - - rkl_clearBuffer(buffer, 0UL); - - if(useFixedBuffer == 0U) { - RKLCDelayedAssert(buffer == &dynamicBuffer, exception, exitNow); - RKL_STRONG_REF void *p = (RKL_STRONG_REF void *)dynamicBuffer.uniChar; - if(RKL_EXPECTED((dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)rkl_realloc(&p, ((size_t)cacheSlot->setToLength * sizeof(UniChar)), 0UL)) == NULL, 0L)) { goto exitNow; } // Resize the buffer. - } - - RKLCDelayedAssert(buffer->uniChar != NULL, exception, exitNow); - CFStringGetCharacters(cacheSlot->setToString, CFMakeRange(0L, cacheSlot->setToLength), (UniChar *)buffer->uniChar); // Convert to a UTF16 string. - - RKLCDelayedAssert(buffer->string == NULL, exception, exitNow); - if(RKL_EXPECTED((buffer->string = (CFStringRef)CFRetain((CFTypeRef)cacheSlot->setToString)) == NULL, 0L)) { goto exitNow; } - buffer->hash = cacheSlot->setToHash; - buffer->length = cacheSlot->setToLength; - - cacheSlot->setToUniChar = buffer->uniChar; - cacheSlot->setToRange = NSNotFoundRange; - -setRegexText: - if(NSEqualRanges(cacheSlot->setToRange, *range) == NO) { - RKLCDelayedAssert((cacheSlot->icu_regex != NULL) && (cacheSlot->setToUniChar != NULL) && (NSMaxRange(*range) <= (NSUInteger)cacheSlot->setToLength) && (cacheSlot->setToRange.length <= INT_MAX), exception, exitNow); - cacheSlot->lastFindRange = cacheSlot->lastMatchRange = NSNotFoundRange; - cacheSlot->setToRange = *range; - RKL_ICU_FUNCTION_APPEND(uregex_setText)(cacheSlot->icu_regex, cacheSlot->setToUniChar + cacheSlot->setToRange.location, (int32_t)cacheSlot->setToRange.length, status); - rkl_dtrace_addLookupFlag(lookupResultFlags, RKLSetTextLookupFlag); - if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto exitNow; } - } - - rkl_dtrace_utf16ConversionCache(lookupResultFlags, cacheSlot->setToString, cacheSlot->setToRange.location, cacheSlot->setToRange.length, cacheSlot->setToLength); - return(1UL); - -exitNow: - return(0UL); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called with cacheSpinLock already locked! -// ---------- - -static RKLCacheSlot *rkl_getCachedRegexSetToString(NSString *regexString, RKLRegexOptions options, NSString *matchString, NSUInteger *matchLengthPtr, NSRange *matchRange, NSError **error, id *exception, int32_t *status) { - RKLCacheSlot *cacheSlot = NULL; - RKLCDelayedAssert((regexString != NULL) && (exception != NULL) && (status != NULL) && (matchLengthPtr != NULL), exception, exitNow); - - // Fast path the common case where this regex is exactly the same one used last time. - if(RKL_EXPECTED(lastCacheSlot != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->icu_regex != NULL, 1L) && RKL_EXPECTED(lastCacheSlot->regexString == (CFStringRef)regexString, 1L) && RKL_EXPECTED(lastCacheSlot->options == options, 1L)) { cacheSlot = lastCacheSlot; rkl_dtrace_compiledRegexCache(&rkl_dtrace_regexUTF8[(cacheSlot - &rkl_cacheSlots[0])][0], cacheSlot->options, (int)cacheSlot->captureCount, 1, 0, NULL); } - else { lastCacheSlot = NULL; if(RKL_EXPECTED((cacheSlot = rkl_getCachedRegex(regexString, options, error, exception)) == NULL, 0L)) { goto exitNow; } } - RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->regexString != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot == lastCacheSlot), exception, exitNow); - - // Optimize the case where the string to search (matchString) is immutable and the setToString immutable copy is the same string with its reference count incremented. - NSUInteger isSetTo = ((cacheSlot->setToString != NULL) && (cacheSlot->setToString == (CFStringRef)matchString)) ? 1UL : 0UL; - CFIndex matchLength = ((isSetTo == 1UL) && (cacheSlot->setToIsImmutable == 1U)) ? cacheSlot->setToLength : CFStringGetLength((CFStringRef)matchString); - - *matchLengthPtr = (NSUInteger)matchLength; - if(matchRange->length == NSUIntegerMax) { matchRange->length = (NSUInteger)matchLength; } // For convenience, allow NSUIntegerMax == string length. - - if(RKL_EXPECTED((NSUInteger)matchLength < NSMaxRange(*matchRange), 0L)) { goto exitNow; } // The match range is out of bounds for the string. performRegexOp will catch and report the problem. - - if((isSetTo == 1UL) && (cacheSlot->setToIsImmutable == 0U) && (cacheSlot->setToString != NULL) && ((cacheSlot->setToLength != CFStringGetLength(cacheSlot->setToString)) || (cacheSlot->setToHash != CFHash((CFTypeRef)cacheSlot->setToString)))) { isSetTo = 0UL; } - else { // If the first pointer equality check failed, check the hash and length. - if(((isSetTo == 0UL) || (cacheSlot->setToIsImmutable == 0U)) && (cacheSlot->setToString != NULL)) { isSetTo = ((cacheSlot->setToString == (CFStringRef)matchString) && (cacheSlot->setToLength == matchLength) && (cacheSlot->setToHash == CFHash((CFTypeRef)matchString))) ? 1UL : 0UL; } - - if(isSetTo == 1UL) { if(RKL_EXPECTED(rkl_setCacheSlotToString(cacheSlot, matchRange, status, exception) == 0UL, 0L)) { cacheSlot = NULL; if(*exception == NULL) { *exception = (id)RKLCAssertDictionary(@"Failed to set up UTF16 buffer."); } } goto exitNow; } - } - - // Sometimes the range that the regex is set to isn't right, in which case we don't want to clear the cache slot. Otherwise, flush it out. - if((cacheSlot->setToString != NULL) && (isSetTo == 0UL)) { rkl_clearCacheSlotSetTo(cacheSlot); } - - if(cacheSlot->setToString == NULL) { - cacheSlot->setToString = (CFStringRef)CFRetain((CFTypeRef)matchString); - RKLCDelayedAssert(cacheSlot->setToString != NULL, exception, exitNow); - cacheSlot->setToUniChar = CFStringGetCharactersPtr(cacheSlot->setToString); - cacheSlot->setToNeedsConversion = (cacheSlot->setToUniChar == NULL) ? 1U : 0U; - cacheSlot->setToIsImmutable = (rkl_CFStringIsMutable(cacheSlot->setToString) == YES) ? 0U : 1U; // If RKL_FAST_MUTABLE_CHECK is not defined then setToIsImmutable will always be set to '0', or in other words mutable.. - cacheSlot->setToHash = CFHash((CFTypeRef)cacheSlot->setToString); - cacheSlot->setToRange = NSNotFoundRange; - cacheSlot->setToLength = matchLength; - } - - if(RKL_EXPECTED(rkl_setCacheSlotToString(cacheSlot, matchRange, status, exception) == 0UL, 0L)) { cacheSlot = NULL; if(*exception == NULL) { *exception = (id)RKLCAssertDictionary(@"Failed to set up UTF16 buffer."); } goto exitNow; } - -exitNow: - return(cacheSlot); -} - -#ifdef RKL_HAVE_CLEANUP - -// rkl_cleanup_cacheSpinLockStatus takes advantage of GCC's 'cleanup' variable attribute. When an 'auto' variable with the 'cleanup' attribute goes out of scope, -// GCC arranges to have the designated function called. In this case, we make sure that if rkl_cacheSpinLock was locked that it was also unlocked. -// If rkl_cacheSpinLock was locked, but the cacheSpinLockStatus unlocked flag was not set, we force cacheSpinLock unlocked with a call to OSSpinLockUnlock. -// This is not a panacea for preventing mutex usage errors. Old style ObjC exceptions will bypass the cleanup call, but newer C++ style ObjC exceptions should cause the cleanup function to be called during the stack unwind. - -// We do not depend on this cleanup function being called. It is used only as an extra safety net. It is probably a bug in RegexKitLite if it is ever invoked and forced to take some kind of protective action. - -volatile NSUInteger rkl_debugCacheSpinLockCount = 0UL; - -void rkl_debugCacheSpinLock (void) RKL_ATTRIBUTES(used, noinline, visibility("default")); -static void rkl_cleanup_cacheSpinLockStatus (volatile NSUInteger *cacheSpinLockStatusPtr) RKL_ATTRIBUTES(used); - -void rkl_debugCacheSpinLock(void) { - rkl_debugCacheSpinLockCount++; // This is here primarily to prevent the optimizer from optimizing away the function. -} - -static void rkl_cleanup_cacheSpinLockStatus(volatile NSUInteger *cacheSpinLockStatusPtr) { - static NSUInteger didPrintForcedUnlockWarning = 0UL, didPrintNotLockedWarning = 0UL; - NSUInteger cacheSpinLockStatus = *cacheSpinLockStatusPtr; - - if(RKL_EXPECTED((cacheSpinLockStatus & RKLUnlockedCacheSpinLock) == 0UL, 0L) && RKL_EXPECTED((cacheSpinLockStatus & RKLLockedCacheSpinLock) != 0UL, 1L)) { - if(cacheSpinLock != (OSSpinLock)0) { - if(didPrintForcedUnlockWarning == 0UL) { didPrintForcedUnlockWarning = 1UL; NSLog(@"[RegexKitLite] Unusual condition detected: Recorded that cacheSpinLock was locked, but for some reason it was not unlocked. Forcibly unlocking cacheSpinLock. Set a breakpoint at rkl_debugCacheSpinLock to debug. This warning is only printed once."); } - rkl_debugCacheSpinLock(); // Since this is an unusual condition, offer an attempt to catch it before we unlock. - OSSpinLockUnlock(&cacheSpinLock); - } else { - if(didPrintNotLockedWarning == 0UL) { didPrintNotLockedWarning = 1UL; NSLog(@"[RegexKitLite] Unusual condition detected: Recorded that cacheSpinLock was locked, but for some reason it was not unlocked, yet cacheSpinLock is currently not locked? Set a breakpoint at rkl_debugCacheSpinLock to debug. This warning is only printed once."); } - rkl_debugCacheSpinLock(); - } - } -} - -#endif // RKL_HAVE_CLEANUP - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// ---------- - -static id rkl_performRegexOp(id self, SEL _cmd, RKLRegexOp regexOp, NSString *regexString, RKLRegexOptions options, NSInteger capture, id matchString, NSRange *matchRange, NSString *replacementString, NSError **error, void *result) { - volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; - - NSUInteger replaceMutable = 0UL; - RKLRegexOp maskedRegexOp = (regexOp & RKLMaskOp); - - if((error != NULL) && (*error != NULL)) { *error = NULL; } - - if(RKL_EXPECTED(regexString == NULL, 0L)) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The regular expression argument is NULL."); } - if(RKL_EXPECTED(matchString == NULL, 0L)) { RKL_RAISE_EXCEPTION(NSInternalInconsistencyException, @"The match string argument is NULL."); } - if((maskedRegexOp == RKLReplaceOp) && (replacementString == NULL)) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The replacement string argument is NULL."); } - - id resultObject = NULL, exception = NULL; - int32_t status = U_ZERO_ERROR; - RKLCacheSlot *cacheSlot = NULL; - NSUInteger stringU16Length = 0UL; - NSRange stackRanges[2048]; - RKLFindAll findAll; - - - // IMPORTANT! Once we have obtained the lock, code MUST exit via 'goto exitNow;' to unlock the lock! NO EXCEPTIONS! - // ---------- - OSSpinLockLock(&cacheSpinLock); // Grab the lock and get cache entry. - cacheSpinLockStatus |= RKLLockedCacheSpinLock; - rkl_dtrace_incrementEventID(); - - if(RKL_EXPECTED((cacheSlot = rkl_getCachedRegexSetToString(regexString, options, matchString, &stringU16Length, matchRange, error, &exception, &status)) == NULL, 0L)) { stringU16Length = (NSUInteger)CFStringGetLength((CFStringRef)matchString); } - if(RKL_EXPECTED(matchRange->length == NSUIntegerMax, 1L)) { matchRange->length = stringU16Length; } // For convenience. - if(RKL_EXPECTED(stringU16Length < NSMaxRange(*matchRange), 0L) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSRangeException, @"Range or index out of bounds."); goto exitNow; } - if(RKL_EXPECTED(stringU16Length >= (NSUInteger)INT_MAX, 0L) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSRangeException, @"String length exceeds INT_MAX."); goto exitNow; } - if(((maskedRegexOp == RKLRangeOp) || (maskedRegexOp == RKLArrayOfStringsOp)) && RKL_EXPECTED(cacheSlot != NULL, 1L) && (RKL_EXPECTED(capture < 0L, 0L) || RKL_EXPECTED(capture > cacheSlot->captureCount, 0L)) && RKL_EXPECTED(exception == NULL, 1L)) { exception = (id)RKL_EXCEPTION(NSInvalidArgumentException, @"The capture argument is not valid."); goto exitNow; } - if(RKL_EXPECTED(cacheSlot == NULL, 0L) || RKL_EXPECTED(status > U_ZERO_ERROR, 0L) || RKL_EXPECTED(exception != NULL, 0L)) { goto exitNow; } - - RKLCDelayedAssert((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->regexString != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot->setToString != NULL) && (cacheSlot->setToLength >= 0L) && (cacheSlot->setToUniChar != NULL) && ((CFIndex)NSMaxRange(cacheSlot->setToRange) <= cacheSlot->setToLength), &exception, exitNow); - -#ifndef NS_BLOCK_ASSERTIONS - if(cacheSlot->setToNeedsConversion == 0U) { RKLCDelayedAssert((cacheSlot->setToUniChar == CFStringGetCharactersPtr(cacheSlot->setToString)), &exception, exitNow); } - else { - RKLBuffer *buffer = (cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer; - RKLCDelayedAssert((cacheSlot->setToHash == buffer->hash) && (cacheSlot->setToLength == buffer->length) && (cacheSlot->setToUniChar == buffer->uniChar), &exception, exitNow); - } -#endif - - switch(maskedRegexOp) { - case RKLRangeOp: - if((rkl_search(cacheSlot, matchRange, 0UL, &exception, &status) == NO) || (RKL_EXPECTED(status > U_ZERO_ERROR, 0L))) { *(NSRange *)result = NSNotFoundRange; goto exitNow; } - if(RKL_EXPECTED(capture == 0L, 1L)) { *(NSRange *)result = cacheSlot->lastMatchRange; } else { if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, &status, (int32_t)capture, (NSRange *)result) > U_ZERO_ERROR, 0L)) { goto exitNow; } } - break; - - case RKLSplitOp: // Fall-thru... - case RKLArrayOfStringsOp: // Fall-thru... - case RKLCapturesArrayOp: // Fall-thru... - case RKLArrayOfCapturesOp: - findAll = rkl_makeFindAll(stackRanges, *matchRange, 2048L, (2048UL * sizeof(NSRange)), 0UL, (void **)&scratchBuffer[0], &scratchBuffer[1], &scratchBuffer[2], 0L, capture, ((maskedRegexOp == RKLCapturesArrayOp) ? 1L : NSIntegerMax)); - - if(RKL_EXPECTED(rkl_findRanges(cacheSlot, regexOp, &findAll, &exception, &status) == NO, 1L)) { - if(RKL_EXPECTED(findAll.found == 0L, 0L)) { resultObject = [NSArray array]; } else { resultObject = rkl_makeArray(cacheSlot, regexOp, &findAll, &exception); } - } - - if(RKL_EXPECTED(scratchBuffer[0] != NULL, 0L)) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } - if(RKL_EXPECTED(scratchBuffer[1] != NULL, 0L)) { scratchBuffer[1] = rkl_free(&scratchBuffer[1]); } - if(RKL_EXPECTED(scratchBuffer[2] != NULL, 0L)) { scratchBuffer[2] = rkl_free(&scratchBuffer[2]); } - - break; - - case RKLReplaceOp: resultObject = rkl_replaceString(cacheSlot, matchString, stringU16Length, replacementString, (NSUInteger)CFStringGetLength((CFStringRef)replacementString), (NSUInteger *)result, (replaceMutable = (((regexOp & RKLReplaceMutable) != 0) ? 1UL : 0UL)), &exception, &status); break; - default: exception = RKLCAssertDictionary(@"Unknown regexOp code."); break; - } - -exitNow: - OSSpinLockUnlock(&cacheSpinLock); - cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. - - if(RKL_EXPECTED(status > U_ZERO_ERROR, 0L) && RKL_EXPECTED(exception == NULL, 0L)) { exception = rkl_NSExceptionForRegex(regexString, options, NULL, status); } // If we had a problem, prepare an exception to be thrown. - if(RKL_EXPECTED(exception != NULL, 0L)) { rkl_handleDelayedAssert(self, _cmd, exception); } // If there is an exception, throw it at this point. - // If we're working on a mutable string and there were successful matches/replacements, then we still have work to do. - // This is done outside the cache lock and with the objc replaceCharactersInRange:withString: method because Core Foundation - // does not assert that the string we are attempting to update is actually a mutable string, whereas Foundation ensures - // the object receiving the message is a mutable string and throws an exception if we're attempting to modify an immutable string. - if(RKL_EXPECTED(status == U_ZERO_ERROR, 1L) && RKL_EXPECTED(resultObject != NULL, 1L) && RKL_EXPECTED(replaceMutable == 1UL, 0L) && RKL_EXPECTED(*((NSUInteger *)result) > 0UL, 1L)) { [matchString replaceCharactersInRange:*matchRange withString:resultObject]; } - // If status < U_ZERO_ERROR, consider it an error, even though status < U_ZERO_ERROR is a 'warning' in ICU nomenclature. - // status > U_ZERO_ERROR are an exception and handled above. - // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 - if(RKL_EXPECTED(status < U_ZERO_ERROR, 0L) && RKL_EXPECTED(resultObject == NULL, 0L) && (error != NULL)) { *error = [NSError errorWithDomain:RKLICURegexErrorDomain code:(NSInteger)status userInfo:rkl_userInfoDictionary(regexString, options, NULL, status, @"The ICU library returned an unexpected error code.", @"NSLocalizedDescription", NULL)]; } - return(resultObject); -} - -static void rkl_handleDelayedAssert(id self, SEL _cmd, id exception) { - if(RKL_EXPECTED(exception != NULL, 0L)) { - if([exception isKindOfClass:[NSException class]]) { [[NSException exceptionWithName:[exception name] reason:rkl_stringFromClassAndMethod(self, _cmd, [exception reason]) userInfo:[exception userInfo]] raise]; } - else { - id functionString = [exception objectForKey:@"function"], fileString = [exception objectForKey:@"file"], descriptionString = [exception objectForKey:@"description"], lineNumber = [exception objectForKey:@"line"]; - NSCParameterAssert((functionString != NULL) && (fileString != NULL) && (descriptionString != NULL) && (lineNumber != NULL)); - [[NSAssertionHandler currentHandler] handleFailureInFunction:functionString file:fileString lineNumber:(NSInteger)[lineNumber longValue] description:descriptionString]; - } - } -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called from rkl_performRegexOp() or rkl_findRanges(). -// ---------- - -static NSUInteger rkl_search(RKLCacheSlot *cacheSlot, NSRange *searchRange, NSUInteger updateSearchRange, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) { - NSUInteger foundMatch = 0UL, searchEqualsEndOfRange = (RKL_EXPECTED(NSEqualRanges(*searchRange, NSMakeRange(NSMaxRange(cacheSlot->setToRange), 0UL)) == YES, 0L) ? 1UL : 0UL); - - if((NSEqualRanges(*searchRange, cacheSlot->lastFindRange) == YES) || (searchEqualsEndOfRange == 1UL)) { foundMatch = (((cacheSlot->lastMatchRange.location == (NSUInteger)NSNotFound) || (searchEqualsEndOfRange == 1UL)) ? 0UL : 1UL);} - else { // Only perform an expensive 'find' operation iff the current find range is different than the last find range. - NSUInteger findLocation = (searchRange->location - cacheSlot->setToRange.location); - RKLCDelayedAssert(((searchRange->location >= cacheSlot->setToRange.location)) && (NSRangeInsideRange(*searchRange, cacheSlot->setToRange) == YES) && (findLocation < INT_MAX) && (findLocation <= cacheSlot->setToRange.length), exception, exitNow); - - RKL_PREFETCH_UNICHAR(cacheSlot->setToUniChar, searchRange->location); // Spool up the CPU caches. - - // Using uregex_findNext can be a slight performance win. - NSUInteger useFindNext = ((searchRange->location == (NSMaxRange(cacheSlot->lastMatchRange) + (((cacheSlot->lastMatchRange.length == 0UL) && (cacheSlot->lastMatchRange.location < NSMaxRange(cacheSlot->setToRange))) ? 1UL : 0UL))) ? 1UL : 0UL); - - cacheSlot->lastFindRange = *searchRange; - if(RKL_EXPECTED(useFindNext == 0UL, 0L)) { if(RKL_EXPECTED((RKL_ICU_FUNCTION_APPEND(uregex_find) (cacheSlot->icu_regex, (int32_t)findLocation, status) == NO), 0L) || RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto finishedFind; } } - else { if(RKL_EXPECTED((RKL_ICU_FUNCTION_APPEND(uregex_findNext)(cacheSlot->icu_regex, status) == NO), 0L) || RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto finishedFind; } } - foundMatch = 1UL; - - if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, 0, &cacheSlot->lastMatchRange) > U_ZERO_ERROR, 0L)) { goto finishedFind; } - RKLCDelayedAssert(NSRangeInsideRange(cacheSlot->lastMatchRange, *searchRange) == YES, exception, exitNow); - } - -finishedFind: - if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { foundMatch = 0UL; cacheSlot->lastFindRange = NSNotFoundRange; } - - if(foundMatch == 0UL) { cacheSlot->lastFindRange = NSNotFoundRange; cacheSlot->lastMatchRange = NSNotFoundRange; if(updateSearchRange == 1UL) { *searchRange = NSMakeRange(NSMaxRange(*searchRange), 0UL); } } - else { - RKLCDelayedAssert(NSRangeInsideRange(cacheSlot->lastMatchRange, *searchRange) == YES, exception, exitNow); - if(updateSearchRange == 1UL) { - NSUInteger nextLocation = (NSMaxRange(cacheSlot->lastMatchRange) + (((cacheSlot->lastMatchRange.length == 0UL) && (cacheSlot->lastMatchRange.location < NSMaxRange(cacheSlot->setToRange))) ? 1UL : 0UL)), locationDiff = nextLocation - searchRange->location; - RKLCDelayedAssert((((locationDiff > 0UL) || ((locationDiff == 0UL) && (cacheSlot->lastMatchRange.location == NSMaxRange(cacheSlot->setToRange)))) && (locationDiff <= searchRange->length)), exception, exitNow); - searchRange->location = nextLocation; - searchRange->length -= locationDiff; - } - } - -#ifndef NS_BLOCK_ASSERTIONS -exitNow: -#endif - return(foundMatch); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called from rkl_doFindOp(). -// ---------- - -static BOOL rkl_findRanges(RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception, int32_t *status) { - BOOL returnWithError = YES; - RKLCDelayedAssert((((cacheSlot != NULL) && (cacheSlot->icu_regex != NULL) && (cacheSlot->setToUniChar != NULL) && (cacheSlot->captureCount >= 0L) && (cacheSlot->setToRange.location != (NSUInteger)NSNotFound)) && (status != NULL) && ((findAll != NULL) && (findAll->found == 0L) && ((findAll->capacity >= 0L) && (((findAll->capacity > 0L) || (findAll->size > 0UL)) ? ((findAll->ranges != NULL) && (findAll->capacity > 0L) && (findAll->size > 0UL)) : 1)) && (findAll->rangesScratchBuffer != NULL) && ((findAll->capture >= 0L) && (findAll->capture <= cacheSlot->captureCount)))), exception, exitNow); - - if(RKL_EXPECTED(cacheSlot->setToLength == 0L, 0L) || RKL_EXPECTED(cacheSlot->setToRange.length == 0UL, 0L)) { returnWithError = NO; goto exitNow; } - - NSInteger captureCount = cacheSlot->captureCount; - RKLRegexOp maskedRegexOp = (regexOp & RKLMaskOp); - NSUInteger lastLocation = findAll->findInRange.location; - NSRange searchRange = findAll->findInRange; - - for(findAll->found = 0L; (findAll->found < findAll->findUpTo) && ((findAll->found < findAll->capacity) || (findAll->found == 0L)); findAll->found++) { - NSInteger loopCapture, shouldBreak = 0L; - - if(RKL_EXPECTED(findAll->found >= ((findAll->capacity - ((captureCount + 2L) * 4L)) - 4L), 0L)) { if(RKL_EXPECTED(rkl_growFindRanges(cacheSlot, lastLocation, findAll, exception) == 0UL, 0L)) { goto exitNow; } } - - RKLCDelayedAssert((searchRange.location != (NSUInteger)NSNotFound) && (NSRangeInsideRange(searchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(findAll->findInRange, cacheSlot->setToRange) == YES), exception, exitNow); - - // This fixes a 'bug' that is also present in ICU's uregex_split(). 'Bug', in this case, means that the results of a split operation can differ from those that perl's split() creates for the same input. - // "I|at|ice I eat rice" split using the regex "\b\s*" demonstrates the problem. ICU bug http://bugs.icu-project.org/trac/ticket/6826 - // ICU : "", "I", "|", "at", "|", "ice", "", "I", "", "eat", "", "rice" <- Results that RegexKitLite used to produce. - // PERL: "I", "|", "at", "|", "ice", "I", "eat", "rice" <- Results that RegexKitLite now produces. - do { if((rkl_search(cacheSlot, &searchRange, 1UL, exception, status) == NO) || (RKL_EXPECTED(*status > U_ZERO_ERROR, 0L))) { shouldBreak = 1L; } } - while((maskedRegexOp == RKLSplitOp) && RKL_EXPECTED(shouldBreak == 0L, 1L) && RKL_EXPECTED(cacheSlot->lastMatchRange.length == 0UL, 0L) && RKL_EXPECTED((cacheSlot->lastMatchRange.location - lastLocation) == 0UL, 0L)); - if(RKL_EXPECTED(shouldBreak == 1L, 0L)) { break; } - - RKLCDelayedAssert((searchRange.location != (NSUInteger)NSNotFound) && (NSRangeInsideRange(searchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(findAll->findInRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(searchRange, findAll->findInRange) == YES), exception, exitNow); - RKLCDelayedAssert((NSRangeInsideRange(cacheSlot->lastFindRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(cacheSlot->lastMatchRange, cacheSlot->setToRange) == YES) && (NSRangeInsideRange(cacheSlot->lastMatchRange, findAll->findInRange) == YES), exception, exitNow); - RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->capacity >= 0L) && ((findAll->found + (captureCount + 3L) + 1L) < (findAll->capacity - 2L)), exception, exitNow); - - switch(maskedRegexOp) { - case RKLArrayOfStringsOp: - if(findAll->capture == 0L) { findAll->ranges[findAll->found] = cacheSlot->lastMatchRange; } else { if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, (int32_t)findAll->capture, &findAll->ranges[findAll->found]) > U_ZERO_ERROR, 0L)) { goto exitNow; } } - break; - - case RKLSplitOp: // Fall-thru... - case RKLCapturesArrayOp: // Fall-thru... - case RKLArrayOfCapturesOp: - findAll->ranges[findAll->found] = ((maskedRegexOp == RKLSplitOp) ? NSMakeRange(lastLocation, cacheSlot->lastMatchRange.location - lastLocation) : cacheSlot->lastMatchRange); - - for(loopCapture = 1L; loopCapture <= captureCount; loopCapture++) { - RKLCDelayedAssert((findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)) && (loopCapture < INT_MAX), exception, exitNow); - if(RKL_EXPECTED(rkl_getRangeForCapture(cacheSlot, status, (int32_t)loopCapture, &findAll->ranges[++findAll->found]) > U_ZERO_ERROR, 0L)) { goto exitNow; } - } - break; - - default: if(*exception != NULL) { *exception = RKLCAssertDictionary(@"Unknown regexOp."); } goto exitNow; break; - } - - lastLocation = NSMaxRange(cacheSlot->lastMatchRange); - } - - if(RKL_EXPECTED(*status > U_ZERO_ERROR, 0L)) { goto exitNow; } - - RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)), exception, exitNow); - if((maskedRegexOp == RKLSplitOp) && (lastLocation != NSMaxRange(findAll->findInRange))) { findAll->ranges[findAll->found++] = NSMakeRange(lastLocation, NSMaxRange(findAll->findInRange) - lastLocation); } - - RKLCDelayedAssert((findAll->ranges != NULL) && (findAll->found >= 0L) && (findAll->found < (findAll->capacity - 2L)), exception, exitNow); - returnWithError = NO; - -exitNow: - return(returnWithError); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called from rkl_findRanges(). -// ---------- - -static NSUInteger rkl_growFindRanges(RKLCacheSlot *cacheSlot, NSUInteger lastLocation, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) { - NSUInteger didGrowRanges = 0UL; - RKLCDelayedAssert((((cacheSlot != NULL) && (cacheSlot->captureCount >= 0L)) && ((findAll != NULL) && (findAll->capacity >= 0L) && (findAll->rangesScratchBuffer != NULL) && (findAll->found >= 0L) && (((findAll->capacity > 0L) || (findAll->size > 0UL) || (findAll->ranges != NULL)) ? ((findAll->capacity > 0L) && (findAll->size > 0UL) && (findAll->ranges != NULL) && (((size_t)findAll->capacity * sizeof(NSRange)) == findAll->size)) : 1))), exception, exitNow); - - // Attempt to guesstimate the required capacity based on: the total length needed to search / (length we've searched so far / ranges found so far). - NSInteger newCapacity = (findAll->capacity + (findAll->capacity / 2L)), estimate = (NSInteger)((float)cacheSlot->setToLength / (((float)lastLocation + 1.0f) / ((float)findAll->found + 1.0f))); - newCapacity = (((newCapacity + ((estimate > newCapacity) ? estimate : newCapacity)) / 2L) + ((cacheSlot->captureCount + 2L) * 4L) + 4L); - - NSUInteger needToCopy = ((findAll->ranges != NULL) && (*findAll->rangesScratchBuffer != findAll->ranges)) ? 1UL : 0UL; // If findAll->ranges is set to a stack allocation then we need to manually copy the data from the stack to the new heap allocation. - size_t newSize = ((size_t)newCapacity * sizeof(NSRange)); - NSRange *newRanges = NULL; - - if(RKL_EXPECTED((newRanges = (NSRange *)rkl_realloc((RKL_STRONG_REF void **)findAll->rangesScratchBuffer, newSize, 0UL)) == NULL, 0L)) { findAll->capacity = 0L; findAll->size = 0UL; findAll->ranges = NULL; *findAll->rangesScratchBuffer = rkl_free((RKL_STRONG_REF void **)findAll->rangesScratchBuffer); goto exitNow; } else { didGrowRanges = 1UL; } - if(needToCopy == 1UL) { memcpy(newRanges, findAll->ranges, findAll->size); } // If necessary, copy the existing data to the new heap allocation. - - findAll->capacity = newCapacity; - findAll->size = newSize; - findAll->ranges = newRanges; - -exitNow: - return(didGrowRanges); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called from rkl_doFindOp(). -// ---------- - -static NSArray *rkl_makeArray(RKLCacheSlot *cacheSlot, RKLRegexOp regexOp, RKLFindAll *findAll, id *exception RKL_UNUSED_ASSERTION_ARG) { - NSUInteger createdStringsCount = 0UL, createdArraysCount = 0UL, transferedStringsCount = 0UL; - id *matchedStrings = NULL, *subcaptureArrays = NULL, emptyString = @""; - NSArray *resultArray = NULL; - - RKLCDelayedAssert((cacheSlot != NULL) && ((findAll != NULL) && (findAll->found >= 0L) && (findAll->stringsScratchBuffer != NULL) && (findAll->arraysScratchBuffer != NULL)), exception, exitNow); - - size_t matchedStringsSize = ((size_t)findAll->found * sizeof(id)); - CFStringRef setToString = cacheSlot->setToString; - - if((findAll->stackUsed + matchedStringsSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((matchedStrings = (id *)alloca(matchedStringsSize)) == NULL, 0L)) { goto exitNow; } findAll->stackUsed += matchedStringsSize; } - else { if(RKL_EXPECTED((matchedStrings = (id *)rkl_realloc(findAll->stringsScratchBuffer, matchedStringsSize, (NSUInteger)RKLScannedOption)) == NULL, 0L)) { goto exitNow; } } - - { // This sub-block (and its local variables) is here for the benefit of the optimizer. - NSUInteger found = (NSUInteger)findAll->found; - const NSRange *rangePtr = findAll->ranges; - id *matchedStringsPtr = matchedStrings; - - for(createdStringsCount = 0UL; createdStringsCount < found; createdStringsCount++) { - NSRange range = *rangePtr++; - if(RKL_EXPECTED(((*matchedStringsPtr++ = RKL_EXPECTED(range.length == 0UL, 0L) ? emptyString : rkl_CreateStringWithSubstring((id)setToString, range)) == NULL), 0L)) { goto exitNow; } - } - } - - NSUInteger arrayCount = createdStringsCount; - id *arrayObjects = matchedStrings; - - if((regexOp & RKLSubcapturesArray) != 0UL) { - RKLCDelayedAssert(((createdStringsCount % ((NSUInteger)cacheSlot->captureCount + 1UL)) == 0UL) && (createdArraysCount == 0UL), exception, exitNow); - - NSUInteger captureCount = ((NSUInteger)cacheSlot->captureCount + 1UL); - NSUInteger subcaptureArraysCount = (createdStringsCount / captureCount); - size_t subcaptureArraysSize = ((size_t)subcaptureArraysCount * sizeof(id)); - - if((findAll->stackUsed + subcaptureArraysSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((subcaptureArrays = (id *)alloca(subcaptureArraysSize)) == NULL, 0L)) { goto exitNow; } findAll->stackUsed += subcaptureArraysSize; } - else { if(RKL_EXPECTED((subcaptureArrays = (id *)rkl_realloc(findAll->arraysScratchBuffer, subcaptureArraysSize, (NSUInteger)RKLScannedOption)) == NULL, 0L)) { goto exitNow; } } - - { // This sub-block (and its local variables) is here for the benefit of the optimizer. - id *subcaptureArraysPtr = subcaptureArrays; - id *matchedStringsPtr = matchedStrings; - - for(createdArraysCount = 0UL; createdArraysCount < subcaptureArraysCount; createdArraysCount++) { - if(RKL_EXPECTED((*subcaptureArraysPtr++ = rkl_CreateArrayWithObjects((void **)matchedStringsPtr, captureCount)) == NULL, 0L)) { goto exitNow; } - matchedStringsPtr += captureCount; - transferedStringsCount += captureCount; - } - } - - RKLCDelayedAssert((transferedStringsCount == createdStringsCount), exception, exitNow); - arrayCount = createdArraysCount; - arrayObjects = subcaptureArrays; - } - - RKLCDelayedAssert((arrayObjects != NULL), exception, exitNow); - resultArray = rkl_CreateAutoreleasedArray((void **)arrayObjects, (NSUInteger)arrayCount); - -exitNow: - if(RKL_EXPECTED(resultArray == NULL, 0L) && (rkl_collectingEnabled() == NO)) { // If we did not create an array then we need to make sure that we release any objects we created. - NSUInteger x; - if(matchedStrings != NULL) { for(x = transferedStringsCount; x < createdStringsCount; x++) { if((matchedStrings[x] != NULL) && (matchedStrings[x] != emptyString)) { matchedStrings[x] = rkl_ReleaseObject(matchedStrings[x]); } } } - if(subcaptureArrays != NULL) { for(x = 0UL; x < createdArraysCount; x++) { if(subcaptureArrays[x] != NULL) { subcaptureArrays[x] = rkl_ReleaseObject(subcaptureArrays[x]); } } } - } - - return(resultArray); -} - -// IMPORTANT! This code is critical path code. Because of this, it has been written for speed, not clarity. -// IMPORTANT! Should only be called from rkl_performRegexOp(). -// ---------- - -static NSString *rkl_replaceString(RKLCacheSlot *cacheSlot, id searchString, NSUInteger searchU16Length, NSString *replacementString, NSUInteger replacementU16Length, NSUInteger *replacedCountPtr, NSUInteger replaceMutable, id *exception, int32_t *status) { - uint64_t searchU16Length64 = (uint64_t)searchU16Length, replacementU16Length64 = (uint64_t)replacementU16Length; - int32_t resultU16Length = 0, tempUniCharBufferU16Capacity = 0, needU16Capacity = 0; - UniChar *tempUniCharBuffer = NULL; - const UniChar *replacementUniChar = NULL; - id resultObject = NULL; - NSUInteger replacedCount = 0UL; - - if((RKL_EXPECTED(replacementU16Length64 >= (uint64_t)INT_MAX, 0L) || RKL_EXPECTED(((searchU16Length64 / 2ULL) + (replacementU16Length64 * 2ULL)) >= (uint64_t)INT_MAX, 0L))) { *exception = [NSException exceptionWithName:NSRangeException reason:@"Replacement string length exceeds INT_MAX." userInfo:NULL]; goto exitNow; } - - RKLCDelayedAssert((searchU16Length64 < (uint64_t)INT_MAX) && (replacementU16Length64 < (uint64_t)INT_MAX) && (((searchU16Length64 / 2ULL) + (replacementU16Length64 * 2ULL)) < (uint64_t)INT_MAX), exception, exitNow); - - // Zero order approximation of the buffer sizes for holding the replaced string or split strings and split strings pointer offsets. As UTF16 code units. - tempUniCharBufferU16Capacity = (int32_t)(16UL + (searchU16Length + (searchU16Length / 2UL)) + (replacementU16Length * 2UL)); - RKLCDelayedAssert((tempUniCharBufferU16Capacity < INT_MAX) && (tempUniCharBufferU16Capacity > 0), exception, exitNow); - - // Buffer sizes converted from native units to bytes. - size_t stackSize = 0UL, replacementSize = ((size_t)replacementU16Length * sizeof(UniChar)), tempUniCharBufferSize = ((size_t)tempUniCharBufferU16Capacity * sizeof(UniChar)); - - // For the various buffers we require, we first try to allocate from the stack if we're not over the RKL_STACK_LIMIT. If we are, switch to using the heap for the buffer. - if((stackSize + tempUniCharBufferSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)alloca(tempUniCharBufferSize)) == NULL, 0L)) { goto exitNow; } stackSize += tempUniCharBufferSize; } - else { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], tempUniCharBufferSize, 0UL)) == NULL, 0L)) { goto exitNow; } } - - // Try to get the pointer to the replacement strings UTF16 data. If we can't, allocate some buffer space, then covert to UTF16. - if((replacementUniChar = CFStringGetCharactersPtr((CFStringRef)replacementString)) == NULL) { - UniChar *uniCharBuffer = NULL; - if((stackSize + replacementSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)alloca(replacementSize)) == NULL, 0L)) { goto exitNow; } stackSize += replacementSize; } - else { if(RKL_EXPECTED((uniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[1], replacementSize, 0UL)) == NULL, 0L)) { goto exitNow; } } - CFStringGetCharacters((CFStringRef)replacementString, CFMakeRange(0L, replacementU16Length), uniCharBuffer); // Convert to a UTF16 string. - replacementUniChar = uniCharBuffer; - } - - resultU16Length = rkl_replaceAll(cacheSlot, replacementUniChar, (int32_t)replacementU16Length, tempUniCharBuffer, tempUniCharBufferU16Capacity, &replacedCount, &needU16Capacity, exception, status); - RKLCDelayedAssert((resultU16Length <= tempUniCharBufferU16Capacity) && (needU16Capacity >= resultU16Length) && (needU16Capacity >= 0), exception, exitNow); - if(RKL_EXPECTED(needU16Capacity >= INT_MAX, 0L)) { *exception = [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Replaced string length exceeds INT_MAX." userInfo:NULL]; goto exitNow; } - - if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { // Our buffer guess(es) were too small. Resize the buffers and try again. - tempUniCharBufferSize = ((size_t)(tempUniCharBufferU16Capacity = needU16Capacity + 4) * sizeof(UniChar)); // Use needU16Capacity. Bug 2890810. - if((stackSize + tempUniCharBufferSize) < (size_t)(RKL_STACK_LIMIT)) { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)alloca(tempUniCharBufferSize)) == NULL, 0L)) { goto exitNow; } stackSize += tempUniCharBufferSize; } // Warning about stackSize can be safely ignored. - else { if(RKL_EXPECTED((tempUniCharBuffer = (UniChar *)rkl_realloc(&scratchBuffer[0], tempUniCharBufferSize, 0UL)) == NULL, 0L)) { goto exitNow; } } - - *status = U_ZERO_ERROR; // Make sure the status var is cleared and try again. - resultU16Length = rkl_replaceAll(cacheSlot, replacementUniChar, (int32_t)replacementU16Length, tempUniCharBuffer, tempUniCharBufferU16Capacity, &replacedCount, &needU16Capacity, exception, status); - RKLCDelayedAssert((resultU16Length <= tempUniCharBufferU16Capacity) && (needU16Capacity >= resultU16Length) && (needU16Capacity >= 0), exception, exitNow); - } - - // If status != U_ZERO_ERROR, consider it an error, even though status < U_ZERO_ERROR is a 'warning' in ICU nomenclature. - // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 - if(RKL_EXPECTED(*status != U_ZERO_ERROR, 0L)) { goto exitNow; } // Something went wrong. - - if(resultU16Length == 0) { resultObject = @""; } // Optimize the case where the replaced text length == 0 with a @"" string. - else if(((NSUInteger)resultU16Length == searchU16Length) && (replacedCount == 0UL)) { // Optimize the case where the replacement == original by creating a copy. Very fast if self is immutable. - if(replaceMutable == 0UL) { resultObject = rkl_CFAutorelease(CFStringCreateCopy(NULL, (CFStringRef)searchString)); } // .. but only if this is not replacing a mutable self. Warning about potential leak can be safely ignored. - } else { resultObject = rkl_CFAutorelease(CFStringCreateWithCharacters(NULL, tempUniCharBuffer, (CFIndex)resultU16Length)); } // otherwise, create a new string. Warning about potential leak can be safely ignored. - - // If replaceMutable == 1UL, we don't do the replacement here. We wait until after we return and unlock the cache lock. - // This is because we may be trying to mutate an immutable string object. - if((replacedCount > 0UL) && (replaceMutable == 1UL)) { // We're working on a mutable string and there were successfull matches with replaced text, so there's work to do. - rkl_clearBuffer((cacheSlot->setToLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer, 0UL); - rkl_clearCacheSlotSetTo(cacheSlot); // Flush any cached information about this string since it will mutate. - } - -exitNow: - if(scratchBuffer[0] != NULL) { scratchBuffer[0] = rkl_free(&scratchBuffer[0]); } - if(scratchBuffer[1] != NULL) { scratchBuffer[1] = rkl_free(&scratchBuffer[1]); } - if(replacedCountPtr != NULL) { *replacedCountPtr = replacedCount; } - return(resultObject); -} // The two warnings about potential leaks can be safely ignored. - -// IMPORTANT! Should only be called from rkl_replaceString(). -// ---------- -// Modified version of the ICU libraries uregex_replaceAll() that keeps count of the number of replacements made. - -static int32_t rkl_replaceAll(RKLCacheSlot *cacheSlot, const UniChar *replacementUniChar, int32_t replacementU16Length, UniChar *replacedUniChar, int32_t replacedU16Capacity, NSUInteger *replacedCount, int32_t *needU16Capacity, id *exception RKL_UNUSED_ASSERTION_ARG, int32_t *status) { - int32_t u16Length = 0, initialReplacedU16Capacity = replacedU16Capacity; - NSUInteger replaced = 0UL, bufferOverflowed = 0UL; - RKLCDelayedAssert((cacheSlot != NULL) && (replacementUniChar != NULL) && (replacedUniChar != NULL) && (replacedCount != NULL) && (needU16Capacity != NULL) && (status != NULL) && (replacementU16Length >= 0) && (replacedU16Capacity >= 0), exception, exitNow); - - cacheSlot->lastFindRange = cacheSlot->lastMatchRange = NSNotFoundRange; // Clear the cached find information for this regex so a subsequent find works correctly. - RKL_ICU_FUNCTION_APPEND(uregex_reset)(cacheSlot->icu_regex, 0, status); - - // Work around for ICU uregex_reset() bug, see http://bugs.icu-project.org/trac/ticket/6545 - // http://sourceforge.net/tracker/index.php?func=detail&aid=2105213&group_id=204582&atid=990188 - if(RKL_EXPECTED(cacheSlot->setToRange.length == 0L, 0L) && (*status == U_INDEX_OUTOFBOUNDS_ERROR)) { *status = U_ZERO_ERROR; } - - // This loop originally came from ICU source/i18n/uregex.cpp, uregex_replaceAll. - // There is a bug in that code which causes the size of the buffer required for the replaced text to not be calculated correctly. - // This contains a work around using the variable bufferOverflowed. - // ICU bug: http://bugs.icu-project.org/trac/ticket/6656 - // http://sourceforge.net/tracker/index.php?func=detail&aid=2408447&group_id=204582&atid=990188 - while(RKL_ICU_FUNCTION_APPEND(uregex_findNext)(cacheSlot->icu_regex, status)) { - replaced++; - u16Length += RKL_ICU_FUNCTION_APPEND(uregex_appendReplacement)(cacheSlot->icu_regex, replacementUniChar, replacementU16Length, &replacedUniChar, &replacedU16Capacity, status); - if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { bufferOverflowed = 1UL; *status = U_ZERO_ERROR; } - } - if(RKL_EXPECTED(*status == U_BUFFER_OVERFLOW_ERROR, 0L)) { bufferOverflowed = 1UL; *status = U_ZERO_ERROR; } - u16Length += RKL_ICU_FUNCTION_APPEND(uregex_appendTail)(cacheSlot->icu_regex, &replacedUniChar, &replacedU16Capacity, status); - - // Check for status <= U_ZERO_ERROR (a 'warning' in ICU nomenclature) rather than just status == U_ZERO_ERROR. - // Under just the right circumstances, status might be equal to U_STRING_NOT_TERMINATED_WARNING. When this occured, - // rkl_replaceString would never get the U_BUFFER_OVERFLOW_ERROR status, and thus never grow the buffer to the size needed. - // http://sourceforge.net/tracker/?func=detail&atid=990188&aid=2890810&group_id=204582 - if(RKL_EXPECTED(*status <= U_ZERO_ERROR, 1L) && RKL_EXPECTED(bufferOverflowed == 1UL, 0L)) { *status = U_BUFFER_OVERFLOW_ERROR; } - -#ifndef NS_BLOCK_ASSERTIONS -exitNow: -#endif - if(replacedCount != NULL) { *replacedCount = replaced; } - if(needU16Capacity != NULL) { *needU16Capacity = u16Length; } // Use needU16Capacity to return the number of characters that are needed for the completely replaced string. Bug 2890810. - return(initialReplacedU16Capacity - replacedU16Capacity); // Return the number of characters of replacedUniChar that were used. -} - -static NSUInteger rkl_isRegexValid(id self, SEL _cmd, NSString *regex, RKLRegexOptions options, NSInteger *captureCountPtr, NSError **error) { - volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; - - RKLCacheSlot *cacheSlot = NULL; - NSUInteger gotCacheSlot = 0UL; - NSInteger captureCount = -1L; - id exception = NULL; - - if((error != NULL) && (*error != NULL)) { *error = NULL; } - if(regex == NULL) { RKL_RAISE_EXCEPTION(NSInvalidArgumentException, @"The regular expression argument is NULL."); } - - OSSpinLockLock(&cacheSpinLock); - cacheSpinLockStatus |= RKLLockedCacheSpinLock; - rkl_dtrace_incrementEventID(); - if((cacheSlot = rkl_getCachedRegex(regex, options, error, &exception)) != NULL) { gotCacheSlot = 1UL; captureCount = cacheSlot->captureCount; } - cacheSlot = NULL; - OSSpinLockUnlock(&cacheSpinLock); - cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. - - if(captureCountPtr != NULL) { *captureCountPtr = captureCount; } - if(RKL_EXPECTED(exception != NULL, 0L)) { rkl_handleDelayedAssert(self, _cmd, exception); } - return(gotCacheSlot); -} - -static void rkl_clearStringCache(void) { - NSCParameterAssert(cacheSpinLock != (OSSpinLock)0); - lastCacheSlot = NULL; - NSUInteger x = 0UL; - for(x = 0UL; x < (NSUInteger)(RKL_SCRATCH_BUFFERS); x++) { if(scratchBuffer[x] != NULL) { scratchBuffer[x] = rkl_free(&scratchBuffer[x]); } } - for(x = 0UL; x < (NSUInteger)(RKL_CACHE_SIZE); x++) { rkl_clearCacheSlotRegex(&rkl_cacheSlots[x]); } - rkl_clearBuffer(&fixedBuffer, 0UL); - rkl_clearBuffer(&dynamicBuffer, 1UL); -} - -static void rkl_clearBuffer(RKLBuffer *buffer, NSUInteger freeDynamicBuffer) { - if(buffer == NULL) { return; } - if((freeDynamicBuffer == 1UL) && (buffer->uniChar != NULL) && (buffer == &dynamicBuffer)) { RKL_STRONG_REF void *p = (RKL_STRONG_REF void *)dynamicBuffer.uniChar; dynamicBuffer.uniChar = (RKL_STRONG_REF UniChar *)rkl_free(&p); } - if(buffer->string != NULL) { CFRelease((CFTypeRef)buffer->string); buffer->string = NULL; } - buffer->length = 0L; - buffer->hash = 0UL; -} - -static void rkl_clearCacheSlotRegex(RKLCacheSlot *cacheSlot) { - if(cacheSlot == NULL) { return; } - if(cacheSlot->setToString != NULL) { rkl_clearCacheSlotSetTo(cacheSlot); } - if(cacheSlot->icu_regex != NULL) { RKL_ICU_FUNCTION_APPEND(uregex_close)(cacheSlot->icu_regex); cacheSlot->icu_regex = NULL; cacheSlot->captureCount = -1L; } - if(cacheSlot->regexString != NULL) { CFRelease((CFTypeRef)cacheSlot->regexString); cacheSlot->regexString = NULL; cacheSlot->options = 0U; } -} - -static void rkl_clearCacheSlotSetTo(RKLCacheSlot *cacheSlot) { - if(cacheSlot == NULL) { return; } - if(cacheSlot->icu_regex != NULL) { int32_t status = 0; RKL_ICU_FUNCTION_APPEND(uregex_setText)(cacheSlot->icu_regex, &emptyUniCharString[0], 0, &status); } - if(cacheSlot->setToString != NULL) { CFRelease((CFTypeRef)cacheSlot->setToString); cacheSlot->setToString = NULL; } - cacheSlot->lastFindRange = cacheSlot->lastMatchRange = cacheSlot->setToRange = NSNotFoundRange; - cacheSlot->setToIsImmutable = cacheSlot->setToNeedsConversion = 0U; - cacheSlot->setToUniChar = NULL; - cacheSlot->setToHash = 0UL; - cacheSlot->setToLength = 0L; -} - -// Helps to keep things tidy. -#define addKeyAndObject(objs, keys, i, k, o) ({id _o=(o), _k=(k); if((_o != NULL) && (_k != NULL)) { objs[i] = _o; keys[i] = _k; i++; } }) - -static NSDictionary *rkl_userInfoDictionary(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status, ...) { - va_list varArgsList; - va_start(varArgsList, status); - if(regexString == NULL) { va_end(varArgsList); return(NULL); } - - id objects[64], keys[64]; - NSUInteger count = 0UL; - - NSString *errorNameString = [NSString stringWithUTF8String:RKL_ICU_FUNCTION_APPEND(u_errorName)(status)]; - - addKeyAndObject(objects, keys, count, RKLICURegexRegexErrorKey, regexString); - addKeyAndObject(objects, keys, count, RKLICURegexRegexOptionsErrorKey, [NSNumber numberWithUnsignedInt:options]); - addKeyAndObject(objects, keys, count, RKLICURegexErrorCodeErrorKey, [NSNumber numberWithInt:status]); - addKeyAndObject(objects, keys, count, RKLICURegexErrorNameErrorKey, errorNameString); - - if((parseError != NULL) && (parseError->line != -1)) { - NSString *preContextString = [NSString stringWithCharacters:&parseError->preContext[0] length:(NSUInteger)RKL_ICU_FUNCTION_APPEND(u_strlen)(&parseError->preContext[0])]; - NSString *postContextString = [NSString stringWithCharacters:&parseError->postContext[0] length:(NSUInteger)RKL_ICU_FUNCTION_APPEND(u_strlen)(&parseError->postContext[0])]; - - addKeyAndObject(objects, keys, count, RKLICURegexLineErrorKey, [NSNumber numberWithInt:parseError->line]); - addKeyAndObject(objects, keys, count, RKLICURegexOffsetErrorKey, [NSNumber numberWithInt:parseError->offset]); - addKeyAndObject(objects, keys, count, RKLICURegexPreContextErrorKey, preContextString); - addKeyAndObject(objects, keys, count, RKLICURegexPostContextErrorKey, postContextString); - addKeyAndObject(objects, keys, count, @"NSLocalizedFailureReason", ([NSString stringWithFormat:@"The error %@ occurred at line %d, column %d: %@<>%@", errorNameString, parseError->line, parseError->offset, preContextString, postContextString])); - } else { - addKeyAndObject(objects, keys, count, @"NSLocalizedFailureReason", ([NSString stringWithFormat:@"The error %@ occurred.", errorNameString])); - } - - while(count < 62UL) { id obj = va_arg(varArgsList, id), key = va_arg(varArgsList, id); if((obj != NULL) && (key != NULL)) { addKeyAndObject(objects, keys, count, key, obj); } else { break; } } - va_end(varArgsList); - - return([NSDictionary dictionaryWithObjects:&objects[0] forKeys:&keys[0] count:count]); -} - -static NSError *rkl_NSErrorForRegex(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) { - return([NSError errorWithDomain:RKLICURegexErrorDomain code:(NSInteger)status userInfo:rkl_userInfoDictionary(regexString, options, parseError, status, @"There was an error compiling the regular expression.", @"NSLocalizedDescription", NULL)]); -} - -static NSException *rkl_NSExceptionForRegex(NSString *regexString, RKLRegexOptions options, const UParseError *parseError, int32_t status) { - return([NSException exceptionWithName:RKLICURegexException reason:[NSString stringWithFormat:@"ICU regular expression error #%d, %s.", status, RKL_ICU_FUNCTION_APPEND(u_errorName)(status)] userInfo:rkl_userInfoDictionary(regexString, options, parseError, status, NULL)]); -} - -static NSDictionary *rkl_makeAssertDictionary(const char *function, const char *file, int line, NSString *format, ...) { - va_list varArgsList; - va_start(varArgsList, format); - NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease]; - va_end(varArgsList); - NSString *functionString = [NSString stringWithUTF8String:function], *fileString = [NSString stringWithUTF8String:file]; - return([NSDictionary dictionaryWithObjectsAndKeys:formatString, @"description", functionString, @"function", fileString, @"file", [NSNumber numberWithInt:line], @"line", NSInternalInconsistencyException, @"exceptionName", NULL]); -} - -static NSString *rkl_stringFromClassAndMethod(id object, SEL selector, NSString *format, ...) { - va_list varArgsList; - va_start(varArgsList, format); - NSString *formatString = [[[NSString alloc] initWithFormat:format arguments:varArgsList] autorelease]; - va_end(varArgsList); - Class objectsClass = [object class]; - return([NSString stringWithFormat:@"*** %c[%@ %@]: %@", (object == objectsClass) ? '+' : '-', NSStringFromClass(objectsClass), NSStringFromSelector(selector), formatString]); -} - -#pragma mark - -#pragma mark Objective-C Public Interface -#pragma mark - - -@implementation NSString (RegexKitLiteAdditions) - -#pragma mark +clearStringCache - -+ (void)RKL_METHOD_PREPEND(clearStringCache) -{ - volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; - OSSpinLockLock(&cacheSpinLock); - cacheSpinLockStatus |= RKLLockedCacheSpinLock; - rkl_clearStringCache(); - OSSpinLockUnlock(&cacheSpinLock); - cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. -} - -#pragma mark +captureCountForRegex: - -+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex -{ - NSInteger captureCount = -1L; - rkl_isRegexValid(self, _cmd, regex, RKLNoOptions, &captureCount, NULL); - return(captureCount); -} - -+ (NSInteger)RKL_METHOD_PREPEND(captureCountForRegex):(NSString *)regex options:(RKLRegexOptions)options error:(NSError **)error -{ - NSInteger captureCount = -1L; - rkl_isRegexValid(self, _cmd, regex, options, &captureCount, error); - return(captureCount); -} - -#pragma mark -captureCount: - -- (NSInteger)RKL_METHOD_PREPEND(captureCount) -{ - NSInteger captureCount = -1L; - rkl_isRegexValid(self, _cmd, self, RKLNoOptions, &captureCount, NULL); - return(captureCount); -} - -- (NSInteger)RKL_METHOD_PREPEND(captureCountWithOptions):(RKLRegexOptions)options error:(NSError **)error -{ - NSInteger captureCount = -1L; - rkl_isRegexValid(self, _cmd, self, options, &captureCount, error); - return(captureCount); -} - -#pragma mark -componentsSeparatedByRegex: - -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex -{ - NSRange range = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex range:(NSRange)range -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(componentsSeparatedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLSplitOp, regex, options, 0L, self, &range, NULL, error, NULL)); -} - -#pragma mark -isMatchedByRegex: - -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex -{ - NSRange result = NSNotFoundRange, range = NSMaxiumRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); - return((result.location == (NSUInteger)NSNotFound) ? NO : YES); -} - -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex inRange:(NSRange)range -{ - NSRange result = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); - return((result.location == (NSUInteger)NSNotFound) ? NO : YES); -} - -- (BOOL)RKL_METHOD_PREPEND(isMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range error:(NSError **)error -{ - NSRange result = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, 0L, self, &range, NULL, error, &result); - return((result.location == (NSUInteger)NSNotFound) ? NO : YES); -} - -#pragma mark -isRegexValid - -- (BOOL)RKL_METHOD_PREPEND(isRegexValid) -{ - return(rkl_isRegexValid(self, _cmd, self, RKLNoOptions, NULL, NULL) == 1UL ? YES : NO); -} - -- (BOOL)RKL_METHOD_PREPEND(isRegexValidWithOptions):(RKLRegexOptions)options error:(NSError **)error -{ - return(rkl_isRegexValid(self, _cmd, self, options, NULL, error) == 1UL ? YES : NO); -} - -#pragma mark -flushCachedRegexData - -- (void)RKL_METHOD_PREPEND(flushCachedRegexData) -{ - volatile NSUInteger RKL_CLEANUP(rkl_cleanup_cacheSpinLockStatus) cacheSpinLockStatus = 0UL; - - CFIndex selfLength = CFStringGetLength((CFStringRef)self); - CFHashCode selfHash = CFHash((CFTypeRef)self); - - OSSpinLockLock(&cacheSpinLock); - cacheSpinLockStatus |= RKLLockedCacheSpinLock; - rkl_dtrace_incrementEventID(); - - NSUInteger slot; - for(slot = 0UL; slot < (NSUInteger)(RKL_CACHE_SIZE); slot++) { - RKLCacheSlot *cacheSlot = &rkl_cacheSlots[slot]; - if((cacheSlot->setToString != NULL) && ( (cacheSlot->setToString == (CFStringRef)self) || ((cacheSlot->setToLength == selfLength) && (cacheSlot->setToHash == selfHash)) ) ) { rkl_clearCacheSlotSetTo(cacheSlot); } - } - - RKLBuffer *buffer = (selfLength < (CFIndex)(RKL_FIXED_LENGTH)) ? &fixedBuffer : &dynamicBuffer; - if((buffer->string != NULL) && ((buffer->string == (CFStringRef)self) || ((buffer->length == selfLength) && (buffer->hash == selfHash)))) { rkl_clearBuffer(buffer, 0UL); } - - OSSpinLockUnlock(&cacheSpinLock); - cacheSpinLockStatus |= RKLUnlockedCacheSpinLock; // Warning about cacheSpinLockStatus never being read can be safely ignored. -} - -#pragma mark -rangeOfRegex: - -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex -{ - NSRange result = NSNotFoundRange, range = NSMaxiumRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); - return(result); -} - -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex capture:(NSInteger)capture -{ - NSRange result = NSNotFoundRange, range = NSMaxiumRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, capture, self, &range, NULL, NULL, &result); - return(result); -} - -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex inRange:(NSRange)range -{ - NSRange result = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &result); - return(result); -} - -- (NSRange)RKL_METHOD_PREPEND(rangeOfRegex):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error -{ - NSRange result = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, capture, self, &range, NULL, error, &result); - return(result); -} - -#pragma mark -stringByMatching: - -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex -{ - NSRange matchedRange = NSNotFoundRange, range = NSMaxiumRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &matchedRange); - return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); -} // Warning about potential leak can be safely ignored. - -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex capture:(NSInteger)capture -{ - NSRange matchedRange = NSNotFoundRange, range = NSMaxiumRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, capture, self, &range, NULL, NULL, &matchedRange); - return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); -} // Warning about potential leak can be safely ignored. - -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex inRange:(NSRange)range -{ - NSRange matchedRange = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, &matchedRange); - return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); -} // Warning about potential leak can be safely ignored. - -- (NSString *)RKL_METHOD_PREPEND(stringByMatching):(NSString *)regex options:(RKLRegexOptions)options inRange:(NSRange)range capture:(NSInteger)capture error:(NSError **)error -{ - NSRange matchedRange = NSNotFoundRange; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLRangeOp, regex, options, capture, self, &range, NULL, error, &matchedRange); - return((matchedRange.location == (NSUInteger)NSNotFound) ? NULL : rkl_CFAutorelease(CFStringCreateWithSubstring(NULL, (CFStringRef)self, CFMakeRange(matchedRange.location, matchedRange.length)))); -} // Warning about potential leak can be safely ignored. - -#pragma mark -stringByReplacingOccurrencesOfRegex: - -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement -{ - NSRange searchRange = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, NULL)); -} - -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, NULL)); -} - -- (NSString *)RKL_METHOD_PREPEND(stringByReplacingOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLReplaceOp, regex, options, 0L, self, &searchRange, replacement, error, NULL)); -} - -#pragma mark -componentsMatchedByRegex: - -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex -{ - NSRange searchRange = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex capture:(NSInteger)capture -{ - NSRange searchRange = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, capture, self, &searchRange, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex range:(NSRange)range -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(componentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range capture:(NSInteger)capture error:(NSError **)error -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLArrayOfStringsOp, regex, options, capture, self, &range, NULL, error, NULL)); -} - -#pragma mark -captureComponentsMatchedByRegex: - -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex -{ - NSRange searchRange = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(captureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)RKLCapturesArrayOp, regex, options, 0L, self, &range, NULL, error, NULL)); -} - -#pragma mark -arrayOfCaptureComponentsMatchedByRegex: - -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex -{ - NSRange searchRange = NSMaxiumRange; - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, RKLNoOptions, 0L, self, &searchRange, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex range:(NSRange)range -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, RKLNoOptions, 0L, self, &range, NULL, NULL, NULL)); -} - -- (NSArray *)RKL_METHOD_PREPEND(arrayOfCaptureComponentsMatchedByRegex):(NSString *)regex options:(RKLRegexOptions)options range:(NSRange)range error:(NSError **)error -{ - return(rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLArrayOfCapturesOp | RKLSubcapturesArray), regex, options, 0L, self, &range, NULL, error, NULL)); -} - -@end - - -@implementation NSMutableString (RegexKitLiteAdditions) - -#pragma mark -replaceOccurrencesOfRegex: - -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement -{ - NSRange searchRange = NSMaxiumRange; - NSUInteger replacedCount = 0UL; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, (void **)((void *)&replacedCount)); - return(replacedCount); -} - -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement range:(NSRange)searchRange -{ - NSUInteger replacedCount = 0UL; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, RKLNoOptions, 0L, self, &searchRange, replacement, NULL, (void **)((void *)&replacedCount)); - return(replacedCount); -} - -- (NSUInteger)RKL_METHOD_PREPEND(replaceOccurrencesOfRegex):(NSString *)regex withString:(NSString *)replacement options:(RKLRegexOptions)options range:(NSRange)searchRange error:(NSError **)error -{ - NSUInteger replacedCount = 0UL; - rkl_performRegexOp(self, _cmd, (RKLRegexOp)(RKLReplaceOp | RKLReplaceMutable), regex, options, 0L, self, &searchRange, replacement, error, (void **)((void *)&replacedCount)); - return(replacedCount); -} - -@end diff --git a/Xmod/Autocustomize Entity Classes.applescript b/Xmod/Autocustomize Entity Classes.applescript deleted file mode 100644 index e371047b..00000000 --- a/Xmod/Autocustomize Entity Classes.applescript +++ /dev/null @@ -1 +0,0 @@ -tell application "Xcode" if version = "3.2" or version = "3.2.1" then display alert "Xcode Incompatiblity" message "Xcode 3.2 and 3.2.1 broke the AppleScript interface for manipulating entities, breaking this script. Dupe http://openradar.me/7289446 if you want it back." as warning return end if activate if not (exists active project document) then error "No active project. Please open an Xcode project and re-run the script." end if set mainWindowFilePath to associated file name of main window if mainWindowFilePath does not end with ".xcdatamodel" then error "Please open an .xcdatamodel file and re-run the script." end if tell item 1 of (every data model document whose path is mainWindowFilePath) using terms from application "Finder" display alert "Autocustomize Entity Classes" message "Automatically customize all generic entity classes based on their names? (This is undoable.)" buttons {"Cancel", "Auto-customize"} cancel button 1 end using terms from if button returned of result is "Auto-customize" then repeat with entityIt in (every entity) set object class of entityIt to name of entityIt & "MO" end repeat end if end tell end tell activate \ No newline at end of file diff --git a/Xmod/English.lproj/InfoPlist.strings b/Xmod/English.lproj/InfoPlist.strings deleted file mode 100644 index 948e12b9..00000000 Binary files a/Xmod/English.lproj/InfoPlist.strings and /dev/null differ diff --git a/Xmod/Info.plist b/Xmod/Info.plist deleted file mode 100644 index 53468e4c..00000000 --- a/Xmod/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - - CFBundleIdentifier - com.rentzsch.xmod - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.8 - NSPrincipalClass - - XCPluginHasUI - - XCGCReady - YES - - diff --git a/Xmod/JRSwizzle/JRSwizzle.h b/Xmod/JRSwizzle/JRSwizzle.h deleted file mode 100644 index ceb0528d..00000000 --- a/Xmod/JRSwizzle/JRSwizzle.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com -// Some rights reserved: http://opensource.org/licenses/mit-license.php - -#import - -@interface NSObject (JRSwizzle) - -+ (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_; -+ (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_; - -@end diff --git a/Xmod/JRSwizzle/JRSwizzle.m b/Xmod/JRSwizzle/JRSwizzle.m deleted file mode 100644 index 2e6ed036..00000000 --- a/Xmod/JRSwizzle/JRSwizzle.m +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com -// Some rights reserved: http://opensource.org/licenses/mit-license.php - -#import "JRSwizzle.h" -#import - -#define SetNSErrorFor(FUNC, ERROR_VAR, FORMAT,...) \ - if (ERROR_VAR) { \ - NSString *errStr = [NSString stringWithFormat:@"%s: " FORMAT,FUNC,##__VA_ARGS__]; \ - *ERROR_VAR = [NSError errorWithDomain:@"NSCocoaErrorDomain" \ - code:-1 \ - userInfo:[NSDictionary dictionaryWithObject:errStr forKey:NSLocalizedDescriptionKey]]; \ - } -#define SetNSError(ERROR_VAR, FORMAT,...) SetNSErrorFor(__func__, ERROR_VAR, FORMAT, ##__VA_ARGS__) - -#if OBJC_API_VERSION >= 2 -#define GetClass(obj) object_getClass(obj) -#else -#define GetClass(obj) (obj ? obj->isa : Nil) -#endif - -@implementation NSObject (JRSwizzle) - -+ (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_ { -#if OBJC_API_VERSION >= 2 - Method origMethod = class_getInstanceMethod(self, origSel_); - if (!origMethod) { - SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]); - return NO; - } - - Method altMethod = class_getInstanceMethod(self, altSel_); - if (!altMethod) { - SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]); - return NO; - } - - class_addMethod(self, - origSel_, - class_getMethodImplementation(self, origSel_), - method_getTypeEncoding(origMethod)); - class_addMethod(self, - altSel_, - class_getMethodImplementation(self, altSel_), - method_getTypeEncoding(altMethod)); - - method_exchangeImplementations(class_getInstanceMethod(self, origSel_), class_getInstanceMethod(self, altSel_)); - return YES; -#else - // Scan for non-inherited methods. - Method directOriginalMethod = NULL, directAlternateMethod = NULL; - - void *iterator = NULL; - struct objc_method_list *mlist = class_nextMethodList(self, &iterator); - while (mlist) { - int method_index = 0; - for (; method_index < mlist->method_count; method_index++) { - if (mlist->method_list[method_index].method_name == origSel_) { - assert(!directOriginalMethod); - directOriginalMethod = &mlist->method_list[method_index]; - } - if (mlist->method_list[method_index].method_name == altSel_) { - assert(!directAlternateMethod); - directAlternateMethod = &mlist->method_list[method_index]; - } - } - mlist = class_nextMethodList(self, &iterator); - } - - // If either method is inherited, copy it up to the target class to make it non-inherited. - if (!directOriginalMethod || !directAlternateMethod) { - Method inheritedOriginalMethod = NULL, inheritedAlternateMethod = NULL; - if (!directOriginalMethod) { - inheritedOriginalMethod = class_getInstanceMethod(self, origSel_); - if (!inheritedOriginalMethod) { - SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]); - return NO; - } - } - if (!directAlternateMethod) { - inheritedAlternateMethod = class_getInstanceMethod(self, altSel_); - if (!inheritedAlternateMethod) { - SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]); - return NO; - } - } - - int hoisted_method_count = !directOriginalMethod && !directAlternateMethod ? 2 : 1; - struct objc_method_list *hoisted_method_list = malloc(sizeof(struct objc_method_list) + (sizeof(struct objc_method)*(hoisted_method_count-1))); - hoisted_method_list->obsolete = NULL; // soothe valgrind - apparently ObjC runtime accesses this value and it shows as uninitialized in valgrind - hoisted_method_list->method_count = hoisted_method_count; - Method hoisted_method = hoisted_method_list->method_list; - - if (!directOriginalMethod) { - bcopy(inheritedOriginalMethod, hoisted_method, sizeof(struct objc_method)); - directOriginalMethod = hoisted_method++; - } - if (!directAlternateMethod) { - bcopy(inheritedAlternateMethod, hoisted_method, sizeof(struct objc_method)); - directAlternateMethod = hoisted_method; - } - class_addMethods(self, hoisted_method_list); - } - - // Swizzle. - IMP temp = directOriginalMethod->method_imp; - directOriginalMethod->method_imp = directAlternateMethod->method_imp; - directAlternateMethod->method_imp = temp; - - return YES; -#endif -} - -+ (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_ { - return [GetClass((id)self) jr_swizzleMethod:origSel_ withMethod:altSel_ error:error_]; -} - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/10.3 Test-Info.plist b/Xmod/JRSwizzle/JRSwizzleTest/10.3 Test-Info.plist deleted file mode 100644 index 738cf17f..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/10.3 Test-Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.yourcompany.10.3 Test - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - - diff --git a/Xmod/JRSwizzle/JRSwizzleTest/10.4 Test-Info.plist b/Xmod/JRSwizzle/JRSwizzleTest/10.4 Test-Info.plist deleted file mode 100644 index b0a67265..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/10.4 Test-Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.yourcompany.10.4 Test - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - - diff --git a/Xmod/JRSwizzle/JRSwizzleTest/10.5 32-bit Test-Info.plist b/Xmod/JRSwizzle/JRSwizzleTest/10.5 32-bit Test-Info.plist deleted file mode 100644 index 6f5c60b5..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/10.5 32-bit Test-Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.yourcompany.10.5 32-bit Test - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - - diff --git a/Xmod/JRSwizzle/JRSwizzleTest/10.5 64-bit Test-Info.plist b/Xmod/JRSwizzle/JRSwizzleTest/10.5 64-bit Test-Info.plist deleted file mode 100644 index 737d82ed..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/10.5 64-bit Test-Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - com.yourcompany.10.5 64-bit Test - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - - diff --git a/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.h b/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.h deleted file mode 100644 index bbe9cc04..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@interface AppleSwizzleTest : SenTestCase { - -} - -- (void)testAppleSwizzleOfDirectMethod; -- (void)testAppleSwizzleOfInheritedMethod; - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.m b/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.m deleted file mode 100644 index 74b34e95..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/AppleSwizzleTest.m +++ /dev/null @@ -1,129 +0,0 @@ -#import "AppleSwizzleTest.h" -#import - -BOOL aFooCalled, bFooCalled, bAltFooCalled; - -@interface A5 : NSObject {} -- (void)foo5; -@end -@implementation A5 -- (void)foo5 { - aFooCalled = YES; -} -@end - -@interface B5 : A5 {} -@end -@implementation B5 -- (void)foo5 { - bFooCalled = YES; -} -@end - -@interface B5 (altFoo5) -- (void)altFoo5; -@end -@implementation B5 (altFoo5) -- (void)altFoo5 { - bAltFooCalled = YES; -} -@end - -@interface A6 : NSObject {} -- (void)foo6; -@end -@implementation A6 -- (void)foo6 { - aFooCalled = YES; -} -@end - -@interface B6 : A6 {} -@end -@implementation B6 -@end - -@interface B6 (altFoo6) -- (void)altFoo6; -@end -@implementation B6 (altFoo6) -- (void)altFoo6 { - bAltFooCalled = YES; -} -@end - -@implementation AppleSwizzleTest - -- (void)testAppleSwizzleOfDirectMethod { - A5 *a = [[[A5 alloc] init] autorelease]; - B5 *b = [[[B5 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo5]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo5]; - STAssertFalse(aFooCalled, nil); - STAssertTrue(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - method_exchangeImplementations(class_getInstanceMethod([B5 class], @selector(foo5)), - class_getInstanceMethod([B5 class], @selector(altFoo5))); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo5]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo5]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -- (void)testAppleSwizzleOfInheritedMethod { - A6 *a = [[[A6 alloc] init] autorelease]; - B6 *b = [[[B6 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo6]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo6]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - method_exchangeImplementations(class_getInstanceMethod([B6 class], @selector(foo6)), - class_getInstanceMethod([B6 class], @selector(altFoo6))); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo6]; - STAssertFalse(aFooCalled, nil); // KNOWN INCORRECT BEHAVIOR: [a foo6] resulted in calling B6(altFoo6)'s -altFoo6! - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo6]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.h b/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.h deleted file mode 100644 index 4b1b0b0b..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@interface BallardSwizzleTest : SenTestCase { - -} - -- (void)testBallardSwizzleOfDirectMethod; -- (void)testBallardSwizzleOfInheritedMethod; - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.m b/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.m deleted file mode 100644 index 0b013163..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/BallardSwizzleTest.m +++ /dev/null @@ -1,127 +0,0 @@ -#import "BallardSwizzleTest.h" -#import "MethodSwizzle.h" - -BOOL aFooCalled, bFooCalled, bAltFooCalled; - -@interface A3 : NSObject {} -- (void)foo3; -@end -@implementation A3 -- (void)foo3 { - aFooCalled = YES; -} -@end - -@interface B3 : A3 {} -@end -@implementation B3 -- (void)foo3 { - bFooCalled = YES; -} -@end - -@interface B3 (altFoo3) -- (void)altFoo3; -@end -@implementation B3 (altFoo3) -- (void)altFoo3 { - bAltFooCalled = YES; -} -@end - -@interface A4 : NSObject {} -- (void)foo4; -@end -@implementation A4 -- (void)foo4 { - aFooCalled = YES; -} -@end - -@interface B4 : A4 {} -@end -@implementation B4 -@end - -@interface B4 (altFoo4) -- (void)altFoo4; -@end -@implementation B4 (altFoo4) -- (void)altFoo4 { - bAltFooCalled = YES; -} -@end - -@implementation BallardSwizzleTest - -- (void)testBallardSwizzleOfDirectMethod { - A3 *a = [[[A3 alloc] init] autorelease]; - B3 *b = [[[B3 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo3]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo3]; - STAssertFalse(aFooCalled, nil); - STAssertTrue(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - MethodSwizzle([B3 class], @selector(foo3), @selector(altFoo3)); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo3]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo3]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -- (void)testBallardSwizzleOfInheritedMethod { - A4 *a = [[[A4 alloc] init] autorelease]; - B4 *b = [[[B4 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo4]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo4]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - MethodSwizzle([B4 class], @selector(foo4), @selector(altFoo4)); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo4]; - STAssertTrue(aFooCalled, nil); // CORRECT BEHAVIOR - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo4]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.h b/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.h deleted file mode 100644 index b4f5702c..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.h +++ /dev/null @@ -1,10 +0,0 @@ -#import - -@interface ClassicSwizzleTest : SenTestCase { - -} - -- (void)testClassicSwizzleOfDirectMethod; -- (void)testClassicSwizzleOfInheritedMethod; - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.m b/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.m deleted file mode 100644 index 30f7bc19..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/ClassicSwizzleTest.m +++ /dev/null @@ -1,151 +0,0 @@ -#import "ClassicSwizzleTest.h" -#import - -// Lifted from http://www.cocoadev.com/index.pl?MethodSwizzling -void ClassicMethodSwizzle(Class aClass, SEL orig_sel, SEL alt_sel) { - Method orig_method = nil, alt_method = nil; - - // First, look for the methods - orig_method = class_getInstanceMethod(aClass, orig_sel); - alt_method = class_getInstanceMethod(aClass, alt_sel); - - // If both are found, swizzle them - if ((orig_method != nil) && (alt_method != nil)) - { - char *temp1; - IMP temp2; - - temp1 = orig_method->method_types; - orig_method->method_types = alt_method->method_types; - alt_method->method_types = temp1; - - temp2 = orig_method->method_imp; - orig_method->method_imp = alt_method->method_imp; - alt_method->method_imp = temp2; - } -} - -BOOL aFooCalled, bFooCalled, bAltFooCalled; - -@interface A1 : NSObject {} -- (void)foo1; -@end -@implementation A1 -- (void)foo1 { - aFooCalled = YES; -} -@end - -@interface B1 : A1 {} -@end -@implementation B1 -- (void)foo1 { - bFooCalled = YES; -} -@end - -@interface B1 (altFoo1) -- (void)altFoo1; -@end -@implementation B1 (altFoo1) -- (void)altFoo1 { - bAltFooCalled = YES; -} -@end - -@interface A2 : NSObject {} -- (void)foo2; -@end -@implementation A2 -- (void)foo2 { - aFooCalled = YES; -} -@end - -@interface B2 : A2 {} -@end -@implementation B2 -@end - -@interface B2 (altFoo2) -- (void)altFoo2; -@end -@implementation B2 (altFoo2) -- (void)altFoo2 { - bAltFooCalled = YES; -} -@end - -@implementation ClassicSwizzleTest - -- (void)testClassicSwizzleOfDirectMethod { - A1 *a = [[[A1 alloc] init] autorelease]; - B1 *b = [[[B1 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo1]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo1]; - STAssertFalse(aFooCalled, nil); - STAssertTrue(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - ClassicMethodSwizzle([B1 class], @selector(foo1), @selector(altFoo1)); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo1]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo1]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -- (void)testClassicSwizzleOfInheritedMethod { - A2 *a = [[[A2 alloc] init] autorelease]; - B2 *b = [[[B2 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo2]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo2]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - ClassicMethodSwizzle([B2 class], @selector(foo2), @selector(altFoo2)); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo2]; - STAssertFalse(aFooCalled, nil); // KNOWN INCORRECT BEHAVIOR: [a foo2] resulted in calling B2(altFoo2)'s -altFoo2! - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo2]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -@end diff --git a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.h b/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.h deleted file mode 100644 index 8ed8dbe6..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface JRSwizzleTest : SenTestCase {} -@end \ No newline at end of file diff --git a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.m b/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.m deleted file mode 100644 index 15990f77..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.m +++ /dev/null @@ -1,156 +0,0 @@ -#import "JRSwizzleTest.h" -#import "JRSwizzle.h" - -BOOL aFooCalled, bFooCalled, bAltFooCalled; - -#pragma mark - -#pragma mark Scenario 7: Test JRSwizzle of Direct Implementation -#pragma mark - - -@interface A7 : NSObject {} -- (void)foo7; -@end -@implementation A7 -- (void)foo7 { - aFooCalled = YES; -} -@end - -@interface B7 : A7 {} -@end -@implementation B7 -- (void)foo7 { - bFooCalled = YES; -} -@end - -@interface B7 (altFoo7) -- (void)altFoo7; -@end -@implementation B7 (altFoo7) -- (void)altFoo7 { - bAltFooCalled = YES; -} -@end - -@interface JRSwizzleTest (testJRSwizzleOfDirectMethod) -- (void)testJRSwizzleOfDirectMethod; -@end -@implementation JRSwizzleTest (testJRSwizzleOfDirectMethod) - -- (void)testJRSwizzleOfDirectMethod { - A7 *a = [[[A7 alloc] init] autorelease]; - B7 *b = [[[B7 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo7]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo7]; - STAssertFalse(aFooCalled, nil); - STAssertTrue(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - NSError *error = nil; - [B7 jr_swizzleMethod:@selector(foo7) - withMethod:@selector(altFoo7) - error:&error]; - STAssertNil(error, nil); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo7]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo7]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -@end - -#pragma mark - -#pragma mark Scenario 8: Test JRSwizzle of Inherited Implementation -#pragma mark - - -@interface A8 : NSObject {} -- (void)foo8; -@end -@implementation A8 -- (void)foo8 { - aFooCalled = YES; -} -@end - -@interface B8 : A8 {} -@end -@implementation B8 -@end - -@interface B8 (altFoo8) -- (void)altFoo8; -@end -@implementation B8 (altFoo8) -- (void)altFoo8 { - bAltFooCalled = YES; -} -@end - -@interface JRSwizzleTest (testJRSwizzleOfInheritedMethod) -- (void)testJRSwizzleOfInheritedMethod; -@end -@implementation JRSwizzleTest (testJRSwizzleOfInheritedMethod) - -- (void)testJRSwizzleOfInheritedMethod { - A8 *a = [[[A8 alloc] init] autorelease]; - B8 *b = [[[B8 alloc] init] autorelease]; - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo8]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo8]; - STAssertTrue(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - } - - NSError *error = nil; - [B8 jr_swizzleMethod:@selector(foo8) - withMethod:@selector(altFoo8) - error:&error]; - STAssertNil(error, nil); - - { - aFooCalled = bFooCalled = bAltFooCalled = NO; - [a foo8]; - STAssertTrue(aFooCalled, nil); // CORRECT BEHAVIOR - STAssertFalse(bFooCalled, nil); - STAssertFalse(bAltFooCalled, nil); - - aFooCalled = bFooCalled = bAltFooCalled = NO; - [b foo8]; - STAssertFalse(aFooCalled, nil); - STAssertFalse(bFooCalled, nil); - STAssertTrue(bAltFooCalled, nil); - } -} - -@end - -@implementation JRSwizzleTest -@end \ No newline at end of file diff --git a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.xcodeproj/project.pbxproj b/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.xcodeproj/project.pbxproj deleted file mode 100644 index 6588aff8..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1168 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXAggregateTarget section */ - 79F3DBFA0CF33EE500733703 /* All Tests */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 79F3DC0C0CF33EFB00733703 /* Build configuration list for PBXAggregateTarget "All Tests" */; - buildPhases = ( - ); - dependencies = ( - 792609490CF3FA4A00A93D12 /* PBXTargetDependency */, - 7926085F0CF3F32700A93D12 /* PBXTargetDependency */, - 79F3DC3E0CF358B300733703 /* PBXTargetDependency */, - 79F3DC400CF358B300733703 /* PBXTargetDependency */, - ); - name = "All Tests"; - productName = "All Tests"; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 7926079B0CF3EE5400A93D12 /* AppleSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC870CF3EAAD00733703 /* AppleSwizzleTest.m */; }; - 792607C80CF3F0A900A93D12 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; - 792608460CF3F0AE00A93D12 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; }; - 792608640CF3F34000A93D12 /* BallardSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC5E0CF36BC300733703 /* BallardSwizzleTest.m */; }; - 792608650CF3F34100A93D12 /* ClassicSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC1C0CF3411300733703 /* ClassicSwizzleTest.m */; }; - 792608690CF3F36900A93D12 /* MethodSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC540CF36B3500733703 /* MethodSwizzle.m */; }; - 792608800CF3F57B00A93D12 /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */; }; - 792608810CF3F57B00A93D12 /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */; }; - 792608820CF3F57B00A93D12 /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */; }; - 792608880CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */; }; - 792608890CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */; }; - 7926088A0CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */; }; - 792608A80CF3F8DA00A93D12 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; - 792609260CF3F8E500A93D12 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; }; - 7926094C0CF3FA6400A93D12 /* BallardSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC5E0CF36BC300733703 /* BallardSwizzleTest.m */; }; - 7926094D0CF3FA6500A93D12 /* ClassicSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC1C0CF3411300733703 /* ClassicSwizzleTest.m */; }; - 7926094E0CF3FA6600A93D12 /* JRSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */; }; - 792609500CF3FA7400A93D12 /* MethodSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC540CF36B3500733703 /* MethodSwizzle.m */; }; - 792609510CF3FA7700A93D12 /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */; }; - 79F3DBE80CF33E6000733703 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; settings = {ATTRIBUTES = (); }; }; - 79F3DBEA0CF33E6000733703 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; - 79F3DC1D0CF3411300733703 /* ClassicSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC1C0CF3411300733703 /* ClassicSwizzleTest.m */; }; - 79F3DC560CF36B3500733703 /* MethodSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC540CF36B3500733703 /* MethodSwizzle.m */; }; - 79F3DC5F0CF36BC300733703 /* BallardSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC5E0CF36BC300733703 /* BallardSwizzleTest.m */; }; - 79F3DC880CF3EAAD00733703 /* AppleSwizzleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 79F3DC870CF3EAAD00733703 /* AppleSwizzleTest.m */; }; - 8DD76F9A0486AA7600D96B5E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* main.m */; settings = {ATTRIBUTES = (); }; }; - 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 792607970CF3EE2100A93D12 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 79F3DBE60CF33E6000733703; - remoteInfo = "10.5 64-bit"; - }; - 7926085C0CF3F26000A93D12 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 792607C20CF3F05800A93D12; - remoteInfo = 10.4; - }; - 7926085E0CF3F32700A93D12 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 792608540CF3F24400A93D12; - remoteInfo = "10.4 Test"; - }; - 792609480CF3FA4A00A93D12 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 7926093E0CF3F98E00A93D12; - remoteInfo = "10.3 Test"; - }; - 7926094A0CF3FA5300A93D12 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 792608A20CF3F88400A93D12; - remoteInfo = 10.3; - }; - 79F3DC1F0CF3417200733703 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 8DD76F960486AA7600D96B5E; - remoteInfo = "10.5 32-bit"; - }; - 79F3DC3D0CF358B300733703 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 79F3DC140CF33F5000733703; - remoteInfo = "10.5 32-bit Test"; - }; - 79F3DC3F0CF358B300733703 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 79F3DC2C0CF341EC00733703; - remoteInfo = "10.5 64-bit Test"; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 08FB7796FE84155DC02AAC07 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 32A70AAB03705E1F00C91783 /* JRSwizzleTest_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JRSwizzleTest_Prefix.pch; sourceTree = ""; }; - 792607C30CF3F05800A93D12 /* JRSwizzleTest_1040 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JRSwizzleTest_1040; sourceTree = BUILT_PRODUCTS_DIR; }; - 792608550CF3F24400A93D12 /* 10.4 Test.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "10.4 Test.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 792608560CF3F24400A93D12 /* 10.4 Test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "10.4 Test-Info.plist"; sourceTree = ""; }; - 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JRSwizzle.m; path = ../JRSwizzle.m; sourceTree = ""; }; - 7926087F0CF3F57B00A93D12 /* JRSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JRSwizzle.h; path = ../JRSwizzle.h; sourceTree = ""; }; - 792608860CF3F6BF00A93D12 /* JRSwizzleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JRSwizzleTest.h; sourceTree = ""; }; - 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JRSwizzleTest.m; sourceTree = ""; }; - 792608A30CF3F88400A93D12 /* JRSwizzleTest_1030 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JRSwizzleTest_1030; sourceTree = BUILT_PRODUCTS_DIR; }; - 7926093F0CF3F98E00A93D12 /* 10.3 Test.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "10.3 Test.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 792609400CF3F98E00A93D12 /* 10.3 Test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "10.3 Test-Info.plist"; sourceTree = ""; }; - 79F3DBEE0CF33E6000733703 /* JRSwizzleTest_1050_64 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JRSwizzleTest_1050_64; sourceTree = BUILT_PRODUCTS_DIR; }; - 79F3DC150CF33F5000733703 /* 10.5 32-bit Test.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "10.5 32-bit Test.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 79F3DC160CF33F5000733703 /* 10.5 32-bit Test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "10.5 32-bit Test-Info.plist"; sourceTree = ""; }; - 79F3DC1B0CF3411300733703 /* ClassicSwizzleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassicSwizzleTest.h; sourceTree = ""; }; - 79F3DC1C0CF3411300733703 /* ClassicSwizzleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClassicSwizzleTest.m; sourceTree = ""; }; - 79F3DC2D0CF341EC00733703 /* 10.5 64-bit Test.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "10.5 64-bit Test.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; - 79F3DC2E0CF341EC00733703 /* 10.5 64-bit Test-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "10.5 64-bit Test-Info.plist"; sourceTree = ""; }; - 79F3DC540CF36B3500733703 /* MethodSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MethodSwizzle.m; sourceTree = ""; }; - 79F3DC550CF36B3500733703 /* MethodSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MethodSwizzle.h; sourceTree = ""; }; - 79F3DC5D0CF36BC300733703 /* BallardSwizzleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BallardSwizzleTest.h; sourceTree = ""; }; - 79F3DC5E0CF36BC300733703 /* BallardSwizzleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BallardSwizzleTest.m; sourceTree = ""; }; - 79F3DC860CF3EAAD00733703 /* AppleSwizzleTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleSwizzleTest.h; sourceTree = ""; }; - 79F3DC870CF3EAAD00733703 /* AppleSwizzleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppleSwizzleTest.m; sourceTree = ""; }; - 8DD76FA10486AA7600D96B5E /* JRSwizzleTest_1050_32 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = JRSwizzleTest_1050_32; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 792607C10CF3F05800A93D12 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 792607C80CF3F0A900A93D12 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 792608520CF3F24400A93D12 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 792608A10CF3F88400A93D12 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 792608A80CF3F8DA00A93D12 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7926093C0CF3F98E00A93D12 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DBE90CF33E6000733703 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 79F3DBEA0CF33E6000733703 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC120CF33F5000733703 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC2A0CF341EC00733703 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8DD76F9B0486AA7600D96B5E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 08FB7794FE84155DC02AAC07 /* JRSwizzleTest */ = { - isa = PBXGroup; - children = ( - 79F3DC4B0CF36AC400733703 /* Tests */, - 08FB7795FE84155DC02AAC07 /* Source */, - 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */, - 1AB674ADFE9D54B511CA2CBB /* Products */, - 792609400CF3F98E00A93D12 /* 10.3 Test-Info.plist */, - 792608560CF3F24400A93D12 /* 10.4 Test-Info.plist */, - 79F3DC160CF33F5000733703 /* 10.5 32-bit Test-Info.plist */, - 79F3DC2E0CF341EC00733703 /* 10.5 64-bit Test-Info.plist */, - ); - name = JRSwizzleTest; - sourceTree = ""; - }; - 08FB7795FE84155DC02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - 08FB7796FE84155DC02AAC07 /* main.m */, - 7926087F0CF3F57B00A93D12 /* JRSwizzle.h */, - 7926087E0CF3F57B00A93D12 /* JRSwizzle.m */, - 79F3DC550CF36B3500733703 /* MethodSwizzle.h */, - 79F3DC540CF36B3500733703 /* MethodSwizzle.m */, - 32A70AAB03705E1F00C91783 /* JRSwizzleTest_Prefix.pch */, - ); - name = Source; - sourceTree = ""; - }; - 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = { - isa = PBXGroup; - children = ( - 08FB779EFE84155DC02AAC07 /* Foundation.framework */, - ); - name = "External Frameworks and Libraries"; - sourceTree = ""; - }; - 1AB674ADFE9D54B511CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8DD76FA10486AA7600D96B5E /* JRSwizzleTest_1050_32 */, - 79F3DBEE0CF33E6000733703 /* JRSwizzleTest_1050_64 */, - 79F3DC150CF33F5000733703 /* 10.5 32-bit Test.octest */, - 79F3DC2D0CF341EC00733703 /* 10.5 64-bit Test.octest */, - 792607C30CF3F05800A93D12 /* JRSwizzleTest_1040 */, - 792608550CF3F24400A93D12 /* 10.4 Test.octest */, - 792608A30CF3F88400A93D12 /* JRSwizzleTest_1030 */, - 7926093F0CF3F98E00A93D12 /* 10.3 Test.octest */, - ); - name = Products; - sourceTree = ""; - }; - 79F3DC4B0CF36AC400733703 /* Tests */ = { - isa = PBXGroup; - children = ( - 79F3DC1B0CF3411300733703 /* ClassicSwizzleTest.h */, - 79F3DC1C0CF3411300733703 /* ClassicSwizzleTest.m */, - 79F3DC5D0CF36BC300733703 /* BallardSwizzleTest.h */, - 79F3DC5E0CF36BC300733703 /* BallardSwizzleTest.m */, - 79F3DC860CF3EAAD00733703 /* AppleSwizzleTest.h */, - 79F3DC870CF3EAAD00733703 /* AppleSwizzleTest.m */, - 792608860CF3F6BF00A93D12 /* JRSwizzleTest.h */, - 792608870CF3F6BF00A93D12 /* JRSwizzleTest.m */, - ); - name = Tests; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 792607C20CF3F05800A93D12 /* 10.4 */ = { - isa = PBXNativeTarget; - buildConfigurationList = 792607C70CF3F09500A93D12 /* Build configuration list for PBXNativeTarget "10.4" */; - buildPhases = ( - 792607C00CF3F05800A93D12 /* Sources */, - 792607C10CF3F05800A93D12 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = 10.4; - productName = 10.4; - productReference = 792607C30CF3F05800A93D12 /* JRSwizzleTest_1040 */; - productType = "com.apple.product-type.tool"; - }; - 792608540CF3F24400A93D12 /* 10.4 Test */ = { - isa = PBXNativeTarget; - buildConfigurationList = 792608590CF3F24400A93D12 /* Build configuration list for PBXNativeTarget "10.4 Test" */; - buildPhases = ( - 792608500CF3F24400A93D12 /* Resources */, - 792608510CF3F24400A93D12 /* Sources */, - 792608520CF3F24400A93D12 /* Frameworks */, - 792608530CF3F24400A93D12 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 7926085D0CF3F26000A93D12 /* PBXTargetDependency */, - ); - name = "10.4 Test"; - productName = "10.4 Test"; - productReference = 792608550CF3F24400A93D12 /* 10.4 Test.octest */; - productType = "com.apple.product-type.bundle"; - }; - 792608A20CF3F88400A93D12 /* 10.3 */ = { - isa = PBXNativeTarget; - buildConfigurationList = 792608A70CF3F8AC00A93D12 /* Build configuration list for PBXNativeTarget "10.3" */; - buildPhases = ( - 792608A00CF3F88400A93D12 /* Sources */, - 792608A10CF3F88400A93D12 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = 10.3; - productName = 10.3; - productReference = 792608A30CF3F88400A93D12 /* JRSwizzleTest_1030 */; - productType = "com.apple.product-type.tool"; - }; - 7926093E0CF3F98E00A93D12 /* 10.3 Test */ = { - isa = PBXNativeTarget; - buildConfigurationList = 792609430CF3F98E00A93D12 /* Build configuration list for PBXNativeTarget "10.3 Test" */; - buildPhases = ( - 7926093A0CF3F98E00A93D12 /* Resources */, - 7926093B0CF3F98E00A93D12 /* Sources */, - 7926093C0CF3F98E00A93D12 /* Frameworks */, - 7926093D0CF3F98E00A93D12 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 7926094B0CF3FA5300A93D12 /* PBXTargetDependency */, - ); - name = "10.3 Test"; - productName = "10.3 Test"; - productReference = 7926093F0CF3F98E00A93D12 /* 10.3 Test.octest */; - productType = "com.apple.product-type.bundle"; - }; - 79F3DBE60CF33E6000733703 /* 10.5 64-bit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 79F3DBEB0CF33E6000733703 /* Build configuration list for PBXNativeTarget "10.5 64-bit" */; - buildPhases = ( - 79F3DBE70CF33E6000733703 /* Sources */, - 79F3DBE90CF33E6000733703 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "10.5 64-bit"; - productInstallPath = "$(HOME)/bin"; - productName = JRSwizzleTest; - productReference = 79F3DBEE0CF33E6000733703 /* JRSwizzleTest_1050_64 */; - productType = "com.apple.product-type.tool"; - }; - 79F3DC140CF33F5000733703 /* 10.5 32-bit Test */ = { - isa = PBXNativeTarget; - buildConfigurationList = 79F3DC190CF33F5100733703 /* Build configuration list for PBXNativeTarget "10.5 32-bit Test" */; - buildPhases = ( - 79F3DC100CF33F5000733703 /* Resources */, - 79F3DC110CF33F5000733703 /* Sources */, - 79F3DC120CF33F5000733703 /* Frameworks */, - 79F3DC130CF33F5000733703 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 79F3DC200CF3417200733703 /* PBXTargetDependency */, - ); - name = "10.5 32-bit Test"; - productName = "10.5 32-bit Test"; - productReference = 79F3DC150CF33F5000733703 /* 10.5 32-bit Test.octest */; - productType = "com.apple.product-type.bundle"; - }; - 79F3DC2C0CF341EC00733703 /* 10.5 64-bit Test */ = { - isa = PBXNativeTarget; - buildConfigurationList = 79F3DC310CF341EC00733703 /* Build configuration list for PBXNativeTarget "10.5 64-bit Test" */; - buildPhases = ( - 79F3DC280CF341EC00733703 /* Resources */, - 79F3DC290CF341EC00733703 /* Sources */, - 79F3DC2A0CF341EC00733703 /* Frameworks */, - 79F3DC2B0CF341EC00733703 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 792607980CF3EE2100A93D12 /* PBXTargetDependency */, - ); - name = "10.5 64-bit Test"; - productName = "10.5 64-bit Test"; - productReference = 79F3DC2D0CF341EC00733703 /* 10.5 64-bit Test.octest */; - productType = "com.apple.product-type.bundle"; - }; - 8DD76F960486AA7600D96B5E /* 10.5 32-bit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "10.5 32-bit" */; - buildPhases = ( - 8DD76F990486AA7600D96B5E /* Sources */, - 8DD76F9B0486AA7600D96B5E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "10.5 32-bit"; - productInstallPath = "$(HOME)/bin"; - productName = JRSwizzleTest; - productReference = 8DD76FA10486AA7600D96B5E /* JRSwizzleTest_1050_32 */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 08FB7793FE84155DC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "JRSwizzleTest" */; - compatibilityVersion = "Xcode 3.0"; - hasScannedForEncodings = 1; - mainGroup = 08FB7794FE84155DC02AAC07 /* JRSwizzleTest */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 79F3DBFA0CF33EE500733703 /* All Tests */, - 792608A20CF3F88400A93D12 /* 10.3 */, - 792607C20CF3F05800A93D12 /* 10.4 */, - 8DD76F960486AA7600D96B5E /* 10.5 32-bit */, - 79F3DBE60CF33E6000733703 /* 10.5 64-bit */, - 7926093E0CF3F98E00A93D12 /* 10.3 Test */, - 792608540CF3F24400A93D12 /* 10.4 Test */, - 79F3DC140CF33F5000733703 /* 10.5 32-bit Test */, - 79F3DC2C0CF341EC00733703 /* 10.5 64-bit Test */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 792608500CF3F24400A93D12 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7926093A0CF3F98E00A93D12 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC100CF33F5000733703 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC280CF341EC00733703 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 792608530CF3F24400A93D12 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; - 7926093D0CF3F98E00A93D12 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; - 79F3DC130CF33F5000733703 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; - 79F3DC2B0CF341EC00733703 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 792607C00CF3F05800A93D12 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 792608460CF3F0AE00A93D12 /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 792608510CF3F24400A93D12 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 792608640CF3F34000A93D12 /* BallardSwizzleTest.m in Sources */, - 792608650CF3F34100A93D12 /* ClassicSwizzleTest.m in Sources */, - 792608690CF3F36900A93D12 /* MethodSwizzle.m in Sources */, - 792608820CF3F57B00A93D12 /* JRSwizzle.m in Sources */, - 792608880CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 792608A00CF3F88400A93D12 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 792609260CF3F8E500A93D12 /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 7926093B0CF3F98E00A93D12 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7926094C0CF3FA6400A93D12 /* BallardSwizzleTest.m in Sources */, - 7926094D0CF3FA6500A93D12 /* ClassicSwizzleTest.m in Sources */, - 7926094E0CF3FA6600A93D12 /* JRSwizzleTest.m in Sources */, - 792609500CF3FA7400A93D12 /* MethodSwizzle.m in Sources */, - 792609510CF3FA7700A93D12 /* JRSwizzle.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DBE70CF33E6000733703 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 79F3DBE80CF33E6000733703 /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC110CF33F5000733703 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 79F3DC1D0CF3411300733703 /* ClassicSwizzleTest.m in Sources */, - 79F3DC560CF36B3500733703 /* MethodSwizzle.m in Sources */, - 79F3DC5F0CF36BC300733703 /* BallardSwizzleTest.m in Sources */, - 79F3DC880CF3EAAD00733703 /* AppleSwizzleTest.m in Sources */, - 792608800CF3F57B00A93D12 /* JRSwizzle.m in Sources */, - 7926088A0CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 79F3DC290CF341EC00733703 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7926079B0CF3EE5400A93D12 /* AppleSwizzleTest.m in Sources */, - 792608810CF3F57B00A93D12 /* JRSwizzle.m in Sources */, - 792608890CF3F6BF00A93D12 /* JRSwizzleTest.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8DD76F990486AA7600D96B5E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8DD76F9A0486AA7600D96B5E /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 792607980CF3EE2100A93D12 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 79F3DBE60CF33E6000733703 /* 10.5 64-bit */; - targetProxy = 792607970CF3EE2100A93D12 /* PBXContainerItemProxy */; - }; - 7926085D0CF3F26000A93D12 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 792607C20CF3F05800A93D12 /* 10.4 */; - targetProxy = 7926085C0CF3F26000A93D12 /* PBXContainerItemProxy */; - }; - 7926085F0CF3F32700A93D12 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 792608540CF3F24400A93D12 /* 10.4 Test */; - targetProxy = 7926085E0CF3F32700A93D12 /* PBXContainerItemProxy */; - }; - 792609490CF3FA4A00A93D12 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 7926093E0CF3F98E00A93D12 /* 10.3 Test */; - targetProxy = 792609480CF3FA4A00A93D12 /* PBXContainerItemProxy */; - }; - 7926094B0CF3FA5300A93D12 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 792608A20CF3F88400A93D12 /* 10.3 */; - targetProxy = 7926094A0CF3FA5300A93D12 /* PBXContainerItemProxy */; - }; - 79F3DC200CF3417200733703 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 8DD76F960486AA7600D96B5E /* 10.5 32-bit */; - targetProxy = 79F3DC1F0CF3417200733703 /* PBXContainerItemProxy */; - }; - 79F3DC3E0CF358B300733703 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 79F3DC140CF33F5000733703 /* 10.5 32-bit Test */; - targetProxy = 79F3DC3D0CF358B300733703 /* PBXContainerItemProxy */; - }; - 79F3DC400CF358B300733703 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 79F3DC2C0CF341EC00733703 /* 10.5 64-bit Test */; - targetProxy = 79F3DC3F0CF358B300733703 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 1DEB927508733DD40010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = JRSwizzleTest_Prefix.pch; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = JRSwizzleTest_1050_32; - ZERO_LINK = YES; - }; - name = Debug; - }; - 1DEB927608733DD40010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = JRSwizzleTest_Prefix.pch; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = JRSwizzleTest_1050_32; - }; - name = Release; - }; - 1DEB927908733DD40010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; - }; - name = Debug; - }; - 1DEB927A08733DD40010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc, - i386, - ); - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk"; - }; - name = Release; - }; - 792607C50CF3F05800A93D12 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; - PRODUCT_NAME = JRSwizzleTest_1040; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - ZERO_LINK = YES; - }; - name = Debug; - }; - 792607C60CF3F05800A93D12 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; - PRODUCT_NAME = JRSwizzleTest_1040; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - ZERO_LINK = NO; - }; - name = Release; - }; - 792608570CF3F24400A93D12 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1040"; - COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.4 Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.4 Test"; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 792608580CF3F24400A93D12 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1040"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.4 Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.4 Test"; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - ZERO_LINK = NO; - }; - name = Release; - }; - 792608A50CF3F88500A93D12 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ppc; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; - INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; - PRODUCT_NAME = JRSwizzleTest_1030; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - VALID_ARCHS = ppc; - ZERO_LINK = YES; - }; - name = Debug; - }; - 792608A60CF3F88500A93D12 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ppc; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; - INSTALL_PATH = /usr/local/bin; - PREBINDING = NO; - PRODUCT_NAME = JRSwizzleTest_1030; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - VALID_ARCHS = ppc; - ZERO_LINK = NO; - }; - name = Release; - }; - 792609410CF3F98E00A93D12 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ppc; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1030"; - COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.3 Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.3 Test"; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - TEST_HOST = "$(BUNDLE_LOADER)"; - VALID_ARCHS = ppc; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 792609420CF3F98E00A93D12 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ppc; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1030"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.3 Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.3 Test"; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - TEST_HOST = "$(BUNDLE_LOADER)"; - VALID_ARCHS = ppc; - WRAPPER_EXTENSION = octest; - ZERO_LINK = NO; - }; - name = Release; - }; - 79F3DBEC0CF33E6000733703 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = JRSwizzleTest_Prefix.pch; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = JRSwizzleTest_1050_64; - ZERO_LINK = YES; - }; - name = Debug; - }; - 79F3DBED0CF33E6000733703 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc64, - x86_64, - ); - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = JRSwizzleTest_Prefix.pch; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = JRSwizzleTest_1050_64; - }; - name = Release; - }; - 79F3DBFB0CF33EE500733703 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "All Tests"; - }; - name = Debug; - }; - 79F3DBFC0CF33EE500733703 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - PRODUCT_NAME = "All Tests"; - ZERO_LINK = NO; - }; - name = Release; - }; - 79F3DC170CF33F5100733703 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1050_32"; - COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.5 32-bit Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.5 32-bit Test"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 79F3DC180CF33F5100733703 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1050_32"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.5 32-bit Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.5 32-bit Test"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - ZERO_LINK = NO; - }; - name = Release; - }; - 79F3DC2F0CF341EC00733703 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc64, - x86_64, - ); - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1050_64"; - COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.5 64-bit Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.5 64-bit Test"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 79F3DC300CF341EC00733703 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - ppc64, - x86_64, - ); - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/JRSwizzleTest_1050_64"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Cocoa.framework/Headers/Cocoa.h"; - INFOPLIST_FILE = "10.5 64-bit Test-Info.plist"; - INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; - OTHER_LDFLAGS = ( - "-framework", - Cocoa, - "-framework", - SenTestingKit, - ); - PREBINDING = NO; - PRODUCT_NAME = "10.5 64-bit Test"; - TEST_HOST = "$(BUNDLE_LOADER)"; - WRAPPER_EXTENSION = octest; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "10.5 32-bit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB927508733DD40010E9CD /* Debug */, - 1DEB927608733DD40010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "JRSwizzleTest" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB927908733DD40010E9CD /* Debug */, - 1DEB927A08733DD40010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 792607C70CF3F09500A93D12 /* Build configuration list for PBXNativeTarget "10.4" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 792607C50CF3F05800A93D12 /* Debug */, - 792607C60CF3F05800A93D12 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 792608590CF3F24400A93D12 /* Build configuration list for PBXNativeTarget "10.4 Test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 792608570CF3F24400A93D12 /* Debug */, - 792608580CF3F24400A93D12 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 792608A70CF3F8AC00A93D12 /* Build configuration list for PBXNativeTarget "10.3" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 792608A50CF3F88500A93D12 /* Debug */, - 792608A60CF3F88500A93D12 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 792609430CF3F98E00A93D12 /* Build configuration list for PBXNativeTarget "10.3 Test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 792609410CF3F98E00A93D12 /* Debug */, - 792609420CF3F98E00A93D12 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 79F3DBEB0CF33E6000733703 /* Build configuration list for PBXNativeTarget "10.5 64-bit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 79F3DBEC0CF33E6000733703 /* Debug */, - 79F3DBED0CF33E6000733703 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 79F3DC0C0CF33EFB00733703 /* Build configuration list for PBXAggregateTarget "All Tests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 79F3DBFB0CF33EE500733703 /* Debug */, - 79F3DBFC0CF33EE500733703 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 79F3DC190CF33F5100733703 /* Build configuration list for PBXNativeTarget "10.5 32-bit Test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 79F3DC170CF33F5100733703 /* Debug */, - 79F3DC180CF33F5100733703 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 79F3DC310CF341EC00733703 /* Build configuration list for PBXNativeTarget "10.5 64-bit Test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 79F3DC2F0CF341EC00733703 /* Debug */, - 79F3DC300CF341EC00733703 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; -} diff --git a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest_Prefix.pch b/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest_Prefix.pch deleted file mode 100644 index edfae8e0..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/JRSwizzleTest_Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'JRSwizzleTest' target in the 'JRSwizzleTest' project. -// - -#ifdef __OBJC__ - #import -#endif diff --git a/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.h b/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.h deleted file mode 100644 index f1127f2b..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// MethodSwizzle.h -// -// Copyright (c) 2006 Tildesoft. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -#import - -BOOL ClassMethodSwizzle(Class klass, SEL origSel, SEL altSel); -BOOL MethodSwizzle(Class klass, SEL origSel, SEL altSel); diff --git a/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.m b/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.m deleted file mode 100644 index 8104696e..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/MethodSwizzle.m +++ /dev/null @@ -1,121 +0,0 @@ -// -// MethodSwizzle.m -// -// Copyright (c) 2006 Tildesoft. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -// Implementation of Method Swizzling, inspired by -// http://www.cocoadev.com/index.pl?MethodSwizzling - -// solves the inherited method problem - -#import "MethodSwizzle.h" -#import -#import -#import -#import - -static BOOL _PerformSwizzle(Class klass, SEL origSel, SEL altSel, BOOL forInstance); - -BOOL ClassMethodSwizzle(Class klass, SEL origSel, SEL altSel) { - return _PerformSwizzle(klass, origSel, altSel, NO); -} - -BOOL MethodSwizzle(Class klass, SEL origSel, SEL altSel) { - return _PerformSwizzle(klass, origSel, altSel, YES); -} - -// if the origSel isn't present in the class, pull it up from where it exists -// then do the swizzle -BOOL _PerformSwizzle(Class klass, SEL origSel, SEL altSel, BOOL forInstance) { - // First, make sure the class isn't nil - if (klass != nil) { - Method origMethod = NULL, altMethod = NULL; - - // Next, look for the methods - Class iterKlass = (forInstance ? klass : klass->isa); - void *iterator = NULL; - struct objc_method_list *mlist = class_nextMethodList(iterKlass, &iterator); - while (mlist != NULL) { - int i; - for (i = 0; i < mlist->method_count; ++i) { - if (mlist->method_list[i].method_name == origSel) { - origMethod = &mlist->method_list[i]; - break; - } - if (mlist->method_list[i].method_name == altSel) { - altMethod = &mlist->method_list[i]; - break; - } - } - mlist = class_nextMethodList(iterKlass, &iterator); - } - - if (origMethod == NULL || altMethod == NULL) { - // one or both methods are not in the immediate class - // try searching the entire hierarchy - // remember, iterKlass is the class we care about - klass || klass->isa - // class_getInstanceMethod on a metaclass is the same as class_getClassMethod on the real class - BOOL pullOrig = NO, pullAlt = NO; - if (origMethod == NULL) { - origMethod = class_getInstanceMethod(iterKlass, origSel); - pullOrig = YES; - } - if (altMethod == NULL) { - altMethod = class_getInstanceMethod(iterKlass, altSel); - pullAlt = YES; - } - - // die now if one of the methods doesn't exist anywhere in the hierarchy - // this way we won't make any changes to the class if we can't finish - if (origMethod == NULL || altMethod == NULL) { - return NO; - } - - // we can safely assume one of the two methods, at least, will be pulled - // pull them up - size_t listSize = sizeof(struct objc_method_list); - if (pullOrig && pullAlt) listSize += sizeof(struct objc_method); // need 2 methods - struct objc_method_list *mlist = malloc(listSize); - mlist->obsolete = NULL; - int i = 0; - if (pullOrig) { - memcpy(&mlist->method_list[i], origMethod, sizeof(struct objc_method)); - origMethod = &mlist->method_list[i]; - i++; - } - if (pullAlt) { - memcpy(&mlist->method_list[i], altMethod, sizeof(struct objc_method)); - altMethod = &mlist->method_list[i]; - i++; - } - mlist->method_count = i; - class_addMethods(iterKlass, mlist); - } - - // now swizzle - IMP temp = origMethod->method_imp; - origMethod->method_imp = altMethod->method_imp; - altMethod->method_imp = temp; - - return YES; - } - return NO; -} diff --git a/Xmod/JRSwizzle/JRSwizzleTest/main.m b/Xmod/JRSwizzle/JRSwizzleTest/main.m deleted file mode 100644 index abef408f..00000000 --- a/Xmod/JRSwizzle/JRSwizzleTest/main.m +++ /dev/null @@ -1,33 +0,0 @@ -#import - -#if 0 - - Scenario Swizzle Technology Method Implementation Correct Behavior 10.4 64-bit - ======== ================================ ===================== ================ ==== ====== - 1 Classic Direct YES YES NO - 2 Classic Inherited NO YES NO - 3 Ballard Direct YES YES NO - 4 Ballard Inherited YES YES NO - 5 method_exchangeImplementations Direct YES NO YES - 6 method_exchangeImplementations Inherited NO NO YES - 7 +swizzleMethod:withMethod:error: Direct YES YES YES - 8 +swizzleMethod:withMethod:error: Inherited YES YES YES - - * build+test 10.3 ppc (1, 2, 3, 4, 7, 8) - * build+test 10.4 ppc + i386 (1, 2, 3, 4, 7, 8) - * build+test 10.5 32-bit ppc + i386 (1, 2, 3, 4, 5, 6, 7, 8) - * build+test 10.5 64-bit x86_64 + ppc64 (5, 6, 7, 8) - -#endif - -int main (int argc, const char * argv[]) { - BOOL sixty_four_bit; -#ifdef __LP64__ - sixty_four_bit = YES; -#else - sixty_four_bit = NO; -#endif - - printf("JRSwizzleTest success SDK:%d %s\n", MAC_OS_X_VERSION_MAX_ALLOWED, sixty_four_bit ? "64-bit" : "32-bit"); - return 0; -} \ No newline at end of file diff --git a/Xmod/JRSwizzle/README.markdown b/Xmod/JRSwizzle/README.markdown deleted file mode 100644 index 4de4da51..00000000 --- a/Xmod/JRSwizzle/README.markdown +++ /dev/null @@ -1,144 +0,0 @@ -# JRSwizzle - -## Description - -JRSwizzle is source code package that offers a single, easy, correct+consistent interface for exchanging Objective-C method implementations ("method swizzling") across many versions of Mac OS X, Objective-C and runtime architectures. - -More succinctly: *JRSwizzle wants to be your one-stop-shop for all your method swizzling needs.* - -## Download - - $ cd /path/to/top/of/your/project - $ git submodule add git://github.com/rentzsch/jrswizzle.git JRSwizzle - $ git submodule init && git submodule update - - # OPTIONAL: Execute the following commands if you want to explicitly peg - # to a certain version. Otherwise `git submodule update` will keep you - # current with HEAD. - - $ cd JRSwizzle - $ git checkout v1.0d1 - -## Reasons for Existence - -* **Easy:** Just do this: `[SomeClass jr_swizzle:@selector(foo) withMethod:@selector(my_foo) error:&error];` Voila. -* **Correct:** There's a subtle interaction between method swizzling and method inheritance. Following in Kevin Ballard's footsteps, this package Does The Right Thing. -* **Compatible:** JRSwizzle should Just Work on any version of Mac OS X you care about. Here's the exhaustive compatibility list: - * Mac OS X v10.3/ppc (Ballard implementation) - * Mac OS X v10.4/ppc (Ballard implementation) - * Mac OS X v10.4/i386 (Ballard implementation) - * Mac OS X v10.5/ppc (method_exchangeImplementations+Ballard implementation) - * Mac OS X v10.5/i386 (method_exchangeImplementations+Ballard implementation) - * Mac OS X v10.5/ppc64 (method_exchangeImplementations+Ballard implementation) - * Mac OS X v10.5/x86_64 (method_exchangeImplementations+Ballard implementation) -* **Robust:** All parameters are checked and JRSwizzle returns an optional `NSError` with high-quality diagnostics. - -## Support - -Please use [JRSwizzle's Lighthouse project site](http://rentzsch.lighthouseapp.com/projects/28971-jrswizzle/tickets?q=all) to [file bugs or feature requests](http://rentzsch.lighthouseapp.com/projects/28971-jrswizzle/tickets/new). - -To contribute, please fork this project, make+commit your changes and then send me a pull request. - -## Comparison - -There's at least four swizzling implementations floating around. Here's a comparison chart to help you make sense of how they relate to each other and why JRSwizzle exists. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ScenarioSwizzle TechnologyMethod ImplementationCorrect Behavior10.464-bit
1ClassicDirectYESYESNO
2ClassicInheritedNOYESNO
3BallardDirectYESYESNO
4BallardInheritedYESYESNO
5AppleDirectYESNOYES
6AppleInheritedNONOYES
7JRSwizzleDirectYESYESYES
8JRSwizzleInheritedYESYESYES
- - * *Classic* is the canonical `MethodSwizzle()` implementation as described in [CocoaDev's MethodSwizzling page](http://www.cocoadev.com/index.pl?MethodSwizzling). - * *Ballard* is [Kevin Ballard's improved implementation](http://kevin.sb.org/2006/12/30/method-swizzling-reimplemented/) which solves the inherited method problem. - * *Apple* is 10.5's new `method_exchangeImplementations` API. - * *JRSwizzle* is this package. - -## License - -The source code is distributed under the nonviral [MIT License](http://opensource.org/licenses/mit-license.php). It's the simplest most permissive license available. - -## Version History - -* **v1.0d1:** May 31 2009 - - * [FIX] Soothe valgrind by nulling out `hoisted_method_list->obsolete`, which it apparently reads. ([Daniel Jalkut](http://github.com/rentzsch/jrswizzle/commit/2f677d063202b443ca7a1c46e8b67d67ea6fc88e)) - - * [FIX] Xcode 3.2 apparently now needs `ARCHS` set explicitly for 10.3 targets. ([rentzsch](http://github.com/rentzsch/jrswizzle/commit/4478faa40e4fdb322201da20f24d3996193ea48b)) - -* **v1.0d0:** Apr 09 2009 - - * Moved to github. - -* **v1.0d0:** Dec 28 2007 - - * Under development. \ No newline at end of file diff --git a/Xmod/TODO.txt b/Xmod/TODO.txt deleted file mode 100644 index 1fd810eb..00000000 --- a/Xmod/TODO.txt +++ /dev/null @@ -1,15 +0,0 @@ -MUST - -SHOULD -- Default-install Xmo'd (but allow opt-out) -- Metapackage (post-processing script to dynamically put plugin where it should go) -- bundle mogenerator into Xmo'd plugin bundle -- Undesirable effect when nuke+re-add opened human files. Make source group reload smarter. - -NICE -- - -NOTES - -DONE -- Add opt-in "xmod" into datamodel's comment field. \ No newline at end of file diff --git a/Xmod/Xmod.applescript b/Xmod/Xmod.applescript deleted file mode 100644 index 0570a6ff..00000000 --- a/Xmod/Xmod.applescript +++ /dev/null @@ -1,295 +0,0 @@ -property kExplicitlyProcessedOptions : {"--human-dir ", "--machine-dir ", "--output-dir ", "--log-command"} - -tell application "Xcode" - if not (exists active project document) then � - error "No active project. Please open an Xcode project and re-run the script." - try - my updateProjectXmod(project of active project document) - on error errMsg - my logger("Xmod.scpt exception: " & errMsg) - end try -end tell - -on updateProjectXmod(_project) - tell application "Xcode" - -- Iterate over every .xcdatamodel in the project. - set modelList to every file reference of _project whose file kind is "wrapper.xcdatamodel" and comments contains "xmod" - repeat with modelItr in modelList - my updateModel(_project, modelItr, comments of modelItr) - end repeat - -- Iterate over every .xcdatamodeld (notice the 'd') in the project. - set modeldList to every group of _project whose name contains ".xcdatamodeld" and comments contains "xmod" - repeat with modeldIt in modeldList - -- Find the 'active' model version - set currentVersionFile to full path of modeldIt & "/.xccurrentversion" - tell application "System Events" - set currentVersionPlist to contents of property list file currentVersionFile - set activeModelVersionFilename to value of property list item "_XCCurrentVersionName" of currentVersionPlist - end tell - set activeModelVersion to full path of modeldIt & "/" & activeModelVersionFilename - set modelItr to item 1 of (every file reference of modeldIt whose name is activeModelVersionFilename) - -- Then update it - my updateModel(_project, modelItr, comments of modeldIt) - end repeat - end tell -end updateProjectXmod - -on updateModel(_project, modelItr, theComments) - tell application "Xcode" - - set modelInfo to my getModelInfo(full path of modelItr, theComments) - set humanGroupRef to null - set machineGroupRef to null - - -- Figure out the model's parent group. - -- Unversioned models are simple files so their group is the answer. - -- Version models are bundles, which are represented as pseudo-groups in Xcode. You can't ask a pseudo-group for its parent group, - -- so we discover it by querying project-wide all groups that contain the pseudo-group and using the first result. - set modelItemRef to item 1 of (every item reference of _project whose full path is (full path of modelItr)) - set modelGroupRef to group of modelItemRef - if isBundle of modelInfo then - set modelGroupRef to item 1 of (every group of _project whose groups contains modelGroupRef) - end if - - -- look for a group in the project that has the full path of the human manageable files - set groupRefs to (every group of _project whose full path is (humanDirPath of modelInfo)) - -- if we don't find one, create it in the same group as the model file - if (count of groupRefs) = 0 then - tell modelGroupRef - -- if we have different human and machine paths, then append '_human' to the model name for the group name - if (humanDirPath of modelInfo) is not equal to (machineDirPath of modelInfo) then - make new group with properties {full path:(humanDirPath of modelInfo), name:(name of modelInfo & "_human")} - else - make new group with properties {full path:(humanDirPath of modelInfo), name:(name of modelInfo)} - end if - set groupRefs to (every group of _project whose full path is (humanDirPath of modelInfo)) - end tell - end if - set humanGroupRef to item 1 of groupRefs - - -- if we have different human and machine paths, then look for a group for the machine files - if (humanDirPath of modelInfo) is not equal to (machineDirPath of modelInfo) then - set groupRefs to (every group of _project whose full path is (machineDirPath of modelInfo)) - -- if we don't find one, create it in the same group as the model file... named with '_machine' appended to the model name - if (count of groupRefs) = 0 then - tell modelGroupRef - make new group with properties {full path:(machineDirPath of modelInfo), name:(name of modelInfo & "_machine")} - end tell - set groupRefs to (every group of _project whose full path is (machineDirPath of modelInfo)) - end if - set machineGroupRef to item 1 of groupRefs - end if - - -- Create the do shell script string and append any custom per model options to it, skipping the ones we've already parsed out - set logCommand to false - set theScript to "/usr/bin/mogenerator --model '" & full path of modelItr & "' --human-dir '" & (humanDirPath of modelInfo) & "' --machine-dir '" & (machineDirPath of modelInfo) & "'" - set theParagraphs to every paragraph of theComments - repeat with theParagraph in theParagraphs - if theParagraph starts with "--" then - set isExplicitlyProcessedOption to false - repeat with explicitlyProcessedOption in kExplicitlyProcessedOptions - if theParagraph starts with explicitlyProcessedOption then set isExplicitlyProcessedOption to true - end repeat - if not isExplicitlyProcessedOption then - set theScript to theScript & " " & the text of theParagraph - end if - if theParagraph starts with "--log-command" then - set logCommand to true - end if - end if - end repeat - - -- Meat. - if logCommand then - my logger(theScript) - end if - do shell script theScript - - my addFilesFromPathToGroup(_project, modelItr, humanGroupRef) - if machineGroupRef is not null then - my addFilesFromPathToGroup(_project, modelItr, machineGroupRef) - end if - end tell -end updateModel - -on everyTargetWithBuildFilePath(_project, _buildFilePath) - set theResult to {} - tell application "Xcode" - repeat with targetItr in (every target of _project) - repeat with buildFileItr in build files of targetItr - if full path of file reference of buildFileItr is _buildFilePath then set theResult to theResult & {(targetItr as anything)} - end repeat - end repeat - end tell - return theResult -end everyTargetWithBuildFilePath - -on getModelInfo(modelFileUnixPath, theComments) - set modelFilePosixRef to POSIX file modelFileUnixPath - set modelFileAlias to modelFilePosixRef as alias - set theOutputDir to "" - set theHumanDir to "" - set theMachineDir to "" - - -- check for any directory path options specified in the commments - set theParagraphs to every paragraph of theComments - repeat with theParagraph in theParagraphs - set paragraphLength to (length of theParagraph) - if (offset of "--human-dir " in theParagraph) = 1 then - set remainderOffset to (length of "--human-dir ") + 1 - if remainderOffset > paragraphLength then - set theHumanDir to "" - else - set theHumanDir to text remainderOffset thru -1 of theParagraph - end if - else if (offset of "--machine-dir " in theParagraph) = 1 then - set remainderOffset to (length of "--machine-dir ") + 1 - if remainderOffset > paragraphLength then - set theMachineDir to "" - else - set theMachineDir to text remainderOffset thru -1 of theParagraph - end if - else if (offset of "--output-dir " in theParagraph) = 1 then - set remainderOffset to (length of "--output-dir ") + 1 - if remainderOffset > paragraphLength then - set theOutputDir to "" - else - set theOutputDir to text remainderOffset thru -1 of theParagraph - end if - end if - end repeat - - -- remove any leading/trailing spaces or tabs from the paths - if (length of theHumanDir) > 0 then - repeat while character 1 of theHumanDir = tab or character 1 of theHumanDir = space - set theHumanDir to text 2 thru -1 of theHumanDir - end repeat - repeat while last character of theHumanDir = tab or last character of theHumanDir = space - set theHumanDir to text 1 thru -2 of theHumanDir - end repeat - end if - - if (length of theMachineDir) > 0 then - repeat while character 1 of theMachineDir = tab or character 1 of theMachineDir = space - set theMachineDir to text 2 thru -1 of theMachineDir - end repeat - repeat while last character of theMachineDir = tab or last character of theMachineDir = space - set theMachineDir to text 1 thru -2 of theMachineDir - end repeat - end if - - if (length of theOutputDir) > 0 then - repeat while character 1 of theOutputDir = tab or character 1 of theOutputDir = space - set theOutputDir to text 2 thru -1 of theOutputDir - end repeat - repeat while last character of theOutputDir = tab or last character of theOutputDir = space - set theOutputDir to text 1 thru -2 of theOutputDir - end repeat - end if - - -- get actual the model info and modify value for theOutputDir if necessary - tell application "Finder" - set modelFileFolder to folder of modelFileAlias - - set isModelBundle to name of modelFileFolder ends with ".xcdatamodeld" - if isModelBundle then - set modelFileAlias to (folder of modelFileAlias) as alias -- it's a bundle, go up one folder - set modelFileFolder to folder of modelFileAlias - end if - - set modelFileName to name of modelFileAlias - if isModelBundle then - set extensionLength to length of ".xcdatamodeld" - else - set extensionLength to length of ".xcdatamodel" - end if - - set modelName to text 1 thru -(extensionLength + 1) of modelFileName -- pull off the extension - - -- if we didn't find any directory specifiers in the comments, then make theOutputDir the folder containg the model file - if ((length of theOutputDir) = 0) and ((length of theHumanDir) = 0) and ((length of theMachineDir) = 0) then - if not (exists folder modelName of modelFileFolder) then � - make folder at modelFileFolder with properties {name:modelName} - set modelSrcFolder to folder modelName of modelFileFolder - set theOutputDir to text 1 thru -2 of (POSIX path of (modelSrcFolder as alias)) - -- otherwise, if theOutputDir isn't a full path itself already, set theOutputDir to a full path relative to the model file - else if theOutputDir does not start with "/" then - set modelFolderPath to text 1 thru -2 of (POSIX path of (modelFileFolder as alias)) - if (length of theOutputDir) = 0 then - set theOutputDir to modelFolderPath - else - copy modelFolderPath & "/" & theOutputDir to theOutputDir - end if - end if - - end tell - - - -- if theHumanDir is empty, use theOutputDir value instead, if theHumanDir not empty and it isn't a full path, then treat it as a relative path to theOutputDir - if (length of theHumanDir) = 0 then - set theHumanDir to theOutputDir - else if theHumanDir does not start with "/" then - copy theOutputDir & "/" & theHumanDir to theHumanDir - end if - - -- if theMachineDir is empty, use theOutputDir value instead, if theMachineDir not empty and it isn't a full path, then treat it as a relative path to theOutputDir - if (length of theMachineDir) = 0 then - set theMachineDir to theOutputDir - else if theMachineDir does not start with "/" then - copy theOutputDir & "/" & theMachineDir to theMachineDir - end if - - -- ensure the directories exist - do shell script "mkdir -p '" & theHumanDir & "'" - do shell script "mkdir -p '" & theMachineDir & "'" - - -- the following should resolve any symlinks, '..', or '~' in the paths - tell application "System Events" - set dirAlias to POSIX file theHumanDir as alias - set theHumanDir to (POSIX path of (dirAlias as alias)) - set dirAlias to POSIX file theMachineDir as alias - set theMachineDir to (POSIX path of (dirAlias as alias)) - end tell - - return {name:modelName, isBundle:isModelBundle, machineDirPath:theMachineDir, humanDirPath:theHumanDir} - -end getModelInfo - -on logger(msg) - do shell script "logger '" & msg & "'" -end logger - -on addFilesFromPathToGroup(_project, modelItr, groupRef) - tell application "Xcode" - -- get the full path of the directory that the groupRef represents - set groupPath to full path of groupRef - - -- Build a list of source files in the group's directory - tell application "System Events" - set modelSrcDirAlias to POSIX file groupPath as alias - set fileList to (every file of modelSrcDirAlias whose (name ends with ".m" or name ends with ".mm" or name ends with ".h")) - set pathList to {} - repeat with fileItem in fileList - set pathList to pathList & POSIX path of fileItem - end repeat - end tell - - -- Add the source files to the group and the model's targets, but only if they don't exist already - set targetList to null - repeat with pathItr in pathList - tell groupRef - set fileRefs to (every file reference of _project whose full path is pathItr) - if (count of fileRefs) = 0 then - set modelSrcFileRef to make new file reference with properties {full path:pathItr, name:name of (info for POSIX file pathItr)} - if targetList is null then - set targetList to my everyTargetWithBuildFilePath(_project, full path of modelItr) - end if - repeat with targetIndex from 1 to (count of targetList) - set targetItr to item targetIndex of targetList - add modelSrcFileRef to targetItr - end repeat - end if - end tell - end repeat - end tell -end addFilesFromPathToGroup diff --git a/Xmod/Xmod.h b/Xmod/Xmod.h deleted file mode 100644 index e13c7e8d..00000000 --- a/Xmod/Xmod.h +++ /dev/null @@ -1,11 +0,0 @@ -#import -#import - -@interface Xmod : NSObject { - NSBundle *bundle; -} -+ (id)sharedXmod; -- (id)initWithBundle:(NSBundle*)bundle_; -- (IBAction)autocustomizeEntityClasses:(id)sender_; -- (void)runScriptNamed:(NSString*)scriptName_; -@end \ No newline at end of file diff --git a/Xmod/Xmod.m b/Xmod/Xmod.m deleted file mode 100644 index 35b22679..00000000 --- a/Xmod/Xmod.m +++ /dev/null @@ -1,118 +0,0 @@ -#import "Xmod.h" -#import "JRSwizzle.h" - -/* -Xcode 2.4 - 10.4 SDK ppc, i386 -Xcode 2.5 - 10.5 SDK ppc, i386 -Xcode 3.0 - 10.5 SDK ppc GC, ppc64 GC, i386 GC, x86_64 GC -Xcode 3.2 - 10.6 SDK i386 GC, x86_64 GC -*/ - -@interface NSObject (xmod_saveModelToFile) -@end -@implementation NSObject (xmod_saveModelToFile) -- (BOOL)xmod_saveModelToFile:(NSString*)modelPackagePath_ { - BOOL result = [self xmod_saveModelToFile:modelPackagePath_]; - if (result) - [[Xmod sharedXmod] performSelector:@selector(runScriptNamed:) withObject:@"Xmod" afterDelay:0.0]; - return result; -} -@end - -@implementation Xmod - -Xmod *gSharedXmod; - -+ (void)pluginDidLoad:(NSBundle*)bundle_ { - gSharedXmod = [[self alloc] initWithBundle:bundle_]; -} - -+ (id)sharedXmod { - return gSharedXmod; -} - -- (id)initWithBundle:(NSBundle*)bundle_ { - self = [super init]; - if (self) { - bundle = [bundle_ retain]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(applicationDidFinishLaunching:) - name:NSApplicationDidFinishLaunchingNotification - object:nil]; - } - return self; -} - -- (void)applicationDidFinishLaunching:(NSNotification*)notification_ { - // Force loading of the Core Data XDesign plugin so we can find the class to swizzle its instance method. - NSBundle *coreDataPlugin = nil; - - NSString *xcodeVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; - NSAssert(xcodeVersion, @"failed to read Xcode version"); - if ([xcodeVersion isEqualToString:@"2.4"]) { - coreDataPlugin = [NSBundle bundleWithPath:@"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin"]; - } else if ([xcodeVersion isEqualToString:@"2.5"]) { - coreDataPlugin = [NSBundle bundleWithPath:@"/Xcode2.5/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin"]; - } else if ([xcodeVersion isEqualToString:@"3.0"] || [xcodeVersion hasPrefix:@"3.1"] || [xcodeVersion hasPrefix:@"3.2"]) { - coreDataPlugin = [NSBundle bundleWithPath:@"/Developer/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin"]; - } else { - NSLog(@"Xmod: unknown Xcode version (%@), not loading.", xcodeVersion); - return; - } - NSAssert(coreDataPlugin, @"failed to load XDCoreDataModel.xdplugin"); - [coreDataPlugin load]; - - Class persistenceDocumentController = NSClassFromString(@"XDPersistenceDocumentController"); - NSAssert(persistenceDocumentController, @"failed to load XDPersistenceDocumentController"); - - NSError *error = nil; - BOOL swizzled = [persistenceDocumentController jr_swizzleMethod:@selector(saveModelToFile:) - withMethod:@selector(xmod_saveModelToFile:) - error:&error]; - NSAssert1(swizzled, @"failed to swizzle -[XDPersistenceDocumentController saveModelToFile:]: %@", error); - - // Install the Autocustomize menu item. - NSMenu *designMenu = [[[NSApp mainMenu] itemWithTitle:@"Design"] submenu]; - NSMenu *dataModelMenu = [[designMenu itemWithTitle:@"Data Model"] submenu]; - - NSMenuItem *myMenuItem = [dataModelMenu insertItemWithTitle:@"Autocustomize Entity Classes" - action:@selector(autocustomizeEntityClasses:) - keyEquivalent:@"" - atIndex:0]; - [myMenuItem setTarget:self]; -} - -- (IBAction)autocustomizeEntityClasses:(id)sender_ { - [self runScriptNamed:@"Autocustomize Entity Classes"]; -} - -- (void)runScriptNamed:(NSString*)scriptName_ { - NSString *scriptPath = [bundle pathForResource:scriptName_ ofType:@"scpt" inDirectory:@"Scripts"]; - NSAssert1(scriptPath, @"failed to find %@.scpt", scriptName_); -#if 1 - NSTask *osascriptTask = [[[NSTask alloc] init] autorelease]; - [osascriptTask setLaunchPath:@"/usr/bin/osascript"]; - [osascriptTask setArguments:[NSArray arrayWithObject:scriptPath]]; - [osascriptTask launch]; -#else - // Executing an AppleScript inside Xcode's context is weird. - // Scripts like `tell app "Finder" to get folder of file` simply fail. I suspect rogue - // coercion handlers or namespace bugs. So now I just fire off an osascript invocation - // to give the script a clean nonweird enironment. - NSDictionary *scriptInitError = nil; - NSAppleScript *script = [[[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:scriptPath] - error:&scriptInitError] autorelease]; - NSAssert2(!scriptInitError, @"failed to init %@.scpt: %@", scriptName_, scriptInitError); - if (!scriptInitError) { - NSDictionary *scriptExecuteError = nil; - [script executeAndReturnError:&scriptExecuteError]; - NSAssert2(!scriptInitError, @"failed to execute %@.scpt: %@", scriptName_, scriptExecuteError); - } -#endif -} - -@end diff --git a/Xmod/Xmod.xcodeproj/project.pbxproj b/Xmod/Xmod.xcodeproj/project.pbxproj deleted file mode 100644 index c209e69f..00000000 --- a/Xmod/Xmod.xcodeproj/project.pbxproj +++ /dev/null @@ -1,304 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 42; - objects = { - -/* Begin PBXAppleScriptBuildPhase section */ - 79D150FC0C8FBDF9006706AF /* AppleScript */ = { - isa = PBXAppleScriptBuildPhase; - buildActionMask = 2147483647; - contextName = ""; - files = ( - 79D150FE0C8FBE01006706AF /* Xmod.applescript in AppleScript */, - 79F8A9C30C8FF06700082291 /* Autocustomize Entity Classes.applescript in AppleScript */, - ); - isSharedContext = 0; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXAppleScriptBuildPhase section */ - -/* Begin PBXBuildFile section */ - 79D150FE0C8FBE01006706AF /* Xmod.applescript in AppleScript */ = {isa = PBXBuildFile; fileRef = 79D150FA0C8FBDE9006706AF /* Xmod.applescript */; settings = {ATTRIBUTES = (Debug, ); }; }; - 79DFC11F0B59B8C80056C80E /* Xmod.m in Sources */ = {isa = PBXBuildFile; fileRef = 79DFC11E0B59B8C80056C80E /* Xmod.m */; }; - 79E65E0D0D5631EA00B09941 /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 79E65E0B0D5631EA00B09941 /* JRSwizzle.m */; }; - 79F8A9C30C8FF06700082291 /* Autocustomize Entity Classes.applescript in AppleScript */ = {isa = PBXBuildFile; fileRef = 79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */; settings = {ATTRIBUTES = (Debug, ); }; }; - 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; }; - 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 32DBCF630370AF2F00C91783 /* Xmod_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xmod_Prefix.pch; sourceTree = ""; }; - 79D150FA0C8FBDE9006706AF /* Xmod.applescript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.applescript; path = Xmod.applescript; sourceTree = ""; }; - 79DFC11D0B59B8C80056C80E /* Xmod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Xmod.h; sourceTree = ""; }; - 79DFC11E0B59B8C80056C80E /* Xmod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Xmod.m; sourceTree = ""; }; - 79E65E0B0D5631EA00B09941 /* JRSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JRSwizzle.m; path = JRSwizzle/JRSwizzle.m; sourceTree = ""; }; - 79E65E0C0D5631EA00B09941 /* JRSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JRSwizzle.m; path = JRSwizzle/JRSwizzle.m; sourceTree = ""; }; - 79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.applescript; path = "Autocustomize Entity Classes.applescript"; sourceTree = ""; }; - 8D5B49B6048680CD000E48DA /* Xmod.pbplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Xmod.pbplugin; sourceTree = BUILT_PRODUCTS_DIR; }; - 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D5B49B3048680CD000E48DA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 089C166AFE841209C02AAC07 /* Xmod */ = { - isa = PBXGroup; - children = ( - 08FB77AFFE84173DC02AAC07 /* Classes */, - 32C88E010371C26100C91783 /* Other Sources */, - 089C167CFE841241C02AAC07 /* Resources */, - 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, - 19C28FB8FE9D52D311CA2CBB /* Products */, - ); - name = Xmod; - sourceTree = ""; - }; - 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { - isa = PBXGroup; - children = ( - 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, - 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, - ); - name = "Frameworks and Libraries"; - sourceTree = ""; - }; - 089C167CFE841241C02AAC07 /* Resources */ = { - isa = PBXGroup; - children = ( - 8D5B49B7048680CD000E48DA /* Info.plist */, - 089C167DFE841241C02AAC07 /* InfoPlist.strings */, - 79D150FA0C8FBDE9006706AF /* Xmod.applescript */, - 79F8A9C20C8FF06600082291 /* Autocustomize Entity Classes.applescript */, - ); - name = Resources; - sourceTree = ""; - }; - 08FB77AFFE84173DC02AAC07 /* Classes */ = { - isa = PBXGroup; - children = ( - 79DFC11D0B59B8C80056C80E /* Xmod.h */, - 79DFC11E0B59B8C80056C80E /* Xmod.m */, - 79E65E0C0D5631EA00B09941 /* JRSwizzle.m */, - 79E65E0B0D5631EA00B09941 /* JRSwizzle.m */, - ); - name = Classes; - sourceTree = ""; - }; - 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { - isa = PBXGroup; - children = ( - 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, - ); - name = "Linked Frameworks"; - sourceTree = ""; - }; - 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - 089C167FFE841241C02AAC07 /* AppKit.framework */, - D2F7E65807B2D6F200F64583 /* CoreData.framework */, - 089C1672FE841209C02AAC07 /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; - 19C28FB8FE9D52D311CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8D5B49B6048680CD000E48DA /* Xmod.pbplugin */, - ); - name = Products; - sourceTree = ""; - }; - 32C88E010371C26100C91783 /* Other Sources */ = { - isa = PBXGroup; - children = ( - 32DBCF630370AF2F00C91783 /* Xmod_Prefix.pch */, - ); - name = "Other Sources"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8D5B49AC048680CD000E48DA /* Xmod */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Xmod" */; - buildPhases = ( - 79D150FC0C8FBDF9006706AF /* AppleScript */, - 8D5B49AF048680CD000E48DA /* Resources */, - 8D5B49B1048680CD000E48DA /* Sources */, - 8D5B49B3048680CD000E48DA /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Xmod; - productInstallPath = "$(HOME)/Library/Bundles"; - productName = Xmod; - productReference = 8D5B49B6048680CD000E48DA /* Xmod.pbplugin */; - productType = "com.apple.product-type.bundle"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 089C1669FE841209C02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Xmod" */; - compatibilityVersion = "Xcode 2.4"; - hasScannedForEncodings = 1; - mainGroup = 089C166AFE841209C02AAC07 /* Xmod */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 8D5B49AC048680CD000E48DA /* Xmod */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8D5B49AF048680CD000E48DA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D5B49B1048680CD000E48DA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 79DFC11F0B59B8C80056C80E /* Xmod.m in Sources */, - 79E65E0D0D5631EA00B09941 /* JRSwizzle.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 089C167DFE841241C02AAC07 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 089C167EFE841241C02AAC07 /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 1DEB913B08733D840010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - x86_64, - ); - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Xmod_Prefix.pch; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Library/Bundles"; - PRODUCT_NAME = Xmod; - WRAPPER_EXTENSION = pbplugin; - }; - name = Debug; - }; - 1DEB913C08733D840010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - x86_64, - ); - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = Xmod_Prefix.pch; - INFOPLIST_FILE = Info.plist; - INSTALL_PATH = "$(HOME)/Library/Bundles"; - PRODUCT_NAME = Xmod; - WRAPPER_EXTENSION = pbplugin; - }; - name = Release; - }; - 1DEB913F08733D840010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)"; - GCC_ENABLE_OBJC_GC = YES; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH_ACTUAL)"; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk"; - }; - name = Debug; - }; - 1DEB914008733D840010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)"; - ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc"; - GCC_ENABLE_OBJC_GC = YES; - GCC_VERSION = ""; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Xmod" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB913B08733D840010E9CD /* Debug */, - 1DEB913C08733D840010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Xmod" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB913F08733D840010E9CD /* Debug */, - 1DEB914008733D840010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 089C1669FE841209C02AAC07 /* Project object */; -} diff --git a/Xmod/Xmod.xcodeproj/wolf.mode1 b/Xmod/Xmod.xcodeproj/wolf.mode1 deleted file mode 100644 index 0e93aa0c..00000000 --- a/Xmod/Xmod.xcodeproj/wolf.mode1 +++ /dev/null @@ -1,1414 +0,0 @@ - - - - - ActivePerspectiveName - Project - AllowedModules - - - BundleLoadPath - - MaxInstances - n - Module - PBXSmartGroupTreeModule - Name - Groups and Files Outline View - - - BundleLoadPath - - MaxInstances - n - Module - PBXNavigatorGroup - Name - Editor - - - BundleLoadPath - - MaxInstances - n - Module - XCTaskListModule - Name - Task List - - - BundleLoadPath - - MaxInstances - n - Module - XCDetailModule - Name - File and Smart Group Detail Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXBuildResultsModule - Name - Detailed Build Results Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXProjectFindModule - Name - Project Batch Find Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXRunSessionModule - Name - Run Log - - - BundleLoadPath - - MaxInstances - n - Module - PBXBookmarksModule - Name - Bookmarks Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXClassBrowserModule - Name - Class Browser - - - BundleLoadPath - - MaxInstances - n - Module - PBXCVSModule - Name - Source Code Control Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXDebugBreakpointsModule - Name - Debug Breakpoints Tool - - - BundleLoadPath - - MaxInstances - n - Module - XCDockableInspector - Name - Inspector - - - BundleLoadPath - - MaxInstances - n - Module - PBXOpenQuicklyModule - Name - Open Quickly Tool - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugSessionModule - Name - Debugger - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugCLIModule - Name - Debug Console - - - Description - DefaultDescriptionKey - DockingSystemVisible - - Extension - mode1 - FavBarConfig - - PBXProjectModuleGUID - 79DFC1160B59B8870056C80E - XCBarModuleItemNames - - XCBarModuleItems - - - FirstTimeWindowDisplayed - - Identifier - com.apple.perspectives.project.mode1 - MajorVersion - 31 - MinorVersion - 1 - Name - Default - Notifications - - OpenEditors - - - Content - - PBXProjectModuleGUID - 7907BA1F0CED0E23003A8BA0 - PBXProjectModuleLabel - Xmod.m - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 7907BA200CED0E23003A8BA0 - PBXProjectModuleLabel - Xmod.m - _historyCapacity - 0 - bookmark - 794C2E670CF0CA330003EC27 - history - - 79A7D2BE0CF0C56F00193A80 - - - SplitCount - 1 - - StatusBarVisibility - - - Geometry - - Frame - {{0, 20}, {921, 831}} - PBXModuleWindowStatusBarHidden2 - - RubberWindowFrame - 396 144 921 872 0 0 1680 1028 - - - - Content - - PBXProjectModuleGUID - 798EFBDB0CF0B4980090D926 - PBXProjectModuleLabel - Xmod.h - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 798EFBDC0CF0B4980090D926 - PBXProjectModuleLabel - Xmod.h - _historyCapacity - 0 - bookmark - 794C2E680CF0CA330003EC27 - history - - 794C2E520CF0CA070003EC27 - - - SplitCount - 1 - - StatusBarVisibility - - - Geometry - - Frame - {{0, 20}, {743, 597}} - PBXModuleWindowStatusBarHidden2 - - RubberWindowFrame - 896 377 743 638 0 0 1680 1028 - - - - PerspectiveWidths - - -1 - -1 - - Perspectives - - - ChosenToolbarItems - - active-target-popup - active-buildstyle-popup - action - NSToolbarFlexibleSpaceItem - buildOrClean - build-and-runOrDebug - com.apple.ide.PBXToolbarStopButton - get-info - toggle-editor - NSToolbarFlexibleSpaceItem - com.apple.pbx.toolbar.searchfield - - ControllerClassBaseName - - IconName - WindowOfProjectWithEditor - Identifier - perspective.project - IsVertical - - Layout - - - BecomeActive - - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C08E77C0454961000C914BD - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 089C166AFE841209C02AAC07 - 08FB77AFFE84173DC02AAC07 - 089C167CFE841241C02AAC07 - 19C28FB8FE9D52D311CA2CBB - 1C37FBAC04509CD000000102 - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 14 - 13 - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 412}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 430}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 536 535 853 471 0 0 1680 1028 - - Module - PBXSmartGroupTreeModule - Proportion - 203pt - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20306471E060097A5F4 - PBXProjectModuleLabel - MyNewFile14.java - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CE0B20406471E060097A5F4 - PBXProjectModuleLabel - MyNewFile14.java - - SplitCount - 1 - - StatusBarVisibility - - - GeometryConfiguration - - Frame - {{0, 0}, {645, 0}} - RubberWindowFrame - 536 535 853 471 0 0 1680 1028 - - Module - PBXNavigatorGroup - Proportion - 0pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20506471E060097A5F4 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{0, 5}, {645, 425}} - RubberWindowFrame - 536 535 853 471 0 0 1680 1028 - - Module - XCDetailModule - Proportion - 425pt - - - Proportion - 645pt - - - Name - Project - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - XCModuleDock - PBXNavigatorGroup - XCDetailModule - - TableOfContents - - 794C2E4B0CF0C61A0003EC27 - 1CE0B1FE06471DED0097A5F4 - 794C2E4C0CF0C61A0003EC27 - 1CE0B20306471E060097A5F4 - 1CE0B20506471E060097A5F4 - - ToolbarConfiguration - xcode.toolbar.config.default - - - ControllerClassBaseName - - IconName - WindowOfProject - Identifier - perspective.morph - IsVertical - 0 - Layout - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C08E77C0454961000C914BD - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 11E0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 29B97314FDCFA39411CA2CEA - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 337}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 1 - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 355}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 373 269 690 397 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 100% - - - Name - Morph - PreferredWidth - 300 - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - - TableOfContents - - 11E0B1FE06471DED0097A5F4 - - ToolbarConfiguration - xcode.toolbar.config.default.short - - - PerspectivesBarVisible - - ShelfIsVisible - - SourceDescription - file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecificationMode1.xcperspec' - StatusbarIsVisible - - TimeStamp - 0.0 - ToolbarDisplayMode - 2 - ToolbarIsVisible - - ToolbarSizeMode - 2 - Type - Perspectives - UpdateMessage - The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? - WindowJustification - 5 - WindowOrderList - - 79DFC1390B59BFE80056C80E - 798EFBDB0CF0B4980090D926 - 7907BA1F0CED0E23003A8BA0 - /Users/wolf/code/sf/redshed/cocoa/mogenerator/Xmod/Xmod.xcodeproj - - WindowString - 536 535 853 471 0 0 1680 1028 - WindowTools - - - FirstTimeWindowDisplayed - - Identifier - windowTool.build - IsVertical - - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528F0623707200166675 - PBXProjectModuleLabel - - StatusBarVisibility - - - GeometryConfiguration - - Frame - {{0, 0}, {500, 218}} - RubberWindowFrame - 36 501 500 500 0 0 1680 1028 - - Module - PBXNavigatorGroup - Proportion - 218pt - - - ContentConfiguration - - PBXProjectModuleGUID - XCMainBuildResultsModuleGUID - PBXProjectModuleLabel - Build - XCBuildResultsTrigger_Collapse - 1021 - XCBuildResultsTrigger_Open - 1011 - - GeometryConfiguration - - Frame - {{0, 223}, {500, 236}} - RubberWindowFrame - 36 501 500 500 0 0 1680 1028 - - Module - PBXBuildResultsModule - Proportion - 236pt - - - Proportion - 459pt - - - Name - Build Results - ServiceClasses - - PBXBuildResultsModule - - StatusbarIsVisible - - TableOfContents - - 79DFC1390B59BFE80056C80E - 794C2E540CF0CA070003EC27 - 1CD0528F0623707200166675 - XCMainBuildResultsModuleGUID - - ToolbarConfiguration - xcode.toolbar.config.build - WindowString - 36 501 500 500 0 0 1680 1028 - WindowToolGUID - 79DFC1390B59BFE80056C80E - WindowToolIsVisible - - - - Identifier - windowTool.debugger - Layout - - - Dock - - - ContentConfiguration - - Debugger - - HorizontalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {317, 164}} - {{317, 0}, {377, 164}} - - - VerticalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {694, 164}} - {{0, 164}, {694, 216}} - - - - LauncherConfigVersion - 8 - PBXProjectModuleGUID - 1C162984064C10D400B95A72 - PBXProjectModuleLabel - Debug - GLUTExamples (Underwater) - - GeometryConfiguration - - DebugConsoleDrawerSize - {100, 120} - DebugConsoleVisible - None - DebugConsoleWindowFrame - {{200, 200}, {500, 300}} - DebugSTDIOWindowFrame - {{200, 200}, {500, 300}} - Frame - {{0, 0}, {694, 380}} - RubberWindowFrame - 321 238 694 422 0 0 1440 878 - - Module - PBXDebugSessionModule - Proportion - 100% - - - Proportion - 100% - - - Name - Debugger - ServiceClasses - - PBXDebugSessionModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CD10A99069EF8BA00B06720 - 1C0AD2AB069F1E9B00FABCE6 - 1C162984064C10D400B95A72 - 1C0AD2AC069F1E9B00FABCE6 - - ToolbarConfiguration - xcode.toolbar.config.debug - WindowString - 321 238 694 422 0 0 1440 878 - WindowToolGUID - 1CD10A99069EF8BA00B06720 - WindowToolIsVisible - 0 - - - Identifier - windowTool.find - Layout - - - Dock - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CDD528C0622207200134675 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CD0528D0623707200166675 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {781, 167}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXNavigatorGroup - Proportion - 781pt - - - Proportion - 50% - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528E0623707200166675 - PBXProjectModuleLabel - Project Find - - GeometryConfiguration - - Frame - {{8, 0}, {773, 254}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXProjectFindModule - Proportion - 50% - - - Proportion - 428pt - - - Name - Project Find - ServiceClasses - - PBXProjectFindModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C530D57069F1CE1000CFCEE - 1C530D58069F1CE1000CFCEE - 1C530D59069F1CE1000CFCEE - 1CDD528C0622207200134675 - 1C530D5A069F1CE1000CFCEE - 1CE0B1FE06471DED0097A5F4 - 1CD0528E0623707200166675 - - WindowString - 62 385 781 470 0 0 1440 878 - WindowToolGUID - 1C530D57069F1CE1000CFCEE - WindowToolIsVisible - 0 - - - Identifier - MENUSEPARATOR - - - Identifier - windowTool.debuggerConsole - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAAC065D492600B07095 - PBXProjectModuleLabel - Debugger Console - - GeometryConfiguration - - Frame - {{0, 0}, {440, 358}} - RubberWindowFrame - 650 41 440 400 0 0 1280 1002 - - Module - PBXDebugCLIModule - Proportion - 358pt - - - Proportion - 358pt - - - Name - Debugger Console - ServiceClasses - - PBXDebugCLIModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAAD065D492600B07095 - 1C78EAAE065D492600B07095 - 1C78EAAC065D492600B07095 - - WindowString - 650 41 440 400 0 0 1280 1002 - - - Identifier - windowTool.run - Layout - - - Dock - - - ContentConfiguration - - LauncherConfigVersion - 3 - PBXProjectModuleGUID - 1CD0528B0623707200166675 - PBXProjectModuleLabel - Run - Runner - - HorizontalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {493, 167}} - {{0, 176}, {493, 267}} - - - VerticalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {405, 443}} - {{414, 0}, {514, 443}} - - - - - GeometryConfiguration - - Frame - {{0, 0}, {460, 159}} - RubberWindowFrame - 316 696 459 200 0 0 1280 1002 - - Module - PBXRunSessionModule - Proportion - 159pt - - - Proportion - 159pt - - - Name - Run Log - ServiceClasses - - PBXRunSessionModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C0AD2B3069F1EA900FABCE6 - 1C0AD2B4069F1EA900FABCE6 - 1CD0528B0623707200166675 - 1C0AD2B5069F1EA900FABCE6 - - ToolbarConfiguration - xcode.toolbar.config.run - WindowString - 316 696 459 200 0 0 1280 1002 - WindowToolGUID - 1C0AD2B3069F1EA900FABCE6 - WindowToolIsVisible - 0 - - - Identifier - windowTool.scm - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAB2065D492600B07095 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1C78EAB3065D492600B07095 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {452, 0}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - - Module - PBXNavigatorGroup - Proportion - 0pt - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD052920623707200166675 - PBXProjectModuleLabel - SCM - - GeometryConfiguration - - ConsoleFrame - {{0, 259}, {452, 0}} - Frame - {{0, 7}, {452, 259}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - TableConfiguration - - Status - 30 - FileName - 199 - Path - 197.09500122070312 - - TableFrame - {{0, 0}, {452, 250}} - - Module - PBXCVSModule - Proportion - 262pt - - - Proportion - 266pt - - - Name - SCM - ServiceClasses - - PBXCVSModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAB4065D492600B07095 - 1C78EAB5065D492600B07095 - 1C78EAB2065D492600B07095 - 1CD052920623707200166675 - - ToolbarConfiguration - xcode.toolbar.config.scm - WindowString - 743 379 452 308 0 0 1280 1002 - - - Identifier - windowTool.breakpoints - IsVertical - 0 - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C77FABC04509CD000000102 - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - no - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 168 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 1C77FABC04509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {168, 350}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 0 - - GeometryConfiguration - - Frame - {{0, 0}, {185, 368}} - GroupTreeTableConfiguration - - MainColumn - 168 - - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 185pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CA1AED706398EBD00589147 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{190, 0}, {554, 368}} - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - XCDetailModule - Proportion - 554pt - - - Proportion - 368pt - - - MajorVersion - 2 - MinorVersion - 0 - Name - Breakpoints - ServiceClasses - - PBXSmartGroupTreeModule - XCDetailModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CDDB66807F98D9800BB5817 - 1CDDB66907F98D9800BB5817 - 1CE0B1FE06471DED0097A5F4 - 1CA1AED706398EBD00589147 - - ToolbarConfiguration - xcode.toolbar.config.breakpoints - WindowString - 315 424 744 409 0 0 1440 878 - WindowToolGUID - 1CDDB66807F98D9800BB5817 - WindowToolIsVisible - 1 - - - Identifier - windowTool.debugAnimator - Layout - - - Dock - - - Module - PBXNavigatorGroup - Proportion - 100% - - - Proportion - 100% - - - Name - Debug Visualizer - ServiceClasses - - PBXNavigatorGroup - - StatusbarIsVisible - 1 - ToolbarConfiguration - xcode.toolbar.config.debugAnimator - WindowString - 100 100 700 500 0 0 1280 1002 - - - Identifier - windowTool.bookmarks - Layout - - - Dock - - - Module - PBXBookmarksModule - Proportion - 100% - - - Proportion - 100% - - - Name - Bookmarks - ServiceClasses - - PBXBookmarksModule - - StatusbarIsVisible - 0 - WindowString - 538 42 401 187 0 0 1280 1002 - - - Identifier - windowTool.classBrowser - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - OptionsSetName - Hierarchy, all classes - PBXProjectModuleGUID - 1CA6456E063B45B4001379D8 - PBXProjectModuleLabel - Class Browser - NSObject - - GeometryConfiguration - - ClassesFrame - {{0, 0}, {374, 96}} - ClassesTreeTableConfiguration - - PBXClassNameColumnIdentifier - 208 - PBXClassBookColumnIdentifier - 22 - - Frame - {{0, 0}, {630, 331}} - MembersFrame - {{0, 105}, {374, 395}} - MembersTreeTableConfiguration - - PBXMemberTypeIconColumnIdentifier - 22 - PBXMemberNameColumnIdentifier - 216 - PBXMemberTypeColumnIdentifier - 97 - PBXMemberBookColumnIdentifier - 22 - - PBXModuleWindowStatusBarHidden2 - 1 - RubberWindowFrame - 385 179 630 352 0 0 1440 878 - - Module - PBXClassBrowserModule - Proportion - 332pt - - - Proportion - 332pt - - - Name - Class Browser - ServiceClasses - - PBXClassBrowserModule - - StatusbarIsVisible - 0 - TableOfContents - - 1C0AD2AF069F1E9B00FABCE6 - 1C0AD2B0069F1E9B00FABCE6 - 1CA6456E063B45B4001379D8 - - ToolbarConfiguration - xcode.toolbar.config.classbrowser - WindowString - 385 179 630 352 0 0 1440 878 - WindowToolGUID - 1C0AD2AF069F1E9B00FABCE6 - WindowToolIsVisible - 0 - - - - diff --git a/Xmod/Xmod_Prefix.pch b/Xmod/Xmod_Prefix.pch deleted file mode 100644 index 468286f0..00000000 --- a/Xmod/Xmod_Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'Xmod' target in the 'Xmod' project. -// - -#ifdef __OBJC__ - #import -#endif diff --git a/build-mogenerator-Info-plist.sh b/build-mogenerator-Info-plist.sh index 6d4284ca..0bd7e55f 100644 --- a/build-mogenerator-Info-plist.sh +++ b/build-mogenerator-Info-plist.sh @@ -1,4 +1,5 @@ -rm -f $TMPDIR/mogenerator-Info.plist +TMPDIR=${DERIVED_FILE_DIR} +rm -f "${TMPDIR}/mogenerator-Info.plist" /usr/libexec/PlistBuddy \ -c "Clear" \ -c "Import :human.h.motemplate templates/human.h.motemplate" \ @@ -7,4 +8,4 @@ rm -f $TMPDIR/mogenerator-Info.plist -c "Import :machine.h.motemplate templates/machine.h.motemplate" \ -c "Import :machine.m.motemplate templates/machine.m.motemplate" \ -c "Import :machine.swift.motemplate templates/machine.swift.motemplate" \ - $TMPDIR/mogenerator-Info.plist + "${TMPDIR}/mogenerator-Info.plist" diff --git a/categories/NSString+MORegEx.h b/categories/NSString+MORegEx.h new file mode 100644 index 00000000..cf1aece1 --- /dev/null +++ b/categories/NSString+MORegEx.h @@ -0,0 +1,13 @@ +@import Foundation; + +NS_ASSUME_NONNULL_BEGIN +@interface NSString (MORegEx) + +- (NSArray *)captureComponentsMatchedByRegex:(NSString *)pattern; + +- (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)pattern withString:(NSString *)replacementString; + +- (BOOL)isMatchedByRegex:(NSString *)pattern; + +@end +NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/categories/NSString+MORegEx.m b/categories/NSString+MORegEx.m new file mode 100644 index 00000000..cedabbbc --- /dev/null +++ b/categories/NSString+MORegEx.m @@ -0,0 +1,28 @@ +#import "NSString+MORegEx.h" + +@implementation NSString (MORegEx) + +- (NSArray *)captureComponentsMatchedByRegex:(NSString *)pattern +{ + NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; + + return [regex matchesInString:self options:0 range:NSMakeRange(0, [self length])]; +} + +- (NSString *)stringByReplacingOccurrencesOfRegex:(NSString *)pattern withString:(NSString *)replacementString +{ + NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; + + NSString *updatedString = [regex stringByReplacingMatchesInString:self options:0 range:NSMakeRange(0, [self length]) withTemplate:replacementString]; + return updatedString; +} + +- (BOOL)isMatchedByRegex:(NSString *)pattern +{ + NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:0 error:nil]; + + NSUInteger matchCount = [regex numberOfMatchesInString:self options:0 range:NSMakeRange(0, [self length])]; + return (matchCount > 0); +} + +@end diff --git a/ddcli/DDCliApplication.m b/ddcli/DDCliApplication.m index 40d33023..12ce324d 100644 --- a/ddcli/DDCliApplication.m +++ b/ddcli/DDCliApplication.m @@ -39,7 +39,7 @@ + (DDCliApplication *) sharedApplication; return DDCliApp; } -- (id) init; +- (instancetype) init; { self = [super init]; if (self == nil) diff --git a/ddcli/DDCliParseException.h b/ddcli/DDCliParseException.h index 603cf728..a07b20ba 100644 --- a/ddcli/DDCliParseException.h +++ b/ddcli/DDCliParseException.h @@ -22,7 +22,7 @@ * SOFTWARE. */ -#import +@import Foundation; /** @@ -52,7 +52,7 @@ * @param exitCode Desired exit code * @return New exception */ -- (id) initWithReason: (NSString *) reason +- (instancetype) initWithReason: (NSString *) reason exitCode: (int) exitCode; /** diff --git a/ddcli/DDCliParseException.m b/ddcli/DDCliParseException.m index b1f823ce..2926edfa 100644 --- a/ddcli/DDCliParseException.m +++ b/ddcli/DDCliParseException.m @@ -34,7 +34,7 @@ + (DDCliParseException *) parseExceptionWithReason: (NSString *) reason exitCode: exitCode] autorelease]; } -- (id) initWithReason: (NSString *) reason +- (instancetype) initWithReason: (NSString *) reason exitCode: (int) exitCode; { self = [super initWithName: NSStringFromClass([self class]) diff --git a/ddcli/DDCliUtil.h b/ddcli/DDCliUtil.h index de513f98..d35a5c20 100644 --- a/ddcli/DDCliUtil.h +++ b/ddcli/DDCliUtil.h @@ -22,7 +22,7 @@ * SOFTWARE. */ -#import +@import Foundation; /** * @ingroup functions diff --git a/ddcli/DDCommandLineInterface.h b/ddcli/DDCommandLineInterface.h index 66e88277..a504d626 100644 --- a/ddcli/DDCommandLineInterface.h +++ b/ddcli/DDCommandLineInterface.h @@ -23,7 +23,7 @@ */ -#import +@import Foundation; #import #import "DDGetoptLongParser.h" diff --git a/ddcli/DDGetoptLongParser.h b/ddcli/DDGetoptLongParser.h index f37a0922..575f4989 100644 --- a/ddcli/DDGetoptLongParser.h +++ b/ddcli/DDGetoptLongParser.h @@ -100,7 +100,7 @@ typedef struct * * @param target Object that receives target messages. */ -- (id) initWithTarget: (id) target; +- (instancetype) initWithTarget: (id) target; /** * Returns the target object. diff --git a/ddcli/DDGetoptLongParser.m b/ddcli/DDGetoptLongParser.m index 29d4f3d4..8b803051 100644 --- a/ddcli/DDGetoptLongParser.m +++ b/ddcli/DDGetoptLongParser.m @@ -47,7 +47,7 @@ + (DDGetoptLongParser *) optionsWithTarget: (id) target return [[[self alloc] initWithTarget: target] autorelease]; } -- (id) initWithTarget: (id) target +- (instancetype) initWithTarget: (id) target { self = [super init]; if (self == nil) diff --git a/installer/Info.plist b/installer/Info.plist index 7cd39eab..913085cf 100644 --- a/installer/Info.plist +++ b/installer/Info.plist @@ -3,7 +3,7 @@ CFBundleGetInfoString - VERSION, Copyright © 2006-2012 Jonathan 'Wolf' Rentzsch + VERSION, Copyright © 2006-2015 Jonathan 'Wolf' Rentzsch CFBundleIdentifier com.rentzsch.mogenerator CFBundleShortVersionString diff --git a/installer/make_installer.command b/installer/make_installer.command index 920a80e8..33db9602 100755 --- a/installer/make_installer.command +++ b/installer/make_installer.command @@ -6,13 +6,13 @@ sudo echo sudo rm -rf 'build' cd .. -xcodebuild -configuration Release CONFIGURATION_BUILD_DIR="$PWD/installer/build/root/usr/bin/" +xcodebuild -configuration Release CONFIGURATION_BUILD_DIR="$PWD/installer/build/root/usr/local/bin/" # The standard templates are now integrated into mogenerator's binary itself. # mkdir -p 'build/root/Library/Application Support/mogenerator' # cp templates/*.motemplate "$PWD/installer/build/root/Library/Application Support/mogenerator/" cd installer -VERSION=`build/root/usr/bin/mogenerator --version|head -n 1|sed -E 's/mogenerator ([0-9]+\.[0-9]+(\.[0-9]+)?).+/\1/g'` +VERSION=`build/root/usr/local/bin/mogenerator --version|head -n 1|sed -E 's/mogenerator ([0-9]+\.[0-9]+(\.[0-9]+)?).+/\1/g'` MAJOR_VERSION=`echo $VERSION|sed -E 's/([0-9]+).+/\1/g'` MINOR_VERSION=`echo $VERSION|sed -E 's/[0-9]+\.([0-9]+).*/\1/g'` diff --git a/mogenerator.h b/mogenerator.h index 5b9226e5..2bbe4acc 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -1,16 +1,15 @@ // mogenerator.h -// Copyright (c) 2006-2014 Jonathan 'Wolf' Rentzsch: http://rentzsch.com +// Copyright (c) 2006-2016 Jonathan 'Wolf' Rentzsch: http://rentzsch.com // Some rights reserved: http://opensource.org/licenses/mit // http://github.com/rentzsch/mogenerator -#import -#import +@import Foundation; +@import CoreData; #import "MiscMergeTemplate.h" #import "MiscMergeCommandBlock.h" #import "MiscMergeEngine.h" #import "FoundationAdditions.h" -#import "nsenumerate.h" #import "NSString+MiscAdditions.h" #import "DDCommandLineInterface.h" diff --git a/mogenerator.m b/mogenerator.m index 4a6b819e..95570a53 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -1,20 +1,20 @@ // mogenerator.m -// Copyright (c) 2006-2014 Jonathan 'Wolf' Rentzsch: http://rentzsch.com +// Copyright (c) 2006-2016 Jonathan 'Wolf' Rentzsch: http://rentzsch.com // Some rights reserved: http://opensource.org/licenses/mit // http://github.com/rentzsch/mogenerator #import "mogenerator.h" -#import "RegexKitLite.h" #import "NSManagedObjectModel+momcom.h" +#import "NSString+MORegEx.h" static NSString * const kTemplateVar = @"TemplateVar"; -NSString *gCustomBaseClass; -NSString *gCustomBaseClassImport; -NSString *gCustomBaseClassForced; -BOOL gSwift; +static NSString *gCustomBaseClass; +static NSString *gCustomBaseClassImport; +static NSString *gCustomBaseClassForced; +static BOOL gSwift; -static NSString *const kAttributeValueScalarTypeKey = @"attributeValueScalarType"; -static NSString *const kAdditionalHeaderFileNameKey = @"additionalHeaderFileName"; +static const NSString *const kAttributeValueScalarTypeKey = @"attributeValueScalarType"; +static const NSString *const kAdditionalHeaderFileNameKey = @"additionalHeaderFileName"; @interface NSEntityDescription (fetchedPropertiesAdditions) - (NSDictionary*)fetchedPropertiesByName; @@ -23,17 +23,35 @@ - (NSDictionary*)fetchedPropertiesByName; @implementation NSEntityDescription (fetchedPropertiesAdditions) - (NSDictionary*)fetchedPropertiesByName { NSMutableDictionary *fetchedPropertiesByName = [NSMutableDictionary dictionary]; - - nsenumerate ([self properties], NSPropertyDescription, property) { + + NSArray *properties = [self properties]; + for (NSPropertyDescription *property in properties) + { if ([property isKindOfClass:[NSFetchedPropertyDescription class]]) { [fetchedPropertiesByName setObject:property forKey:[property name]]; } } - + return fetchedPropertiesByName; } @end +@interface NSEntityDescription (swiftAdditions) +- (NSString *)sanitizedManagedObjectClassName; +@end + +@implementation NSEntityDescription (swiftAdditions) + +- (NSString *)sanitizedManagedObjectClassName { + NSString *className = [self managedObjectClassName]; + if ([className hasPrefix:@"."]) { + return [className stringByReplacingOccurrencesOfString:@"." withString:@""]; + } + return className; +} + +@end + @interface NSEntityDescription (userInfoAdditions) - (BOOL)hasUserInfoKeys; - (NSDictionary *)userInfoByKeys; @@ -45,7 +63,7 @@ - (NSDictionary*)sanitizedUserInfo { [validCharacters formUnionWithCharacterSet:[NSCharacterSet decimalDigitCharacterSet]]; [validCharacters addCharactersInString:@"_"]; NSCharacterSet *invalidCharacters = [validCharacters invertedSet]; - + NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:[[self userInfo] count]]; for (NSString *key in self.userInfo) { if ([key rangeOfCharacterFromSet:invalidCharacters].location == NSNotFound) { @@ -54,7 +72,7 @@ - (NSDictionary*)sanitizedUserInfo { [result setObject:value forKey:key]; } } - + return result; } @@ -76,7 +94,7 @@ @implementation NSManagedObjectModel (entitiesWithACustomSubclassVerbose) - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_ verbose:(BOOL)verbose_ { NSMutableArray *result = [NSMutableArray array]; NSArray* allEntities = nil; - + if (nil == configuration_) { allEntities = [self entities]; } @@ -89,24 +107,25 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_ } return nil; } - + if (verbose_ && [allEntities count] == 0){ ddprintf(@"No entities found in model (or in specified configuration). No files will be generated.\n(model description: %@)\n", self); } - - nsenumerate (allEntities, NSEntityDescription, entity) { + + for (NSEntityDescription *entity in allEntities) + { NSString *entityClassName = [entity managedObjectClassName]; - + if ([entity hasCustomClass]){ [result addObject:entity]; } else { if (verbose_) { - ddprintf(@"skipping entity %@ (%@) because it doesn't use a custom subclass.\n", + ddprintf(@"skipping entity %@ (%@) because it doesn't use a custom subclass.\n", entity.name, entityClassName); } } } - + return [result sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"managedObjectClassName" ascending:YES] autorelease]]]; } @@ -151,6 +170,12 @@ - (BOOL)hasCustomSuperentity { } } +- (BOOL)hasCustomSuperclass { + // For Swift, where "override" is needed when both the entity and its superentity have custom classes. + BOOL result = [self hasCustomClass] && [self hasCustomSuperentity] && [[self superentity] hasCustomClass]; + return result; +} + - (BOOL)hasAdditionalHeaderFile { return [[[self userInfo] allKeys] containsObject:kAdditionalHeaderFileNameKey]; } @@ -193,8 +218,9 @@ - (NSString*)additionalHeaderFileName { - (NSArray*)noninheritedAttributesSansType { NSArray *attributeDescriptions = [self noninheritedAttributes]; NSMutableArray *filteredAttributeDescriptions = [NSMutableArray arrayWithCapacity:[attributeDescriptions count]]; - - nsenumerate(attributeDescriptions, NSAttributeDescription, attributeDescription) { + + for (NSAttributeDescription *attributeDescription in attributeDescriptions) + { if ([[attributeDescription name] isEqualToString:@"type"]) { ddprintf(@"WARNING skipping 'type' attribute on %@ (%@) - see https://github.com/rentzsch/mogenerator/issues/74\n", self.name, self.managedObjectClassName); @@ -255,9 +281,12 @@ - (NSDictionary*)fetchRequestTemplates { // If that request is fulfilled, this code won't need to be modified thanks to KVC lookup order magic. // UPDATE: 10.5 now has a public -fetchRequestTemplatesByName method. NSDictionary *fetchRequests = [[self managedObjectModel] valueForKey:@"fetchRequestTemplatesByName"]; - + NSMutableDictionary *result = [NSMutableDictionary dictionaryWithCapacity:[fetchRequests count]]; - nsenumerate ([fetchRequests allKeys], NSString, fetchRequestName) { + + NSArray *keys = [fetchRequests allKeys]; + for (NSString *fetchRequestName in keys) + { NSFetchRequest *fetchRequest = [fetchRequests objectForKey:fetchRequestName]; if ([fetchRequest entity] == self) { [result setObject:fetchRequest forKey:fetchRequestName]; @@ -270,9 +299,10 @@ - (NSString*)_resolveKeyPathType:(NSString*)keyPath { NSArray *components = [keyPath componentsSeparatedByString:@"."]; // Hope the set of keys in the key path consists of solely relationships. Abort otherwise - + NSEntityDescription *entity = self; - nsenumerate(components, NSString, key) { + for (NSString *key in components) + { id property = [[entity propertiesByName] objectForKey:key]; if ([property isKindOfClass:[NSAttributeDescription class]]) { NSString *result = [property objectAttributeType]; @@ -282,7 +312,7 @@ - (NSString*)_resolveKeyPathType:(NSString*)keyPath { } assert(property); } - + return [entity managedObjectClassName]; } @@ -298,9 +328,10 @@ - (BOOL)bindingsArray:(NSArray*)bindings containsVariableNamed:(NSString*)name { - (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_ { if (!predicate_) return; - + if ([predicate_ isKindOfClass:[NSCompoundPredicate class]]) { - nsenumerate([(NSCompoundPredicate*)predicate_ subpredicates], NSPredicate, subpredicate) { + for (NSPredicate *subpredicate in [(NSCompoundPredicate*)predicate_ subpredicates]) + { [self _processPredicate:subpredicate bindings:bindings_]; } } else if ([predicate_ isKindOfClass:[NSComparisonPredicate class]]) { @@ -316,9 +347,9 @@ - (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bin break; case NSVariableExpressionType: { // TODO SHOULD Handle LHS keypaths. - + NSString *type = nil; - + NSAttributeDescription *attribute = [[self attributesByName] objectForKey:[lhs keyPath]]; if (attribute) { type = [attribute objectAttributeClassName]; @@ -344,7 +375,10 @@ - (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bin - (NSArray*)prettyFetchRequests { NSDictionary *fetchRequests = [self fetchRequestTemplates]; NSMutableArray *result = [NSMutableArray arrayWithCapacity:[fetchRequests count]]; - nsenumerate ([fetchRequests allKeys], NSString, fetchRequestName) { + + NSArray *keys = [fetchRequests allKeys]; + for (NSString *fetchRequestName in keys) + { NSFetchRequest *fetchRequest = [fetchRequests objectForKey:fetchRequestName]; NSMutableArray *bindings = [NSMutableArray array]; [self _processPredicate:[fetchRequest predicate] bindings:bindings]; @@ -386,11 +420,11 @@ - (BOOL)hasScalarAttributeType { } } - (NSString*)scalarAttributeType { - + BOOL isUnsigned = [self isUnsigned]; - + NSString *attributeValueScalarType = [[self userInfo] objectForKey:kAttributeValueScalarTypeKey]; - + if (attributeValueScalarType) { return attributeValueScalarType; } else { @@ -419,9 +453,9 @@ - (NSString*)scalarAttributeType { } } - (NSString*)scalarAccessorMethodName { - + BOOL isUnsigned = [self isUnsigned]; - + switch ([self attributeType]) { case NSInteger16AttributeType: if (isUnsigned) { @@ -455,9 +489,9 @@ - (NSString*)scalarAccessorMethodName { } } - (NSString*)scalarFactoryMethodName { - + BOOL isUnsigned = [self isUnsigned]; - + switch ([self attributeType]) { case NSInteger16AttributeType: if (isUnsigned) { @@ -550,12 +584,28 @@ - (BOOL)isReadonly { @implementation NSRelationshipDescription (collectionClassName) +- (NSString*)jr_CollectionClassStringWithOrderedClassName:(NSString*)orderedClassName + unorderedClassName:(NSString*)unorderedClassName +{ + NSString *generic = [NSString stringWithFormat:@"<%@*>", self.destinationEntity.managedObjectClassName]; + if (gSwift) { + // No generics for Swift sets, for now. + return [self jr_isOrdered] ? orderedClassName : unorderedClassName; + } + + return [self jr_isOrdered] + ? [orderedClassName stringByAppendingString:generic] + : [unorderedClassName stringByAppendingString:generic]; +} + - (NSString*)mutableCollectionClassName { - return [self jr_isOrdered] ? @"NSMutableOrderedSet" : @"NSMutableSet"; + return [self jr_CollectionClassStringWithOrderedClassName:@"NSMutableOrderedSet" + unorderedClassName:@"NSMutableSet"]; } - (NSString*)immutableCollectionClassName { - return [self jr_isOrdered] ? @"NSOrderedSet" : @"NSSet"; + return [self jr_CollectionClassStringWithOrderedClassName:@"NSOrderedSet" + unorderedClassName:@"NSSet"]; } - (BOOL)jr_isOrdered { @@ -586,7 +636,7 @@ @interface MogeneratorTemplateDesc : NSObject { NSString *templateName; NSString *templatePath; } -- (id)initWithName:(NSString*)name_ path:(NSString*)path_; +- (instancetype)initWithName:(NSString*)name_ path:(NSString*)path_; - (NSString*)templateName; - (void)setTemplateName:(NSString*)name_; - (NSString*)templatePath; @@ -601,11 +651,11 @@ - (void)setTemplatePath:(NSString*)path_; } else { NSData *templateData = [[NSBundle mainBundle] objectForInfoDictionaryKey:[templateDesc_ templateName]]; assert(templateData); - NSString *templateString = [[[NSString alloc] initWithData:templateData encoding:NSASCIIStringEncoding] autorelease]; + NSString *templateString = [[[NSString alloc] initWithData:templateData encoding:NSUTF8StringEncoding] autorelease]; [template setFilename:[@"x-__info_plist://" stringByAppendingString:[templateDesc_ templateName]]]; [template parseString:templateString]; } - + return [[[MiscMergeEngine alloc] initWithTemplate:template] autorelease]; } @@ -628,7 +678,7 @@ - (void)dealloc { - (MogeneratorTemplateDesc*)templateDescNamed:(NSString*)fileName_ { NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL isDirectory; - + if (templatePath) { if ([fileManager fileExistsAtPath:templatePath isDirectory:&isDirectory] && isDirectory) { return [[[MogeneratorTemplateDesc alloc] initWithName:fileName_ @@ -637,8 +687,9 @@ - (MogeneratorTemplateDesc*)templateDescNamed:(NSString*)fileName_ { } else if (templateGroup) { NSArray *appSupportDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask+NSLocalDomainMask, YES); assert(appSupportDirectories); - - nsenumerate (appSupportDirectories, NSString*, appSupportDirectory) { + + for (NSString *appSupportDirectory in appSupportDirectories) + { if ([fileManager fileExistsAtPath:appSupportDirectory isDirectory:&isDirectory]) { NSString *appSupportSubdirectory = [appSupportDirectory stringByAppendingPathComponent:ApplicationSupportSubdirectoryName]; appSupportSubdirectory = [appSupportSubdirectory stringByAppendingPathComponent:templateGroup]; @@ -653,7 +704,7 @@ - (MogeneratorTemplateDesc*)templateDescNamed:(NSString*)fileName_ { } else { return [[[MogeneratorTemplateDesc alloc] initWithName:fileName_ path:nil] autorelease]; } - + ddprintf(@"templateDescNamed:@\"%@\": file not found", fileName_); exit(EXIT_FAILURE); return nil; @@ -663,11 +714,10 @@ - (void)application:(DDCliApplication*)app willParseOptions:(DDGetoptLongParser*)optionsParser; { [optionsParser setGetoptLongOnly:YES]; - DDGetoptOption optionTable[] = + DDGetoptOption optionTable[] = { // Long Short Argument options {@"v2", '2', DDGetoptNoArgument}, - {@"model", 'm', DDGetoptRequiredArgument}, {@"configuration", 'C', DDGetoptRequiredArgument}, {@"base-class", 0, DDGetoptRequiredArgument}, @@ -686,7 +736,7 @@ - (void)application:(DDCliApplication*)app {@"template-group", 0, DDGetoptRequiredArgument}, {@"list-source-files", 0, DDGetoptNoArgument}, {@"orphaned", 0, DDGetoptNoArgument}, - + {@"help", 'h', DDGetoptNoArgument}, {@"version", 0, DDGetoptNoArgument}, {@"template-var", 0, DDGetoptKeyValueArgument}, @@ -707,11 +757,7 @@ - (void)printUsage { "Typical Use\n" "-----------\n" "\n" - "$ mogenerator --v2 --model MyModel.xcdatamodeld --output-dir MyModel\n" - "\n" - "The --v2 argument tells mogenerator to use modern Objective-C (ARC,\n" - "Objective-C literals, modules). Otherwise mogenerator will generate old-style\n" - "Objective-C.\n" + "$ mogenerator --model MyModel.xcdatamodeld --output-dir MyModel\n" "\n" "Use the --model argument to supply the required data model file.\n" "\n" @@ -750,46 +796,46 @@ - (void)printUsage { - (NSString*)xcodeSelectPrintPath { NSString *result = @""; - + @try { NSTask *task = [[[NSTask alloc] init] autorelease]; [task setLaunchPath:@"/usr/bin/xcode-select"]; - + [task setArguments:[NSArray arrayWithObject:@"-print-path"]]; - + NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput:pipe]; // Ensures that the current tasks output doesn't get hijacked [task setStandardInput:[NSPipe pipe]]; - + NSFileHandle *file = [pipe fileHandleForReading]; - + [task launch]; - + NSData *data = [file readDataToEndOfFile]; result = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; result = [result substringToIndex:[result length]-1]; // trim newline } @catch(NSException *ex) { ddprintf(@"WARNING couldn't launch /usr/bin/xcode-select\n"); } - + return result; } - (void)setModel:(NSString*)momOrXCDataModelFilePath { assert(!model); // Currently we only can load one model. - + NSFileManager *fm = [NSFileManager defaultManager]; - + if (![fm fileExistsAtPath:momOrXCDataModelFilePath]) { NSString *reason = [NSString stringWithFormat:@"error loading file at %@: no such file exists", momOrXCDataModelFilePath]; DDCliParseException *e = [DDCliParseException parseExceptionWithReason:reason exitCode:EX_NOINPUT]; @throw e; } - + origModelBasePath = [momOrXCDataModelFilePath stringByDeletingLastPathComponent]; - + // If given a data model bundle (.xcdatamodeld) file, assume its "current" data model file. if ([[momOrXCDataModelFilePath pathExtension] isEqualToString:@"xcdatamodeld"]) { // xcdatamodeld bundles have a ".xccurrentversion" plist file in them with a @@ -813,17 +859,17 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { } } } - + NSString *momFilePath = nil; if ([[momOrXCDataModelFilePath pathExtension] isEqualToString:@"xcdatamodel"]) { // We've been handed a .xcdatamodel data model, transparently compile it into a .mom managed object model. - + NSString *contentsPath = [momOrXCDataModelFilePath stringByAppendingPathComponent:@"contents"]; if ([[NSFileManager defaultManager] fileExistsAtPath:contentsPath]) { // Cool, the model is in the Xcode 4.0+ format, we can compile it ourselves. NSError *compileError = nil; momFilePath = [NSManagedObjectModel compileModelAtPath:momOrXCDataModelFilePath inDirectory:NSTemporaryDirectory() error:&compileError]; - if (compileError) { + if (momFilePath == nil) { NSLog(@"Error: %@", [compileError localizedDescription]); } assert(momFilePath); @@ -836,7 +882,7 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { } else { // Rats, don't have xcrun. Hunt around for momc in various places where various versions of Xcode stashed it. NSString *xcodeSelectMomcPath = [NSString stringWithFormat:@"%@/usr/bin/momc", [self xcodeSelectPrintPath]]; - + if ([fm fileExistsAtPath:xcodeSelectMomcPath]) { momcTool = [NSString stringWithFormat:@"\"%@\"", xcodeSelectMomcPath]; // Quote for safety. } else if ([fm fileExistsAtPath:@"/Applications/Xcode.app/Contents/Developer/usr/bin/momc"]) { @@ -855,7 +901,7 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { assert(momcTool && "momc not found"); } }} - + NSMutableString *momcOptions = [NSMutableString string]; {{ NSArray *supportedMomcOptions = [NSArray arrayWithObjects: @@ -869,7 +915,7 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { } } }} - + NSString *momcIncantation = nil; {{ NSString *tempGeneratedMomFileName = [[[NSProcessInfo processInfo] globallyUniqueString] stringByAppendingPathExtension:@"mom"]; @@ -880,7 +926,7 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { momOrXCDataModelFilePath, tempGeneratedMomFilePath]; }} - + {{ system([momcIncantation UTF8String]); // Ignore system() result since momc sadly doesn't return any relevent error codes. momFilePath = tempGeneratedMomFilePath; @@ -889,7 +935,7 @@ - (void)setModel:(NSString*)momOrXCDataModelFilePath { } else { momFilePath = momOrXCDataModelFilePath; } - + model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:momFilePath]] autorelease]; assert(model); } @@ -900,12 +946,12 @@ - (void)validateOutputPath:(NSString*)path forType:(NSString*)type if (path == nil) { return; } - + NSString *errorString = nil; NSError *error = nil; NSFileManager *fm = [NSFileManager defaultManager]; BOOL isDir = NO; - + // Test to see if the path exists if ([fm fileExistsAtPath:path isDirectory:&isDir]) { if (!isDir) { @@ -918,7 +964,7 @@ - (void)validateOutputPath:(NSString*)path forType:(NSString*)type errorString = [NSString stringWithFormat:@"Couldn't create %@ Directory (%@):%@", type, path, [error localizedDescription]]; } } - + if (errorString != nil) { // Print error message and exit with IO error @@ -932,17 +978,11 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { [self printUsage]; return EXIT_SUCCESS; } - + if (_version) { - printf("mogenerator 1.28. By Jonathan 'Wolf' Rentzsch + friends.\n"); + printf("mogenerator 1.30.1. By Jonathan 'Wolf' Rentzsch + friends.\n"); return EXIT_SUCCESS; } - - if (_v2) { - [templateVar setObject:@YES forKey:@"arc"]; - [templateVar setObject:@YES forKey:@"literals"]; - [templateVar setObject:@YES forKey:@"modules"]; - } gSwift = _swift; @@ -957,10 +997,10 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { NSString * mfilePath = includem; NSString * hfilePath = includeh; - + NSMutableString * mfileContent = [NSMutableString stringWithString:@""]; NSMutableString * hfileContent = [NSMutableString stringWithString:@""]; - + [self validateOutputPath:outputDir forType:@"Output"]; [self validateOutputPath:machineDir forType:@"Machine Output"]; [self validateOutputPath:humanDir forType:@"Human Output"]; @@ -973,45 +1013,58 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { humanDir = outputDir; NSFileManager *fm = [NSFileManager defaultManager]; - + if (_orphaned) { NSMutableDictionary *entityFilesByName = [NSMutableDictionary dictionary]; - + NSArray *srcDirs = [NSArray arrayWithObjects:machineDir, humanDir, nil]; - nsenumerate(srcDirs, NSString, srcDir) { + for (NSString *srcDir in srcDirs) + { if (![srcDir length]) { srcDir = [fm currentDirectoryPath]; } - nsenumerate([fm subpathsAtPath:srcDir], NSString, srcFileName) { - #define MANAGED_OBJECT_SOURCE_FILE_REGEX @"_?([a-zA-Z0-9_]+MO).(h|m|mm)" // Sadly /^(*MO).(h|m|mm)$/ doesn't work. - if ([srcFileName isMatchedByRegex:MANAGED_OBJECT_SOURCE_FILE_REGEX]) { - NSString *entityName = [[srcFileName captureComponentsMatchedByRegex:MANAGED_OBJECT_SOURCE_FILE_REGEX] objectAtIndex:1]; + + NSArray *subpaths = [fm subpathsAtPath:srcDir]; + for (NSString *srcFileName in subpaths) + { + NSString *moSourceFileRegex = @"_?([a-zA-Z0-9_]+MO).(h|m|mm)"; // Sadly /^(*MO).(h|m|mm)$/ doesn't work. + + if ([srcFileName isMatchedByRegex:moSourceFileRegex]) { + NSString *entityName = [[srcFileName captureComponentsMatchedByRegex:moSourceFileRegex] objectAtIndex:1]; if (![entityFilesByName objectForKey:entityName]) { [entityFilesByName setObject:[NSMutableSet set] forKey:entityName]; } [[entityFilesByName objectForKey:entityName] addObject:srcFileName]; } + } } - nsenumerate ([model entitiesWithACustomSubclassInConfiguration:configuration verbose:NO], NSEntityDescription, entity) { + + NSArray *entitiesWithCustomSubclass = [model entitiesWithACustomSubclassInConfiguration:configuration verbose:NO]; + + for (NSEntityDescription *entity in entitiesWithCustomSubclass) + { [entityFilesByName removeObjectForKey:[entity managedObjectClassName]]; } - nsenumerate(entityFilesByName, NSSet, ophanedFiles) { - nsenumerate(ophanedFiles, NSString, ophanedFile) { - ddprintf(@"%@\n", ophanedFile); + + for (NSSet *orphanedFiles in entityFilesByName) + { + for (NSString *orphanedFile in orphanedFiles) + { + ddprintf(@"%@\n", orphanedFile); } } - + return EXIT_SUCCESS; } - + if (templatePath) { - + NSString* absoluteTemplatePath = nil; - + if (![templatePath isAbsolutePath]) { absoluteTemplatePath = [[origModelBasePath stringByAppendingPathComponent:templatePath] stringByStandardizingPath]; - + // Be kind and try a relative Path of the parent xcdatamodeld folder of the model, if it exists if ((![fm fileExistsAtPath:absoluteTemplatePath]) && ([[origModelBasePath pathExtension] isEqualToString:@"xcdatamodeld"])) { absoluteTemplatePath = [[[origModelBasePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:templatePath] stringByStandardizingPath]; @@ -1020,16 +1073,16 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { absoluteTemplatePath = templatePath; } - + // if the computed absoluteTemplatePath exists, use it. if ([fm fileExistsAtPath:absoluteTemplatePath]) { templatePath = absoluteTemplatePath; } } - - int machineFilesGenerated = 0; + + int machineFilesGenerated = 0; int humanFilesGenerated = 0; - + if (model) { MiscMergeEngine *machineH = nil; MiscMergeEngine *machineM = nil; @@ -1057,27 +1110,33 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { [machineM setEngineValue:templateVar forKey:kTemplateVar]; [humanH setEngineValue:templateVar forKey:kTemplateVar]; [humanM setEngineValue:templateVar forKey:kTemplateVar]; - + NSMutableArray *humanMFiles = [NSMutableArray array], *humanHFiles = [NSMutableArray array], *machineMFiles = [NSMutableArray array], *machineHFiles = [NSMutableArray array]; - - nsenumerate ([model entitiesWithACustomSubclassInConfiguration:configuration verbose:YES], NSEntityDescription, entity) { + + NSArray *entitiesWithCustomSubclass = [model entitiesWithACustomSubclassInConfiguration:configuration verbose:YES]; + for (NSEntityDescription *entity in entitiesWithCustomSubclass) + { NSString *generatedMachineH = [machineH executeWithObject:entity sender:nil]; NSString *generatedMachineM = [machineM executeWithObject:entity sender:nil]; NSString *generatedHumanH = [humanH executeWithObject:entity sender:nil]; NSString *generatedHumanM = [humanM executeWithObject:entity sender:nil]; - + // remove unnecessary empty lines - generatedMachineH = [generatedMachineH stringByReplacingOccurrencesOfRegex:@"([ \t]*(\n|\r|\r\n)){2,}" withString:@"\n\n"]; - generatedMachineM = [generatedMachineM stringByReplacingOccurrencesOfRegex:@"([ \t]*(\n|\r|\r\n)){2,}" withString:@"\n\n"]; - generatedHumanH = [generatedHumanH stringByReplacingOccurrencesOfRegex:@"([ \t]*(\n|\r|\r\n)){2,}" withString:@"\n\n"]; - generatedHumanM = [generatedHumanM stringByReplacingOccurrencesOfRegex:@"([ \t]*(\n|\r|\r\n)){2,}" withString:@"\n\n"]; - + NSString *searchPattern = @"([ \t]*(\n|\r|\r\n)){2,}"; + NSString *replacementString = @"\n\n"; + + generatedMachineH = [generatedMachineH stringByReplacingOccurrencesOfRegex:searchPattern withString:replacementString]; + generatedMachineM = [generatedMachineM stringByReplacingOccurrencesOfRegex:searchPattern withString:replacementString]; + generatedHumanH = [generatedHumanH stringByReplacingOccurrencesOfRegex:searchPattern withString:replacementString]; + generatedHumanM = [generatedHumanM stringByReplacingOccurrencesOfRegex:searchPattern withString:replacementString]; + NSString *entityClassName = [entity managedObjectClassName]; + entityClassName = [entityClassName stringByReplacingOccurrencesOfString:@"." withString:@"_"]; BOOL machineDirtied = NO; - + // Machine header files. NSString *extension = (_swift ? @"swift" : @"h"); NSString *machineHFileName = [machineDir stringByAppendingPathComponent: @@ -1092,7 +1151,7 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { machineFilesGenerated++; } } - + // Machine source files. NSString *machineMFileName = nil; if (!_swift) { @@ -1109,7 +1168,7 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { } } } - + // Human header files. NSString *humanHFileName = [humanDir stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.%@", entityClassName, extension]]; @@ -1146,23 +1205,26 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { humanFilesGenerated++; } } - + [mfileContent appendFormat:@"#import \"%@\"\n#import \"%@\"\n", [humanMFileName lastPathComponent], [machineMFileName lastPathComponent]]; [hfileContent appendFormat:@"#import \"%@\"\n", [humanHFileName lastPathComponent]]; } } - + if (_listSourceFiles) { NSArray *filesList = [NSArray arrayWithObjects:humanMFiles, humanHFiles, machineMFiles, machineHFiles, nil]; - nsenumerate (filesList, NSArray, files) { - nsenumerate (files, NSString, fileName) { + + for (NSArray *files in filesList) + { + for (NSString *fileName in files) + { ddprintf(@"%@\n", fileName); } } } } - + if (tempGeneratedMomFilePath) { [fm removeItemAtPath:tempGeneratedMomFilePath error:nil]; } @@ -1186,7 +1248,7 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { printf("Aggregate header file was also generated to %s.\n", [hfilePath fileSystemRepresentation]); } } - + return EXIT_SUCCESS; } @@ -1194,7 +1256,7 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { @implementation MogeneratorTemplateDesc -- (id)initWithName:(NSString*)name_ path:(NSString*)path_ { +- (instancetype)initWithName:(NSString*)name_ path:(NSString*)path_ { self = [super init]; if (self) { templateName = [name_ retain]; diff --git a/mogenerator.xcodeproj/project.pbxproj b/mogenerator.xcodeproj/project.pbxproj index 61695a58..d036b191 100644 --- a/mogenerator.xcodeproj/project.pbxproj +++ b/mogenerator.xcodeproj/project.pbxproj @@ -15,7 +15,6 @@ 55200E980C49FEEA00018A42 /* DDGetoptLongParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 55200E950C49FEEA00018A42 /* DDGetoptLongParser.m */; }; 55200F9D0C4A2CA800018A42 /* DDCliParseException.m in Sources */ = {isa = PBXBuildFile; fileRef = 55200F9C0C4A2CA800018A42 /* DDCliParseException.m */; }; 7931E67810FE982500175784 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 7931E67710FE982500175784 /* libicucore.dylib */; }; - 7931E67B10FE984F00175784 /* RegexKitLite.m in Sources */ = {isa = PBXBuildFile; fileRef = 7931E67A10FE984F00175784 /* RegexKitLite.m */; }; 79D2BF3F0ACFB25B00F3F141 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 79D2BF3E0ACFB25B00F3F141 /* CoreData.framework */; }; 79D2BFA20ACFB51A00F3F141 /* _MiscMergeBreakCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 79D2BF530ACFB51A00F3F141 /* _MiscMergeBreakCommand.m */; }; 79D2BFA40ACFB51A00F3F141 /* _MiscMergeCallCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 79D2BF550ACFB51A00F3F141 /* _MiscMergeCallCommand.m */; }; @@ -59,6 +58,7 @@ 79D2C05A0ACFBCB500F3F141 /* FoundationAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 79D2C0580ACFBCB500F3F141 /* FoundationAdditions.m */; }; 8DD76F9A0486AA7600D96B5E /* mogenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* mogenerator.m */; settings = {ATTRIBUTES = (); }; }; 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; }; + D03C79F31B8BE77500A49BD8 /* NSString+MORegEx.m in Sources */ = {isa = PBXBuildFile; fileRef = D03C79F21B8BE77500A49BD8 /* NSString+MORegEx.m */; }; EE5ED87317332E020013CCD1 /* NSManagedObjectModel+momcom.m in Sources */ = {isa = PBXBuildFile; fileRef = EE5ED86617332E020013CCD1 /* NSManagedObjectModel+momcom.m */; }; EE5ED87417332E020013CCD1 /* NSEntityDescription+momcom.m in Sources */ = {isa = PBXBuildFile; fileRef = EE5ED86817332E020013CCD1 /* NSEntityDescription+momcom.m */; }; EE5ED87517332E020013CCD1 /* NSAttributeDescription+momcom.m in Sources */ = {isa = PBXBuildFile; fileRef = EE5ED86A17332E020013CCD1 /* NSAttributeDescription+momcom.m */; }; @@ -88,93 +88,92 @@ 55200F9B0C4A2CA800018A42 /* DDCliParseException.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DDCliParseException.h; sourceTree = ""; }; 55200F9C0C4A2CA800018A42 /* DDCliParseException.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = DDCliParseException.m; sourceTree = ""; }; 7931E67710FE982500175784 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = usr/lib/libicucore.dylib; sourceTree = SDKROOT; }; - 7931E67910FE984F00175784 /* RegexKitLite.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegexKitLite.h; sourceTree = ""; }; - 7931E67A10FE984F00175784 /* RegexKitLite.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegexKitLite.m; sourceTree = ""; }; 79A586510E48E8B400474C35 /* mogenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mogenerator.h; sourceTree = ""; usesTabs = 0; }; 79D2BF3E0ACFB25B00F3F141 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; - 79D2BF520ACFB51A00F3F141 /* _MiscMergeBreakCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeBreakCommand.h; path = ../MiscMerge/_MiscMergeBreakCommand.h; sourceTree = ""; }; - 79D2BF530ACFB51A00F3F141 /* _MiscMergeBreakCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeBreakCommand.m; path = ../MiscMerge/_MiscMergeBreakCommand.m; sourceTree = ""; }; - 79D2BF540ACFB51A00F3F141 /* _MiscMergeCallCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCallCommand.h; path = ../MiscMerge/_MiscMergeCallCommand.h; sourceTree = ""; }; - 79D2BF550ACFB51A00F3F141 /* _MiscMergeCallCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCallCommand.m; path = ../MiscMerge/_MiscMergeCallCommand.m; sourceTree = ""; }; - 79D2BF560ACFB51A00F3F141 /* _MiscMergeCommentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCommentCommand.h; path = ../MiscMerge/_MiscMergeCommentCommand.h; sourceTree = ""; }; - 79D2BF570ACFB51A00F3F141 /* _MiscMergeCommentCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCommentCommand.m; path = ../MiscMerge/_MiscMergeCommentCommand.m; sourceTree = ""; }; - 79D2BF580ACFB51A00F3F141 /* _MiscMergeContinueCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeContinueCommand.h; path = ../MiscMerge/_MiscMergeContinueCommand.h; sourceTree = ""; }; - 79D2BF590ACFB51A00F3F141 /* _MiscMergeContinueCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeContinueCommand.m; path = ../MiscMerge/_MiscMergeContinueCommand.m; sourceTree = ""; }; - 79D2BF5A0ACFB51A00F3F141 /* _MiscMergeCopyCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCopyCommand.h; path = ../MiscMerge/_MiscMergeCopyCommand.h; sourceTree = ""; }; - 79D2BF5B0ACFB51A00F3F141 /* _MiscMergeCopyCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCopyCommand.m; path = ../MiscMerge/_MiscMergeCopyCommand.m; sourceTree = ""; }; - 79D2BF5C0ACFB51A00F3F141 /* _MiscMergeDateCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDateCommand.h; path = ../MiscMerge/_MiscMergeDateCommand.h; sourceTree = ""; }; - 79D2BF5D0ACFB51A00F3F141 /* _MiscMergeDateCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDateCommand.m; path = ../MiscMerge/_MiscMergeDateCommand.m; sourceTree = ""; }; - 79D2BF5E0ACFB51A00F3F141 /* _MiscMergeDebugCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDebugCommand.h; path = ../MiscMerge/_MiscMergeDebugCommand.h; sourceTree = ""; }; - 79D2BF5F0ACFB51A00F3F141 /* _MiscMergeDebugCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDebugCommand.m; path = ../MiscMerge/_MiscMergeDebugCommand.m; sourceTree = ""; }; - 79D2BF600ACFB51A00F3F141 /* _MiscMergeDelayedParseCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDelayedParseCommand.h; path = ../MiscMerge/_MiscMergeDelayedParseCommand.h; sourceTree = ""; }; - 79D2BF610ACFB51A00F3F141 /* _MiscMergeDelayedParseCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDelayedParseCommand.m; path = ../MiscMerge/_MiscMergeDelayedParseCommand.m; sourceTree = ""; }; - 79D2BF620ACFB51A00F3F141 /* _MiscMergeElseCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeElseCommand.h; path = ../MiscMerge/_MiscMergeElseCommand.h; sourceTree = ""; }; - 79D2BF630ACFB51A00F3F141 /* _MiscMergeElseCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeElseCommand.m; path = ../MiscMerge/_MiscMergeElseCommand.m; sourceTree = ""; }; - 79D2BF640ACFB51A00F3F141 /* _MiscMergeElseifCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeElseifCommand.h; path = ../MiscMerge/_MiscMergeElseifCommand.h; sourceTree = ""; }; - 79D2BF650ACFB51A00F3F141 /* _MiscMergeElseifCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeElseifCommand.m; path = ../MiscMerge/_MiscMergeElseifCommand.m; sourceTree = ""; }; - 79D2BF660ACFB51A00F3F141 /* _MiscMergeEndforeachCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndforeachCommand.h; path = ../MiscMerge/_MiscMergeEndforeachCommand.h; sourceTree = ""; }; - 79D2BF670ACFB51A00F3F141 /* _MiscMergeEndforeachCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndforeachCommand.m; path = ../MiscMerge/_MiscMergeEndforeachCommand.m; sourceTree = ""; }; - 79D2BF680ACFB51A00F3F141 /* _MiscMergeEndifCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndifCommand.h; path = ../MiscMerge/_MiscMergeEndifCommand.h; sourceTree = ""; }; - 79D2BF690ACFB51A00F3F141 /* _MiscMergeEndifCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndifCommand.m; path = ../MiscMerge/_MiscMergeEndifCommand.m; sourceTree = ""; }; - 79D2BF6A0ACFB51A00F3F141 /* _MiscMergeEndloopCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndloopCommand.h; path = ../MiscMerge/_MiscMergeEndloopCommand.h; sourceTree = ""; }; - 79D2BF6B0ACFB51A00F3F141 /* _MiscMergeEndloopCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndloopCommand.m; path = ../MiscMerge/_MiscMergeEndloopCommand.m; sourceTree = ""; }; - 79D2BF6C0ACFB51A00F3F141 /* _MiscMergeEndprocedureCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndprocedureCommand.h; path = ../MiscMerge/_MiscMergeEndprocedureCommand.h; sourceTree = ""; }; - 79D2BF6D0ACFB51A00F3F141 /* _MiscMergeEndprocedureCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndprocedureCommand.m; path = ../MiscMerge/_MiscMergeEndprocedureCommand.m; sourceTree = ""; }; - 79D2BF6E0ACFB51A00F3F141 /* _MiscMergeEndwhileCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndwhileCommand.h; path = ../MiscMerge/_MiscMergeEndwhileCommand.h; sourceTree = ""; }; - 79D2BF6F0ACFB51A00F3F141 /* _MiscMergeEndwhileCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndwhileCommand.m; path = ../MiscMerge/_MiscMergeEndwhileCommand.m; sourceTree = ""; }; - 79D2BF700ACFB51A00F3F141 /* _MiscMergeFieldCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeFieldCommand.h; path = ../MiscMerge/_MiscMergeFieldCommand.h; sourceTree = ""; }; - 79D2BF710ACFB51A00F3F141 /* _MiscMergeFieldCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeFieldCommand.m; path = ../MiscMerge/_MiscMergeFieldCommand.m; sourceTree = ""; }; - 79D2BF720ACFB51A00F3F141 /* _MiscMergeForeachCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeForeachCommand.h; path = ../MiscMerge/_MiscMergeForeachCommand.h; sourceTree = ""; }; - 79D2BF730ACFB51A00F3F141 /* _MiscMergeForeachCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeForeachCommand.m; path = ../MiscMerge/_MiscMergeForeachCommand.m; sourceTree = ""; }; - 79D2BF740ACFB51A00F3F141 /* _MiscMergeIdentifyCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIdentifyCommand.h; path = ../MiscMerge/_MiscMergeIdentifyCommand.h; sourceTree = ""; }; - 79D2BF750ACFB51A00F3F141 /* _MiscMergeIdentifyCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIdentifyCommand.m; path = ../MiscMerge/_MiscMergeIdentifyCommand.m; sourceTree = ""; }; - 79D2BF760ACFB51A00F3F141 /* _MiscMergeIfCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIfCommand.h; path = ../MiscMerge/_MiscMergeIfCommand.h; sourceTree = ""; }; - 79D2BF770ACFB51A00F3F141 /* _MiscMergeIfCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIfCommand.m; path = ../MiscMerge/_MiscMergeIfCommand.m; sourceTree = ""; }; - 79D2BF780ACFB51A00F3F141 /* _MiscMergeIncludeCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIncludeCommand.h; path = ../MiscMerge/_MiscMergeIncludeCommand.h; sourceTree = ""; }; - 79D2BF790ACFB51A00F3F141 /* _MiscMergeIncludeCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIncludeCommand.m; path = ../MiscMerge/_MiscMergeIncludeCommand.m; sourceTree = ""; }; - 79D2BF7A0ACFB51A00F3F141 /* _MiscMergeIndexCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIndexCommand.h; path = ../MiscMerge/_MiscMergeIndexCommand.h; sourceTree = ""; }; - 79D2BF7B0ACFB51A00F3F141 /* _MiscMergeIndexCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIndexCommand.m; path = ../MiscMerge/_MiscMergeIndexCommand.m; sourceTree = ""; }; - 79D2BF7C0ACFB51A00F3F141 /* _MiscMergeLoopCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeLoopCommand.h; path = ../MiscMerge/_MiscMergeLoopCommand.h; sourceTree = ""; }; - 79D2BF7D0ACFB51A00F3F141 /* _MiscMergeLoopCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeLoopCommand.m; path = ../MiscMerge/_MiscMergeLoopCommand.m; sourceTree = ""; }; - 79D2BF7E0ACFB51A00F3F141 /* _MiscMergeNextCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeNextCommand.h; path = ../MiscMerge/_MiscMergeNextCommand.h; sourceTree = ""; }; - 79D2BF7F0ACFB51A00F3F141 /* _MiscMergeNextCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeNextCommand.m; path = ../MiscMerge/_MiscMergeNextCommand.m; sourceTree = ""; }; - 79D2BF800ACFB51A00F3F141 /* _MiscMergeOmitCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeOmitCommand.h; path = ../MiscMerge/_MiscMergeOmitCommand.h; sourceTree = ""; }; - 79D2BF810ACFB51A00F3F141 /* _MiscMergeOmitCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeOmitCommand.m; path = ../MiscMerge/_MiscMergeOmitCommand.m; sourceTree = ""; }; - 79D2BF820ACFB51A00F3F141 /* _MiscMergeOptionCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeOptionCommand.h; path = ../MiscMerge/_MiscMergeOptionCommand.h; sourceTree = ""; }; - 79D2BF830ACFB51A00F3F141 /* _MiscMergeOptionCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeOptionCommand.m; path = ../MiscMerge/_MiscMergeOptionCommand.m; sourceTree = ""; }; - 79D2BF840ACFB51A00F3F141 /* _MiscMergeProcedureCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeProcedureCommand.h; path = ../MiscMerge/_MiscMergeProcedureCommand.h; sourceTree = ""; }; - 79D2BF850ACFB51A00F3F141 /* _MiscMergeProcedureCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeProcedureCommand.m; path = ../MiscMerge/_MiscMergeProcedureCommand.m; sourceTree = ""; }; - 79D2BF860ACFB51A00F3F141 /* _MiscMergeSetCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeSetCommand.h; path = ../MiscMerge/_MiscMergeSetCommand.h; sourceTree = ""; }; - 79D2BF870ACFB51A00F3F141 /* _MiscMergeSetCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeSetCommand.m; path = ../MiscMerge/_MiscMergeSetCommand.m; sourceTree = ""; }; - 79D2BF880ACFB51A00F3F141 /* _MiscMergeWhileCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = _MiscMergeWhileCommand.h; path = ../MiscMerge/_MiscMergeWhileCommand.h; sourceTree = ""; }; - 79D2BF890ACFB51A00F3F141 /* _MiscMergeWhileCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeWhileCommand.m; path = ../MiscMerge/_MiscMergeWhileCommand.m; sourceTree = ""; }; - 79D2BF8A0ACFB51A00F3F141 /* KeyValue+MiscMerge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "KeyValue+MiscMerge.h"; path = "../MiscMerge/KeyValue+MiscMerge.h"; sourceTree = ""; }; - 79D2BF8B0ACFB51A00F3F141 /* KeyValue+MiscMerge.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = "KeyValue+MiscMerge.m"; path = "../MiscMerge/KeyValue+MiscMerge.m"; sourceTree = ""; }; - 79D2BF8C0ACFB51A00F3F141 /* MiscMergeCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeCommand.h; path = ../MiscMerge/MiscMergeCommand.h; sourceTree = ""; }; - 79D2BF8D0ACFB51A00F3F141 /* MiscMergeCommand.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeCommand.m; path = ../MiscMerge/MiscMergeCommand.m; sourceTree = ""; }; - 79D2BF8E0ACFB51A00F3F141 /* MiscMergeCommandBlock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeCommandBlock.h; path = ../MiscMerge/MiscMergeCommandBlock.h; sourceTree = ""; }; - 79D2BF8F0ACFB51A00F3F141 /* MiscMergeCommandBlock.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeCommandBlock.m; path = ../MiscMerge/MiscMergeCommandBlock.m; sourceTree = ""; }; - 79D2BF900ACFB51A00F3F141 /* MiscMergeDriver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeDriver.h; path = ../MiscMerge/MiscMergeDriver.h; sourceTree = ""; }; - 79D2BF910ACFB51A00F3F141 /* MiscMergeDriver.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeDriver.m; path = ../MiscMerge/MiscMergeDriver.m; sourceTree = ""; }; - 79D2BF920ACFB51A00F3F141 /* MiscMergeEngine.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeEngine.h; path = ../MiscMerge/MiscMergeEngine.h; sourceTree = ""; }; - 79D2BF930ACFB51A00F3F141 /* MiscMergeEngine.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeEngine.m; path = ../MiscMerge/MiscMergeEngine.m; sourceTree = ""; }; - 79D2BF940ACFB51A00F3F141 /* MiscMergeExpression.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeExpression.h; path = ../MiscMerge/MiscMergeExpression.h; sourceTree = ""; }; - 79D2BF950ACFB51A00F3F141 /* MiscMergeExpression.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeExpression.m; path = ../MiscMerge/MiscMergeExpression.m; sourceTree = ""; }; - 79D2BF960ACFB51A00F3F141 /* MiscMergeFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeFunctions.h; path = ../MiscMerge/MiscMergeFunctions.h; sourceTree = ""; }; - 79D2BF970ACFB51A00F3F141 /* MiscMergeFunctions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MiscMergeFunctions.m; path = ../MiscMerge/MiscMergeFunctions.m; sourceTree = ""; }; - 79D2BF980ACFB51A00F3F141 /* MiscMergeSpike_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeSpike_Prefix.pch; path = ../MiscMerge/MiscMergeSpike_Prefix.pch; sourceTree = ""; }; - 79D2BF990ACFB51A00F3F141 /* MiscMergeTemplate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MiscMergeTemplate.h; path = ../MiscMerge/MiscMergeTemplate.h; sourceTree = ""; }; + 79D2BF520ACFB51A00F3F141 /* _MiscMergeBreakCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeBreakCommand.h; path = ../MiscMerge/_MiscMergeBreakCommand.h; sourceTree = ""; }; + 79D2BF530ACFB51A00F3F141 /* _MiscMergeBreakCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeBreakCommand.m; path = ../MiscMerge/_MiscMergeBreakCommand.m; sourceTree = ""; }; + 79D2BF540ACFB51A00F3F141 /* _MiscMergeCallCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCallCommand.h; path = ../MiscMerge/_MiscMergeCallCommand.h; sourceTree = ""; }; + 79D2BF550ACFB51A00F3F141 /* _MiscMergeCallCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCallCommand.m; path = ../MiscMerge/_MiscMergeCallCommand.m; sourceTree = ""; }; + 79D2BF560ACFB51A00F3F141 /* _MiscMergeCommentCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCommentCommand.h; path = ../MiscMerge/_MiscMergeCommentCommand.h; sourceTree = ""; }; + 79D2BF570ACFB51A00F3F141 /* _MiscMergeCommentCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCommentCommand.m; path = ../MiscMerge/_MiscMergeCommentCommand.m; sourceTree = ""; }; + 79D2BF580ACFB51A00F3F141 /* _MiscMergeContinueCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeContinueCommand.h; path = ../MiscMerge/_MiscMergeContinueCommand.h; sourceTree = ""; }; + 79D2BF590ACFB51A00F3F141 /* _MiscMergeContinueCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeContinueCommand.m; path = ../MiscMerge/_MiscMergeContinueCommand.m; sourceTree = ""; }; + 79D2BF5A0ACFB51A00F3F141 /* _MiscMergeCopyCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeCopyCommand.h; path = ../MiscMerge/_MiscMergeCopyCommand.h; sourceTree = ""; }; + 79D2BF5B0ACFB51A00F3F141 /* _MiscMergeCopyCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeCopyCommand.m; path = ../MiscMerge/_MiscMergeCopyCommand.m; sourceTree = ""; }; + 79D2BF5C0ACFB51A00F3F141 /* _MiscMergeDateCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDateCommand.h; path = ../MiscMerge/_MiscMergeDateCommand.h; sourceTree = ""; }; + 79D2BF5D0ACFB51A00F3F141 /* _MiscMergeDateCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDateCommand.m; path = ../MiscMerge/_MiscMergeDateCommand.m; sourceTree = ""; }; + 79D2BF5E0ACFB51A00F3F141 /* _MiscMergeDebugCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDebugCommand.h; path = ../MiscMerge/_MiscMergeDebugCommand.h; sourceTree = ""; }; + 79D2BF5F0ACFB51A00F3F141 /* _MiscMergeDebugCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDebugCommand.m; path = ../MiscMerge/_MiscMergeDebugCommand.m; sourceTree = ""; }; + 79D2BF600ACFB51A00F3F141 /* _MiscMergeDelayedParseCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeDelayedParseCommand.h; path = ../MiscMerge/_MiscMergeDelayedParseCommand.h; sourceTree = ""; }; + 79D2BF610ACFB51A00F3F141 /* _MiscMergeDelayedParseCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeDelayedParseCommand.m; path = ../MiscMerge/_MiscMergeDelayedParseCommand.m; sourceTree = ""; }; + 79D2BF620ACFB51A00F3F141 /* _MiscMergeElseCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeElseCommand.h; path = ../MiscMerge/_MiscMergeElseCommand.h; sourceTree = ""; }; + 79D2BF630ACFB51A00F3F141 /* _MiscMergeElseCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeElseCommand.m; path = ../MiscMerge/_MiscMergeElseCommand.m; sourceTree = ""; }; + 79D2BF640ACFB51A00F3F141 /* _MiscMergeElseifCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeElseifCommand.h; path = ../MiscMerge/_MiscMergeElseifCommand.h; sourceTree = ""; }; + 79D2BF650ACFB51A00F3F141 /* _MiscMergeElseifCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeElseifCommand.m; path = ../MiscMerge/_MiscMergeElseifCommand.m; sourceTree = ""; }; + 79D2BF660ACFB51A00F3F141 /* _MiscMergeEndforeachCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndforeachCommand.h; path = ../MiscMerge/_MiscMergeEndforeachCommand.h; sourceTree = ""; }; + 79D2BF670ACFB51A00F3F141 /* _MiscMergeEndforeachCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndforeachCommand.m; path = ../MiscMerge/_MiscMergeEndforeachCommand.m; sourceTree = ""; }; + 79D2BF680ACFB51A00F3F141 /* _MiscMergeEndifCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndifCommand.h; path = ../MiscMerge/_MiscMergeEndifCommand.h; sourceTree = ""; }; + 79D2BF690ACFB51A00F3F141 /* _MiscMergeEndifCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndifCommand.m; path = ../MiscMerge/_MiscMergeEndifCommand.m; sourceTree = ""; }; + 79D2BF6A0ACFB51A00F3F141 /* _MiscMergeEndloopCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndloopCommand.h; path = ../MiscMerge/_MiscMergeEndloopCommand.h; sourceTree = ""; }; + 79D2BF6B0ACFB51A00F3F141 /* _MiscMergeEndloopCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndloopCommand.m; path = ../MiscMerge/_MiscMergeEndloopCommand.m; sourceTree = ""; }; + 79D2BF6C0ACFB51A00F3F141 /* _MiscMergeEndprocedureCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndprocedureCommand.h; path = ../MiscMerge/_MiscMergeEndprocedureCommand.h; sourceTree = ""; }; + 79D2BF6D0ACFB51A00F3F141 /* _MiscMergeEndprocedureCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndprocedureCommand.m; path = ../MiscMerge/_MiscMergeEndprocedureCommand.m; sourceTree = ""; }; + 79D2BF6E0ACFB51A00F3F141 /* _MiscMergeEndwhileCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeEndwhileCommand.h; path = ../MiscMerge/_MiscMergeEndwhileCommand.h; sourceTree = ""; }; + 79D2BF6F0ACFB51A00F3F141 /* _MiscMergeEndwhileCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeEndwhileCommand.m; path = ../MiscMerge/_MiscMergeEndwhileCommand.m; sourceTree = ""; }; + 79D2BF700ACFB51A00F3F141 /* _MiscMergeFieldCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeFieldCommand.h; path = ../MiscMerge/_MiscMergeFieldCommand.h; sourceTree = ""; }; + 79D2BF710ACFB51A00F3F141 /* _MiscMergeFieldCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeFieldCommand.m; path = ../MiscMerge/_MiscMergeFieldCommand.m; sourceTree = ""; }; + 79D2BF720ACFB51A00F3F141 /* _MiscMergeForeachCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeForeachCommand.h; path = ../MiscMerge/_MiscMergeForeachCommand.h; sourceTree = ""; }; + 79D2BF730ACFB51A00F3F141 /* _MiscMergeForeachCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeForeachCommand.m; path = ../MiscMerge/_MiscMergeForeachCommand.m; sourceTree = ""; }; + 79D2BF740ACFB51A00F3F141 /* _MiscMergeIdentifyCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIdentifyCommand.h; path = ../MiscMerge/_MiscMergeIdentifyCommand.h; sourceTree = ""; }; + 79D2BF750ACFB51A00F3F141 /* _MiscMergeIdentifyCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIdentifyCommand.m; path = ../MiscMerge/_MiscMergeIdentifyCommand.m; sourceTree = ""; }; + 79D2BF760ACFB51A00F3F141 /* _MiscMergeIfCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIfCommand.h; path = ../MiscMerge/_MiscMergeIfCommand.h; sourceTree = ""; }; + 79D2BF770ACFB51A00F3F141 /* _MiscMergeIfCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIfCommand.m; path = ../MiscMerge/_MiscMergeIfCommand.m; sourceTree = ""; }; + 79D2BF780ACFB51A00F3F141 /* _MiscMergeIncludeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIncludeCommand.h; path = ../MiscMerge/_MiscMergeIncludeCommand.h; sourceTree = ""; }; + 79D2BF790ACFB51A00F3F141 /* _MiscMergeIncludeCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIncludeCommand.m; path = ../MiscMerge/_MiscMergeIncludeCommand.m; sourceTree = ""; }; + 79D2BF7A0ACFB51A00F3F141 /* _MiscMergeIndexCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeIndexCommand.h; path = ../MiscMerge/_MiscMergeIndexCommand.h; sourceTree = ""; }; + 79D2BF7B0ACFB51A00F3F141 /* _MiscMergeIndexCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeIndexCommand.m; path = ../MiscMerge/_MiscMergeIndexCommand.m; sourceTree = ""; }; + 79D2BF7C0ACFB51A00F3F141 /* _MiscMergeLoopCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeLoopCommand.h; path = ../MiscMerge/_MiscMergeLoopCommand.h; sourceTree = ""; }; + 79D2BF7D0ACFB51A00F3F141 /* _MiscMergeLoopCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeLoopCommand.m; path = ../MiscMerge/_MiscMergeLoopCommand.m; sourceTree = ""; }; + 79D2BF7E0ACFB51A00F3F141 /* _MiscMergeNextCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeNextCommand.h; path = ../MiscMerge/_MiscMergeNextCommand.h; sourceTree = ""; }; + 79D2BF7F0ACFB51A00F3F141 /* _MiscMergeNextCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeNextCommand.m; path = ../MiscMerge/_MiscMergeNextCommand.m; sourceTree = ""; }; + 79D2BF800ACFB51A00F3F141 /* _MiscMergeOmitCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeOmitCommand.h; path = ../MiscMerge/_MiscMergeOmitCommand.h; sourceTree = ""; }; + 79D2BF810ACFB51A00F3F141 /* _MiscMergeOmitCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeOmitCommand.m; path = ../MiscMerge/_MiscMergeOmitCommand.m; sourceTree = ""; }; + 79D2BF820ACFB51A00F3F141 /* _MiscMergeOptionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeOptionCommand.h; path = ../MiscMerge/_MiscMergeOptionCommand.h; sourceTree = ""; }; + 79D2BF830ACFB51A00F3F141 /* _MiscMergeOptionCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeOptionCommand.m; path = ../MiscMerge/_MiscMergeOptionCommand.m; sourceTree = ""; }; + 79D2BF840ACFB51A00F3F141 /* _MiscMergeProcedureCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeProcedureCommand.h; path = ../MiscMerge/_MiscMergeProcedureCommand.h; sourceTree = ""; }; + 79D2BF850ACFB51A00F3F141 /* _MiscMergeProcedureCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeProcedureCommand.m; path = ../MiscMerge/_MiscMergeProcedureCommand.m; sourceTree = ""; }; + 79D2BF860ACFB51A00F3F141 /* _MiscMergeSetCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeSetCommand.h; path = ../MiscMerge/_MiscMergeSetCommand.h; sourceTree = ""; }; + 79D2BF870ACFB51A00F3F141 /* _MiscMergeSetCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeSetCommand.m; path = ../MiscMerge/_MiscMergeSetCommand.m; sourceTree = ""; }; + 79D2BF880ACFB51A00F3F141 /* _MiscMergeWhileCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = _MiscMergeWhileCommand.h; path = ../MiscMerge/_MiscMergeWhileCommand.h; sourceTree = ""; }; + 79D2BF890ACFB51A00F3F141 /* _MiscMergeWhileCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = _MiscMergeWhileCommand.m; path = ../MiscMerge/_MiscMergeWhileCommand.m; sourceTree = ""; }; + 79D2BF8A0ACFB51A00F3F141 /* KeyValue+MiscMerge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "KeyValue+MiscMerge.h"; path = "../MiscMerge/KeyValue+MiscMerge.h"; sourceTree = ""; }; + 79D2BF8B0ACFB51A00F3F141 /* KeyValue+MiscMerge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "KeyValue+MiscMerge.m"; path = "../MiscMerge/KeyValue+MiscMerge.m"; sourceTree = ""; }; + 79D2BF8C0ACFB51A00F3F141 /* MiscMergeCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeCommand.h; path = ../MiscMerge/MiscMergeCommand.h; sourceTree = ""; }; + 79D2BF8D0ACFB51A00F3F141 /* MiscMergeCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeCommand.m; path = ../MiscMerge/MiscMergeCommand.m; sourceTree = ""; }; + 79D2BF8E0ACFB51A00F3F141 /* MiscMergeCommandBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeCommandBlock.h; path = ../MiscMerge/MiscMergeCommandBlock.h; sourceTree = ""; }; + 79D2BF8F0ACFB51A00F3F141 /* MiscMergeCommandBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeCommandBlock.m; path = ../MiscMerge/MiscMergeCommandBlock.m; sourceTree = ""; }; + 79D2BF900ACFB51A00F3F141 /* MiscMergeDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeDriver.h; path = ../MiscMerge/MiscMergeDriver.h; sourceTree = ""; }; + 79D2BF910ACFB51A00F3F141 /* MiscMergeDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeDriver.m; path = ../MiscMerge/MiscMergeDriver.m; sourceTree = ""; }; + 79D2BF920ACFB51A00F3F141 /* MiscMergeEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeEngine.h; path = ../MiscMerge/MiscMergeEngine.h; sourceTree = ""; }; + 79D2BF930ACFB51A00F3F141 /* MiscMergeEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeEngine.m; path = ../MiscMerge/MiscMergeEngine.m; sourceTree = ""; }; + 79D2BF940ACFB51A00F3F141 /* MiscMergeExpression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeExpression.h; path = ../MiscMerge/MiscMergeExpression.h; sourceTree = ""; }; + 79D2BF950ACFB51A00F3F141 /* MiscMergeExpression.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeExpression.m; path = ../MiscMerge/MiscMergeExpression.m; sourceTree = ""; }; + 79D2BF960ACFB51A00F3F141 /* MiscMergeFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeFunctions.h; path = ../MiscMerge/MiscMergeFunctions.h; sourceTree = ""; }; + 79D2BF970ACFB51A00F3F141 /* MiscMergeFunctions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeFunctions.m; path = ../MiscMerge/MiscMergeFunctions.m; sourceTree = ""; }; + 79D2BF980ACFB51A00F3F141 /* MiscMergeSpike_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeSpike_Prefix.pch; path = ../MiscMerge/MiscMergeSpike_Prefix.pch; sourceTree = ""; }; + 79D2BF990ACFB51A00F3F141 /* MiscMergeTemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiscMergeTemplate.h; path = ../MiscMerge/MiscMergeTemplate.h; sourceTree = ""; }; 79D2BF9A0ACFB51A00F3F141 /* MiscMergeTemplate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiscMergeTemplate.m; path = ../MiscMerge/MiscMergeTemplate.m; sourceTree = ""; }; - 79D2BF9B0ACFB51A00F3F141 /* NSNull.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = NSNull.h; path = ../MiscMerge/NSNull.h; sourceTree = ""; }; - 79D2BF9C0ACFB51A00F3F141 /* NSNull.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSNull.m; path = ../MiscMerge/NSNull.m; sourceTree = ""; }; - 79D2BF9D0ACFB51A00F3F141 /* NSScanner+MiscMerge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSScanner+MiscMerge.h"; path = "../MiscMerge/NSScanner+MiscMerge.h"; sourceTree = ""; }; - 79D2BF9E0ACFB51A00F3F141 /* NSScanner+MiscMerge.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = "NSScanner+MiscMerge.m"; path = "../MiscMerge/NSScanner+MiscMerge.m"; sourceTree = ""; }; - 79D2BF9F0ACFB51A00F3F141 /* NSString+MiscAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSString+MiscAdditions.h"; path = "../MiscMerge/NSString+MiscAdditions.h"; sourceTree = ""; }; - 79D2BFA00ACFB51A00F3F141 /* NSString+MiscAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = "NSString+MiscAdditions.m"; path = "../MiscMerge/NSString+MiscAdditions.m"; sourceTree = ""; }; - 79D2C00E0ACFB81200F3F141 /* nsenumerate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nsenumerate.h; sourceTree = ""; }; - 79D2C0570ACFBCB500F3F141 /* FoundationAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FoundationAdditions.h; sourceTree = ""; }; - 79D2C0580ACFBCB500F3F141 /* FoundationAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FoundationAdditions.m; sourceTree = ""; }; + 79D2BF9B0ACFB51A00F3F141 /* NSNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NSNull.h; path = ../MiscMerge/NSNull.h; sourceTree = ""; }; + 79D2BF9C0ACFB51A00F3F141 /* NSNull.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSNull.m; path = ../MiscMerge/NSNull.m; sourceTree = ""; }; + 79D2BF9D0ACFB51A00F3F141 /* NSScanner+MiscMerge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSScanner+MiscMerge.h"; path = "../MiscMerge/NSScanner+MiscMerge.h"; sourceTree = ""; }; + 79D2BF9E0ACFB51A00F3F141 /* NSScanner+MiscMerge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSScanner+MiscMerge.m"; path = "../MiscMerge/NSScanner+MiscMerge.m"; sourceTree = ""; }; + 79D2BF9F0ACFB51A00F3F141 /* NSString+MiscAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+MiscAdditions.h"; path = "../MiscMerge/NSString+MiscAdditions.h"; sourceTree = ""; }; + 79D2BFA00ACFB51A00F3F141 /* NSString+MiscAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+MiscAdditions.m"; path = "../MiscMerge/NSString+MiscAdditions.m"; sourceTree = ""; }; + 79D2C0570ACFBCB500F3F141 /* FoundationAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoundationAdditions.h; sourceTree = ""; }; + 79D2C0580ACFBCB500F3F141 /* FoundationAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FoundationAdditions.m; sourceTree = ""; }; 8DD76FA10486AA7600D96B5E /* mogenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mogenerator; sourceTree = BUILT_PRODUCTS_DIR; }; + D03C79F11B8BE77500A49BD8 /* NSString+MORegEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+MORegEx.h"; path = "categories/NSString+MORegEx.h"; sourceTree = ""; }; + D03C79F21B8BE77500A49BD8 /* NSString+MORegEx.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+MORegEx.m"; path = "categories/NSString+MORegEx.m"; sourceTree = ""; }; EE5ED86517332E020013CCD1 /* NSManagedObjectModel+momcom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectModel+momcom.h"; sourceTree = ""; }; EE5ED86617332E020013CCD1 /* NSManagedObjectModel+momcom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObjectModel+momcom.m"; sourceTree = ""; }; EE5ED86717332E020013CCD1 /* NSEntityDescription+momcom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSEntityDescription+momcom.h"; sourceTree = ""; }; @@ -224,10 +223,9 @@ children = ( 08FB7796FE84155DC02AAC07 /* mogenerator.m */, 79A586510E48E8B400474C35 /* mogenerator.h */, - 79D2C00E0ACFB81200F3F141 /* nsenumerate.h */, - 7931E67910FE984F00175784 /* RegexKitLite.h */, - 7931E67A10FE984F00175784 /* RegexKitLite.m */, 32A70AAB03705E1F00C91783 /* mogenerator_Prefix.pch */, + D03C79F11B8BE77500A49BD8 /* NSString+MORegEx.h */, + D03C79F21B8BE77500A49BD8 /* NSString+MORegEx.m */, ); name = Source; sourceTree = ""; @@ -415,6 +413,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { + LastUpgradeCheck = 0700; }; buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "mogenerator" */; compatibilityVersion = "Xcode 3.2"; @@ -439,8 +438,15 @@ files = ( ); inputPaths = ( + "$(SRCROOT)/templates/human.m.motemplate", + "$(SRCROOT)/templates/human.h.motemplate", + "$(SRCROOT)/templates/human.swift.motemplate", + "$(SRCROOT)/templates/machine.h.motemplate", + "$(SRCROOT)/templates/machine.m.motemplate", + "$(SRCROOT)/templates/machine.swift.motemplate", ); outputPaths = ( + "$(DERIVED_FILE_DIR)/motemplate-Info.plist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -498,7 +504,6 @@ 55200E970C49FEEA00018A42 /* DDCliUtil.m in Sources */, 55200E980C49FEEA00018A42 /* DDGetoptLongParser.m in Sources */, 55200F9D0C4A2CA800018A42 /* DDCliParseException.m in Sources */, - 7931E67B10FE984F00175784 /* RegexKitLite.m in Sources */, 457C26CD139A1EF900BF00DD /* MKCDAGNode.m in Sources */, 457C26CE139A1EF900BF00DD /* MKCNSEntityDescriptionAdditions.m in Sources */, 457C26CF139A1EF900BF00DD /* MKCNSManagedObjectModelAdditions.m in Sources */, @@ -507,6 +512,7 @@ EE5ED87517332E020013CCD1 /* NSAttributeDescription+momcom.m in Sources */, EE5ED87617332E020013CCD1 /* NSPropertyDescription+momcom.m in Sources */, EE5ED87717332E020013CCD1 /* NSRelationshipDescription+momcom.m in Sources */, + D03C79F31B8BE77500A49BD8 /* NSString+MORegEx.m in Sources */, EE5ED87817332E020013CCD1 /* NSFetchedPropertyDescription+momcom.m in Sources */, EE5ED87917332E020013CCD1 /* NSFetchRequest+momcom.m in Sources */, ); @@ -518,6 +524,7 @@ 1DEB927508733DD40010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_DYNAMIC_NO_PIC = NO; @@ -531,7 +538,7 @@ "-sectcreate", __TEXT, __info_plist, - "$TMPDIR/mogenerator-Info.plist", + "$(DERIVED_FILE_DIR)/mogenerator-Info.plist", ); PRODUCT_NAME = mogenerator; WARNING_CFLAGS = "-Wall"; @@ -541,6 +548,7 @@ 1DEB927608733DD40010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_MODULES = YES; DEPLOYMENT_POSTPROCESSING = NO; GCC_C_LANGUAGE_STANDARD = c99; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; @@ -552,7 +560,7 @@ "-sectcreate", __TEXT, __info_plist, - "$TMPDIR/mogenerator-Info.plist", + "$(DERIVED_FILE_DIR)/mogenerator-Info.plist", ); PRODUCT_NAME = mogenerator; WARNING_CFLAGS = "-Wall"; @@ -562,8 +570,9 @@ 1DEB927908733DD40010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(NATIVE_ARCH_ACTUAL)"; - MACOSX_DEPLOYMENT_TARGET = 10.6; + ENABLE_TESTABILITY = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; }; name = Debug; @@ -571,8 +580,7 @@ 1DEB927A08733DD40010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - MACOSX_DEPLOYMENT_TARGET = 10.6; + MACOSX_DEPLOYMENT_TARGET = 10.8; SDKROOT = macosx; }; name = Release; diff --git a/mogenerator.xcodeproj/xcshareddata/xcschemes/mogenerator.xcscheme b/mogenerator.xcodeproj/xcshareddata/xcschemes/mogenerator.xcscheme new file mode 100644 index 00000000..724c064f --- /dev/null +++ b/mogenerator.xcodeproj/xcshareddata/xcschemes/mogenerator.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mogenerator_Prefix.pch b/mogenerator_Prefix.pch index f7088002..a9d1f0c3 100644 --- a/mogenerator_Prefix.pch +++ b/mogenerator_Prefix.pch @@ -1,7 +1,3 @@ -// -// Prefix header for all source files of the 'mogenerator' target in the 'mogenerator' project. -// - #ifdef __OBJC__ - #import +@import Foundation; #endif diff --git a/momcom/NSAttributeDescription+momcom.h b/momcom/NSAttributeDescription+momcom.h index f9f8adea..76ebe39d 100644 --- a/momcom/NSAttributeDescription+momcom.h +++ b/momcom/NSAttributeDescription+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSAttributeDescription (momcom) diff --git a/momcom/NSEntityDescription+momcom.h b/momcom/NSEntityDescription+momcom.h index bf8e8603..e0ecac1b 100644 --- a/momcom/NSEntityDescription+momcom.h +++ b/momcom/NSEntityDescription+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSEntityDescription (momcom) diff --git a/momcom/NSFetchRequest+momcom.h b/momcom/NSFetchRequest+momcom.h index bf2a967c..50b938d3 100644 --- a/momcom/NSFetchRequest+momcom.h +++ b/momcom/NSFetchRequest+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSFetchRequest (momcom) diff --git a/momcom/NSFetchedPropertyDescription+momcom.h b/momcom/NSFetchedPropertyDescription+momcom.h index 0fb7ad44..2e751f6f 100644 --- a/momcom/NSFetchedPropertyDescription+momcom.h +++ b/momcom/NSFetchedPropertyDescription+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSFetchedPropertyDescription (momcom) diff --git a/momcom/NSManagedObjectModel+momcom.h b/momcom/NSManagedObjectModel+momcom.h index 272b1f6b..be2716e8 100644 --- a/momcom/NSManagedObjectModel+momcom.h +++ b/momcom/NSManagedObjectModel+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSManagedObjectModel (momcom) diff --git a/momcom/NSPropertyDescription+momcom.h b/momcom/NSPropertyDescription+momcom.h index 038e3a70..e9971f94 100644 --- a/momcom/NSPropertyDescription+momcom.h +++ b/momcom/NSPropertyDescription+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSPropertyDescription (momcom) diff --git a/momcom/NSPropertyDescription+momcom.m b/momcom/NSPropertyDescription+momcom.m index 1e9841ca..30436d9d 100644 --- a/momcom/NSPropertyDescription+momcom.m +++ b/momcom/NSPropertyDescription+momcom.m @@ -19,6 +19,9 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode } NSPropertyDescription *propertyDescription = [[self alloc] init]; + BOOL optional = NO; + BOOL transient = NO; + BOOL indexed = NO; BOOL syncable = NO; for (NSXMLNode *xmlAttribute in [xmlNode attributes]) { @@ -27,11 +30,11 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode if ([attributeName isEqualToString:@"name"]) { [propertyDescription setName:attributeString]; } else if ([attributeName isEqualToString:@"optional"]) { - [propertyDescription setOptional:[attributeString isEqualToString:@"YES"]]; + optional = [attributeString isEqualToString:@"YES"]; } else if ([attributeName isEqualToString:@"transient"]) { - [propertyDescription setTransient:[attributeString isEqualToString:@"YES"]]; + transient = [attributeString isEqualToString:@"YES"]; } else if ([attributeName isEqualToString:@"indexed"]) { - [propertyDescription setIndexed:[attributeString isEqualToString:@"YES"]]; + indexed = [attributeString isEqualToString:@"YES"]; } else if ([attributeName isEqualToString:@"syncable"]) { syncable = [attributeString isEqualToString:@"YES"]; } else if ([attributeName isEqualToString:@"versionHashModifier"]) { @@ -40,6 +43,11 @@ + (id)baseEntityForXML:(NSXMLElement *)xmlNode [propertyDescription setRenamingIdentifier:attributeString]; } } + + [propertyDescription setOptional:optional]; + [propertyDescription setTransient:transient]; + [propertyDescription setIndexed:indexed]; + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; diff --git a/momcom/NSRelationshipDescription+momcom.h b/momcom/NSRelationshipDescription+momcom.h index dc87226b..17f6a6bc 100644 --- a/momcom/NSRelationshipDescription+momcom.h +++ b/momcom/NSRelationshipDescription+momcom.h @@ -6,7 +6,7 @@ // Copyright (c) 2013 Tom Harrington. All rights reserved. // -#import +@import CoreData; @interface NSRelationshipDescription (momcom) diff --git a/nsenumerate.h b/nsenumerate.h deleted file mode 100644 index e43904dd..00000000 --- a/nsenumerate.h +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************************** - nsenumerate.h $Revision: 1.0 $ - - Copyright (c) 2003 Red Shed Software. All rights reserved. - by Jonathan 'Wolf' Rentzsch (jon at redshed dot net) - - Wed Oct 8 2003 wolf: Created. - - ************************************************************************************/ - -#import - -#define nsenumerate_getEnumerator( TYPE, OBJ ) \ - (TYPE)([OBJ isKindOfClass:[NSEnumerator class]] \ - ? OBJ \ - : [OBJ performSelector:@selector(objectEnumerator)]) - -#define nsenumerate( CONTAINER, ITERATOR_TYPE, ITERATOR_SYMBOL ) \ -for( ITERATOR_TYPE \ - *enumerator = nsenumerate_getEnumerator(ITERATOR_TYPE*, CONTAINER), \ - *ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject]; \ - ITERATOR_SYMBOL != nil; \ - ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject] ) - -#define nsenumerat( CONTAINER, ITERATOR_SYMBOL ) \ -for( id \ - enumerator = nsenumerate_getEnumerator(id, CONTAINER), \ - ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject]; \ - ITERATOR_SYMBOL != nil; \ - ITERATOR_SYMBOL = [((NSEnumerator*) enumerator) nextObject] ) diff --git a/ponso/MKCDAGNode.h b/ponso/MKCDAGNode.h index bb16510e..1b3614b5 100644 --- a/ponso/MKCDAGNode.h +++ b/ponso/MKCDAGNode.h @@ -17,7 +17,7 @@ Created by Nikita Zhuk on 22.1.2011. */ -#import +@import Foundation; /** Generic DAG (Directed Acyclic Graph) implementation @@ -34,7 +34,7 @@ //! All objects of nodes in topological order which are reachable from the receiver. @property(nonatomic, readonly) NSArray *objectsInTopologicalOrder; -- (id)initWithObject:(id)object; +- (instancetype)initWithObject:(id)object; /** Creates dependency between receiver and the given node and adds the given node into the DAG. diff --git a/ponso/MKCDAGNode.m b/ponso/MKCDAGNode.m index 6c722748..e6a0beed 100644 --- a/ponso/MKCDAGNode.m +++ b/ponso/MKCDAGNode.m @@ -74,7 +74,7 @@ + (void)visitNode:(MKCDAGNode *)node visitedNodes:(NSMutableSet *)visitedNodes o #pragma mark Public -- (id)initWithObject:(id)anObject +- (instancetype)initWithObject:(id)anObject { if((self = [super init])) { diff --git a/ponso/MKCNSEntityDescriptionAdditions.h b/ponso/MKCNSEntityDescriptionAdditions.h index e4007744..e0681aa4 100644 --- a/ponso/MKCNSEntityDescriptionAdditions.h +++ b/ponso/MKCNSEntityDescriptionAdditions.h @@ -17,7 +17,7 @@ Created by Nikita Zhuk on 22.1.2011. */ -#import +@import CoreData; @interface NSEntityDescription(MKCNSEntityDescriptionAdditions) diff --git a/ponso/MKCNSManagedObjectModelAdditions.h b/ponso/MKCNSManagedObjectModelAdditions.h index 94db08e0..15187130 100644 --- a/ponso/MKCNSManagedObjectModelAdditions.h +++ b/ponso/MKCNSManagedObjectModelAdditions.h @@ -17,7 +17,7 @@ Created by Nikita Zhuk on 22.1.2011. */ -#import +@import CoreData; @protocol MKCNSRelationshipDescriptionDependencyFilter diff --git a/templates/human.h.motemplate b/templates/human.h.motemplate index e3f3de05..145389c7 100644 --- a/templates/human.h.motemplate +++ b/templates/human.h.motemplate @@ -1,5 +1,5 @@ #import "_<$managedObjectClassName$>.h" -@interface <$managedObjectClassName$> : _<$managedObjectClassName$> {} +@interface <$managedObjectClassName$> : _<$managedObjectClassName$> // Custom logic goes here. @end diff --git a/templates/human.swift.motemplate b/templates/human.swift.motemplate index b743d874..3abb1aa5 100644 --- a/templates/human.swift.motemplate +++ b/templates/human.swift.motemplate @@ -1,6 +1,6 @@ -@objc(<$managedObjectClassName$>) -public class <$managedObjectClassName$>: _<$managedObjectClassName$> { +import Foundation +@objc(<$managedObjectClassName$>) +open class <$managedObjectClassName$>: _<$managedObjectClassName$> { // Custom logic goes here. - } diff --git a/templates/machine.h.motemplate b/templates/machine.h.motemplate index da33f108..34202b20 100644 --- a/templates/machine.h.motemplate +++ b/templates/machine.h.motemplate @@ -1,7 +1,15 @@ // DO NOT EDIT. This file is machine-generated and constantly overwritten. // Make changes to <$managedObjectClassName$>.h instead. -<$if TemplateVar.modules$>@import CoreData;<$else$>#import <$endif$> +#if __has_feature(modules) + @import Foundation; + @import CoreData; +#else + #import + #import +#endif + + <$if hasCustomSuperentity$><$if hasSuperentity$>#import "<$customSuperentity$>.h" <$else$><$if hasCustomBaseCaseImport$>#import <$baseClassImport$><$else$>#import "<$customSuperentity$>.h"<$endif$><$endif$><$endif$> @@ -9,29 +17,7 @@ #import "<$additionalHeaderFileName$>" <$endif$> -<$if noninheritedAttributes.@count > 0$> -extern const struct <$managedObjectClassName$>Attributes {<$foreach Attribute noninheritedAttributes do$> - <$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Attribute.name$>;<$endforeach do$> -} <$managedObjectClassName$>Attributes; -<$endif$> - -<$if noninheritedRelationships.@count > 0$> -extern const struct <$managedObjectClassName$>Relationships {<$foreach Relationship noninheritedRelationships do$> - <$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Relationship.name$>;<$endforeach do$> -} <$managedObjectClassName$>Relationships; -<$endif$> - -<$if noninheritedFetchedProperties.@count > 0$> -extern const struct <$managedObjectClassName$>FetchedProperties {<$foreach FetchedProperty noninheritedFetchedProperties do$> - <$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$FetchedProperty.name$>;<$endforeach do$> -} <$managedObjectClassName$>FetchedProperties; -<$endif$> - -<$if hasUserInfoKeys$> -extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userInfoKeyValues do$> - <$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$UserInfo.key$>;<$endforeach do$> -} <$managedObjectClassName$>UserInfo; -<$endif$> +NS_ASSUME_NONNULL_BEGIN <$foreach Relationship noninheritedRelationships do$>@class <$Relationship.destinationEntity.managedObjectClassName$>; <$endforeach do$> @@ -52,11 +38,12 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI * <$userInfo.discussion$> */ <$endif$> -@interface _<$managedObjectClassName$> : <$customSuperentity$> {} -+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_; + +@interface _<$managedObjectClassName$> : <$customSuperentity$> ++ (instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)moc_; + (NSString*)entityName; -+ (NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; -@property (nonatomic, readonly, strong) <$managedObjectClassName$>ID* objectID; ++ (nullable NSEntityDescription*)entityInManagedObjectContext:(NSManagedObjectContext*)moc_; +@property (nonatomic, readonly, strong) <$managedObjectClassName$>ID *objectID; <$foreach Attribute noninheritedAttributes do$> <$if Attribute.userInfo.documentation$> @@ -67,18 +54,17 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI */ <$endif$> <$if Attribute.hasDefinedAttributeType$> -<$if TemplateVar.arc$> +<$if (Attribute.hasScalarAttributeType && !Attribute.optional && TemplateVar.scalarsWhenNonOptional)$> <$if Attribute.isReadonly$> -@property (nonatomic, strong, readonly) <$Attribute.objectAttributeType$> <$Attribute.name$>; +@property (atomic, readonly) <$Attribute.scalarAttributeType$> <$Attribute.name$>; <$else$> -@property (nonatomic, strong) <$Attribute.objectAttributeType$> <$Attribute.name$>; +@property (atomic) <$Attribute.scalarAttributeType$> <$Attribute.name$>; <$endif$> <$else$> <$if Attribute.isReadonly$> -@property (nonatomic, retain, readonly) <$Attribute.objectAttributeType$> <$Attribute.name$>; +@property (nonatomic, strong, readonly<$if Attribute.optional$>, nullable<$endif$>) <$Attribute.objectAttributeType$> <$Attribute.name$>; <$else$> -@property (nonatomic, retain) <$Attribute.objectAttributeType$> <$Attribute.name$>; -<$endif$> +@property (nonatomic, strong<$if Attribute.optional$>, nullable<$endif$>) <$Attribute.objectAttributeType$> <$Attribute.name$>; <$endif$> <$if Attribute.hasScalarAttributeType$> <$if Attribute.isReadonly$> @@ -90,7 +76,7 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI - (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_; <$endif$> <$endif$> -//- (BOOL)validate<$Attribute.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_; +<$endif$> <$endif$> <$endforeach do$> <$foreach Relationship noninheritedRelationships do$> @@ -102,25 +88,16 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI */ <$endif$> <$if Relationship.isToMany$> -<$if TemplateVar.arc$> -@property (nonatomic, strong) <$Relationship.immutableCollectionClassName$> *<$Relationship.name$>; -<$else$> -@property (nonatomic, retain) <$Relationship.immutableCollectionClassName$> *<$Relationship.name$>; -<$endif$> -- (<$Relationship.mutableCollectionClassName$>*)<$Relationship.name$>Set; -<$else$> -<$if TemplateVar.arc$> -@property (nonatomic, strong) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; +@property (nonatomic, strong<$if Relationship.optional$>, nullable<$endif$>) <$Relationship.immutableCollectionClassName$> *<$Relationship.name$>; +- (<$if Relationship.optional$>nullable <$endif$><$Relationship.mutableCollectionClassName$>*)<$Relationship.name$>Set; <$else$> -@property (nonatomic, retain) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; -<$endif$> -//- (BOOL)validate<$Relationship.name.initialCapitalString$>:(id*)value_ error:(NSError**)error_; +@property (nonatomic, strong<$if Relationship.optional$>, nullable<$endif$>) <$Relationship.destinationEntity.managedObjectClassName$> *<$Relationship.name$>; <$endif$> <$endforeach do$> <$foreach FetchRequest prettyFetchRequests do$> <$if FetchRequest.singleResult$> -+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>; -+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>error:(NSError**)error_; ++ (instancetype)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>; ++ (instancetype)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>error:(NSError**)error_; <$else$> + (NSArray*)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>; + (NSArray*)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>error:(NSError**)error_; @@ -134,7 +111,7 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI * <$FetchedProperty.userInfo.discussion$> */ <$endif$> -@property (nonatomic, readonly) NSArray *<$FetchedProperty.name$>; +@property (nonatomic, readonly<$if FetchedProperty.optional$>, nullable<$endif$>) NSArray *<$FetchedProperty.name$>; <$endforeach do$> <$if TemplateVar.frc$> #if TARGET_OS_IPHONE @@ -169,8 +146,8 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI @interface _<$managedObjectClassName$> (CoreDataGeneratedPrimitiveAccessors) <$foreach Attribute noninheritedAttributesSansType do$> <$if Attribute.hasDefinedAttributeType$> -- (<$Attribute.objectAttributeType$>)primitive<$Attribute.name.initialCapitalString$>; -- (void)setPrimitive<$Attribute.name.initialCapitalString$>:(<$Attribute.objectAttributeType$>)value; +- (<$if Attribute.optional$>nullable <$endif$><$Attribute.objectAttributeType$>)primitive<$Attribute.name.initialCapitalString$>; +- (void)setPrimitive<$Attribute.name.initialCapitalString$>:(<$if Attribute.optional$>nullable <$endif$><$Attribute.objectAttributeType$>)value; <$if Attribute.hasScalarAttributeType$> - (<$Attribute.scalarAttributeType$>)primitive<$Attribute.name.initialCapitalString$>Value; - (void)setPrimitive<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_; @@ -187,3 +164,30 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI <$endif$> <$endforeach do$> @end + + +<$if noninheritedAttributes.@count > 0$> +@interface <$managedObjectClassName$>Attributes: NSObject <$foreach Attribute noninheritedAttributes do$> ++ (NSString *)<$Attribute.name$>;<$endforeach do$> +@end +<$endif$> + +<$if noninheritedRelationships.@count > 0$> +@interface <$managedObjectClassName$>Relationships: NSObject<$foreach Relationship noninheritedRelationships do$> ++ (NSString *)<$Relationship.name$>;<$endforeach do$> +@end +<$endif$> + +<$if noninheritedFetchedProperties.@count > 0$> +@interface <$managedObjectClassName$>FetchedProperties: NSObject<$foreach FetchedProperty noninheritedFetchedProperties do$> ++ (NSString *)<$FetchedProperty.name$>;<$endforeach do$> +@end +<$endif$> + +<$if hasUserInfoKeys$> +@interface <$managedObjectClassName$>UserInfo: NSObject <$foreach UserInfo userInfoKeyValues do$> ++ (NSString *)<$UserInfo.key$>;<$endforeach do$> +@end +<$endif$> + +NS_ASSUME_NONNULL_END diff --git a/templates/machine.m.motemplate b/templates/machine.m.motemplate index e4fb5c8e..70129f2c 100644 --- a/templates/machine.m.motemplate +++ b/templates/machine.m.motemplate @@ -3,36 +3,12 @@ #import "_<$managedObjectClassName$>.h" -<$if noninheritedAttributes.@count > 0$> -const struct <$managedObjectClassName$>Attributes <$managedObjectClassName$>Attributes = {<$foreach Attribute noninheritedAttributes do$> - .<$Attribute.name$> = @"<$Attribute.name$>",<$endforeach do$> -}; -<$endif$> - -<$if noninheritedRelationships.@count > 0$> -const struct <$managedObjectClassName$>Relationships <$managedObjectClassName$>Relationships = {<$foreach Relationship noninheritedRelationships do$> - .<$Relationship.name$> = @"<$Relationship.name$>",<$endforeach do$> -}; -<$endif$> - -<$if noninheritedFetchedProperties.@count > 0$> -const struct <$managedObjectClassName$>FetchedProperties <$managedObjectClassName$>FetchedProperties = {<$foreach FetchedProperty noninheritedFetchedProperties do$> - .<$FetchedProperty.name$> = @"<$FetchedProperty.name$>",<$endforeach do$> -}; -<$endif$> - -<$if hasUserInfoKeys$> -const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserInfo = {<$foreach UserInfo userInfoKeyValues do$> - .<$UserInfo.key$> = @"<$UserInfo.value$>",<$endforeach do$> -}; -<$endif$> - @implementation <$managedObjectClassName$>ID @end @implementation _<$managedObjectClassName$> -+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ { ++ (instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)moc_ { NSParameterAssert(moc_); return [NSEntityDescription insertNewObjectForEntityForName:@"<$name$>" inManagedObjectContext:moc_]; } @@ -52,7 +28,7 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn + (NSSet*)keyPathsForValuesAffectingValueForKey:(NSString*)key { NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; - <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$if Attribute.hasScalarAttributeType$> + <$foreach Attribute noninheritedAttributes do$><$if Attribute.hasDefinedAttributeType$><$if Attribute.hasScalarAttributeType && (Attribute.optional || !TemplateVar.scalarsWhenNonOptional)$> if ([key isEqualToString:@"<$Attribute.name$>Value"]) { NSSet *affectingKey = [NSSet setWithObject:@"<$Attribute.name$>"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; @@ -68,6 +44,22 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn @dynamic <$Attribute.name$>; <$if Attribute.hasScalarAttributeType$> +<$if (!Attribute.optional && TemplateVar.scalarsWhenNonOptional)$> +- (<$Attribute.scalarAttributeType$>)<$Attribute.name$> { + [self willAccessValueForKey:@"<$Attribute.name$>"]; + NSNumber *result = [self primitive<$Attribute.name.initialCapitalString$>]; + [self didAccessValueForKey:@"<$Attribute.name$>"]; + return [result <$Attribute.scalarAccessorMethodName$>]; +} + +<$if ! Attribute.isReadonly$> +- (void)set<$Attribute.name.initialCapitalString$>:(<$Attribute.scalarAttributeType$>)value_ { + [self willChangeValueForKey:@"<$Attribute.name$>"]; + [self setPrimitive<$Attribute.name.initialCapitalString$>:@(value_)]; + [self didChangeValueForKey:@"<$Attribute.name$>"]; +} +<$endif$> +<$else$> - (<$Attribute.scalarAttributeType$>)<$Attribute.name$>Value { NSNumber *result = [self <$Attribute.name$>]; @@ -76,7 +68,7 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn <$if ! Attribute.isReadonly$> - (void)set<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ { - [self set<$Attribute.name.initialCapitalString$>:<$if TemplateVar.literals$>@(value_)<$else$>[NSNumber <$Attribute.scalarFactoryMethodName$>value_]<$endif$>]; + [self set<$Attribute.name.initialCapitalString$>:@(value_)]; } <$endif$> @@ -87,11 +79,12 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn } - (void)setPrimitive<$Attribute.name.initialCapitalString$>Value:(<$Attribute.scalarAttributeType$>)value_ { - [self setPrimitive<$Attribute.name.initialCapitalString$>:<$if TemplateVar.literals$>@(value_)<$else$>[NSNumber <$Attribute.scalarFactoryMethodName$>value_]<$endif$>]; + [self setPrimitive<$Attribute.name.initialCapitalString$>:@(value_)]; } <$endif$> <$endif$> <$endif$> +<$endif$> <$endforeach do$> <$foreach Relationship noninheritedRelationships do$> @@ -117,7 +110,7 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn <$foreach FetchRequest prettyFetchRequests do$> <$if FetchRequest.singleResult$> -+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>{ ++ (instancetype)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>{ NSError *error = nil; id result = [self fetch<$FetchRequest.name.initialCapitalString$>:moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:<$Binding.name$>_ <$endforeach do2$>error:&error]; if (error) { @@ -129,19 +122,15 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn } return result; } -+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>error:(NSError**)error_ { ++ (instancetype)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_ <$endforeach do2$>error:(NSError**)error_ { NSParameterAssert(moc_); NSError *error = nil; NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel]; <$if FetchRequest.hasBindings$> - NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys: - <$foreach Binding FetchRequest.bindings do2$> - <$Binding.name$>_, @"<$Binding.name$>", - <$endforeach do2$> - nil]; + NSDictionary *substitutionVariables = @{<$foreach Binding FetchRequest.bindings doVar$>@"<$Binding.name$>": <$Binding.name$>_<$if BindingIndex < FetchRequest.bindings.@count - 1$>, <$endif$><$endforeach doVar$>}; <$else$> - NSDictionary *substitutionVariables = [NSDictionary dictionary]; + NSDictionary *substitutionVariables = @{}; <$endif$> NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"<$FetchRequest.name$>" substitutionVariables:substitutionVariables]; @@ -156,7 +145,7 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn // Nothing found matching the fetch request. That's cool, though: we'll just return nil. break; case 1: - result = [results objectAtIndex:0]; + result = results.firstObject; break; default: NSLog(@"WARN fetch request <$FetchRequest.name$>: 0 or 1 objects expected, %lu found (substitutionVariables:%@, results:%@)", @@ -188,13 +177,9 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel]; <$if FetchRequest.hasBindings$> - NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys: - <$foreach Binding FetchRequest.bindings do2$> - <$Binding.name$>_, @"<$Binding.name$>", - <$endforeach do2$> - nil]; + NSDictionary *substitutionVariables = @{<$foreach Binding FetchRequest.bindings doVar$>@"<$Binding.name$>": <$Binding.name$>_<$if BindingIndex < FetchRequest.bindings.@count - 1$>, <$endif$><$endforeach doVar$>}; <$else$> - NSDictionary *substitutionVariables = [NSDictionary dictionary]; + NSDictionary *substitutionVariables = @{}; <$endif$> NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"<$FetchRequest.name$>" substitutionVariables:substitutionVariables]; @@ -212,12 +197,11 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn <$if Relationship.isToMany$> - (NSFetchedResultsController*)new<$Relationship.name.initialCapitalString$>FetchedResultsControllerWithSortDescriptors:(NSArray*)sortDescriptors { NSFetchRequest *fetchRequest = [NSFetchRequest new]; - <$if !TemplateVar.arc$>[fetchRequest autorelease];<$endif$> fetchRequest.entity = [NSEntityDescription entityForName:@"<$Relationship.destinationEntity.name$>" inManagedObjectContext:self.managedObjectContext]; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"<$Relationship.inverseRelationship.name$> <$if Relationship.inverseRelationship.isToMany$>CONTAINS<$else$>==<$endif$> %@", self]; fetchRequest.sortDescriptors = sortDescriptors; <$if indexedNoninheritedAttributes.@count > 0$> - NSArray *indexedIDs = [NSArray arrayWithObjects:<$foreach Attribute indexedNoninheritedAttributes do$>self.<$Attribute.name$>, <$endforeach do$>nil]; + NSArray *indexedIDs = @[<$foreach Attribute indexedNoninheritedAttributes do$>self.<$Attribute.name$><$if AttributeIndex < indexedNoninheritedAttributes.@count - 1$>, <$endif$><$endforeach do$>]; NSString *cacheName = [NSString stringWithFormat:@"mogenerator.<$managedObjectClassName$>.%@.<$Relationship.name$>.%@", indexedIDs, sortDescriptors]; <$endif$> return [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest @@ -248,7 +232,7 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn - (void)insertObject:(<$Relationship.destinationEntity.managedObjectClassName$>*)value in<$Relationship.name.initialCapitalString$>AtIndex:(NSUInteger)idx { NSIndexSet* indexes = [NSIndexSet indexSetWithIndex:idx]; [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet insertObject:value atIndex:idx]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; @@ -256,21 +240,21 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn - (void)removeObjectFrom<$Relationship.name.initialCapitalString$>AtIndex:(NSUInteger)idx { NSIndexSet* indexes = [NSIndexSet indexSetWithIndex:idx]; [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet removeObjectAtIndex:idx]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; } - (void)insert<$Relationship.name.initialCapitalString$>:(NSArray *)value atIndexes:(NSIndexSet *)indexes { [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet insertObjects:value atIndexes:indexes]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; } - (void)remove<$Relationship.name.initialCapitalString$>AtIndexes:(NSIndexSet *)indexes { [self willChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet removeObjectsAtIndexes:indexes]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeRemoval valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; @@ -278,14 +262,14 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn - (void)replaceObjectIn<$Relationship.name.initialCapitalString$>AtIndex:(NSUInteger)idx withObject:(<$Relationship.destinationEntity.managedObjectClassName$>*)value { NSIndexSet* indexes = [NSIndexSet indexSetWithIndex:idx]; [self willChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet replaceObjectAtIndex:idx withObject:value]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; } - (void)replace<$Relationship.name.initialCapitalString$>AtIndexes:(NSIndexSet *)indexes with<$Relationship.name.initialCapitalString$>:(NSArray *)value { [self willChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; - NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>]]; + NSMutableOrderedSet *tmpOrderedSet = [NSMutableOrderedSet orderedSetWithOrderedSet:[self <$Relationship.name$>] ?: [NSOrderedSet orderedSet]]; [tmpOrderedSet replaceObjectsAtIndexes:indexes withObjects:value]; [self setPrimitiveValue:tmpOrderedSet forKey:@"<$Relationship.name$>"]; [self didChange:NSKeyValueChangeReplacement valuesAtIndexes:indexes forKey:@"<$Relationship.name$>"]; @@ -293,4 +277,34 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn @end <$endif$><$endif$><$endforeach do$> +<$if noninheritedAttributes.@count > 0$> +@implementation <$managedObjectClassName$>Attributes <$foreach Attribute noninheritedAttributes do$> ++ (NSString *)<$Attribute.name$> { + return @"<$Attribute.name$>"; +}<$endforeach do$> +@end +<$endif$> +<$if noninheritedRelationships.@count > 0$> +@implementation <$managedObjectClassName$>Relationships <$foreach Relationship noninheritedRelationships do$> ++ (NSString *)<$Relationship.name$> { + return @"<$Relationship.name$>"; +}<$endforeach do$> +@end +<$endif$> + +<$if noninheritedFetchedProperties.@count > 0$> +@implementation <$managedObjectClassName$>FetchedProperties <$foreach FetchedProperty noninheritedFetchedProperties do$> ++ (NSString *)<$FetchedProperty.name$> { + return @"<$FetchedProperty.name$>"; +}<$endforeach do$> +@end +<$endif$> + +<$if hasUserInfoKeys$> +@implementation <$managedObjectClassName$>UserInfo <$foreach UserInfo userInfoKeyValues do$> ++ (NSString *)<$UserInfo.key$> { + return @"<$UserInfo.value$>"; +}<$endforeach do$> +@end +<$endif$> diff --git a/templates/machine.swift.motemplate b/templates/machine.swift.motemplate index c5ccbdb5..d066485e 100644 --- a/templates/machine.swift.motemplate +++ b/templates/machine.swift.motemplate @@ -1,56 +1,59 @@ // DO NOT EDIT. This file is machine-generated and constantly overwritten. -// Make changes to <$managedObjectClassName$>.swift instead. +// Make changes to <$sanitizedManagedObjectClassName$>.swift instead. +import Foundation import CoreData - <$if hasCustomBaseCaseImport$>import <$baseClassImport$><$endif$> <$if noninheritedAttributes.@count > 0$> -public enum <$managedObjectClassName$>Attributes: String {<$foreach Attribute noninheritedAttributes do$> +public enum <$sanitizedManagedObjectClassName$>Attributes: String {<$foreach Attribute noninheritedAttributes do$> case <$Attribute.name$> = "<$Attribute.name$>"<$endforeach do$> } <$endif$> <$if noninheritedRelationships.@count > 0$> -public enum <$managedObjectClassName$>Relationships: String {<$foreach Relationship noninheritedRelationships do$> +public enum <$sanitizedManagedObjectClassName$>Relationships: String {<$foreach Relationship noninheritedRelationships do$> case <$Relationship.name$> = "<$Relationship.name$>"<$endforeach do$> } <$endif$> <$if noninheritedFetchedProperties.@count > 0$> -public enum <$managedObjectClassName$>FetchedProperties: String {<$foreach FetchedProperty noninheritedFetchedProperties do$> +public enum <$sanitizedManagedObjectClassName$>FetchedProperties: String {<$foreach FetchedProperty noninheritedFetchedProperties do$> case <$FetchedProperty.name$> = "<$FetchedProperty.name$>"<$endforeach do$> } <$endif$> -<$if hasUserInfoKeys$> -public enum <$managedObjectClassName$>UserInfo: String {<$foreach UserInfo userInfoKeyValues do$> - case <$UserInfo.key$> = "<$UserInfo.key$>"<$endforeach do$> -} +<$if hasUserInfoKeys && userInfoKeyValues.@count > 0$> +public enum <$sanitizedManagedObjectClassName$>UserInfo: String {<$foreach UserInfo userInfoKeyValues do$> + case <$UserInfo.key$> = "<$UserInfo.key$>"<$endforeach do$> +} <$endif$> -@objc public -class _<$managedObjectClassName$>: <$customSuperentity$> { +<$if hasCustomSuperentity $> +open class _<$sanitizedManagedObjectClassName$>: <$customSuperentity$> { +<$else$> +open class _<$sanitizedManagedObjectClassName$>: NSManagedObject { +<$endif$> // MARK: - Class methods - - <$if hasCustomSuperentity$>override <$endif$>public class func entityName () -> String { + + <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>open class func entityName () -> String { return "<$name$>" } - <$if hasCustomSuperentity$>override <$endif$>public class func entity(managedObjectContext: NSManagedObjectContext!) -> NSEntityDescription! { - return NSEntityDescription.entityForName(self.entityName(), inManagedObjectContext: managedObjectContext); + <$if (hasCustomSuperclass || (hasCustomSuperentity && TemplateVar.overrideBaseClass))$>override <$endif$>open class func entity(managedObjectContext: NSManagedObjectContext) -> NSEntityDescription? { + return NSEntityDescription.entity(forEntityName: self.entityName(), in: managedObjectContext) } // MARK: - Life cycle methods - public override init(entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext!) { - super.init(entity: entity, insertIntoManagedObjectContext: context) + public override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) { + super.init(entity: entity, insertInto: context) } - - public convenience init(managedObjectContext: NSManagedObjectContext!) { - let entity = _<$managedObjectClassName$>.entity(managedObjectContext) - self.init(entity: entity, insertIntoManagedObjectContext: managedObjectContext) + + public convenience init?(managedObjectContext: NSManagedObjectContext) { + guard let entity = _<$sanitizedManagedObjectClassName$>.entity(managedObjectContext: managedObjectContext) else { return nil } + self.init(entity: entity, insertInto: managedObjectContext) } // MARK: - Properties @@ -58,96 +61,107 @@ class _<$managedObjectClassName$>: <$customSuperentity$> { <$if Attribute.hasDefinedAttributeType$> <$if Attribute.hasScalarAttributeType$> <$if Attribute.isReadonly$> - @NSManaged public - let <$Attribute.name$>: NSNumber? + open var <$Attribute.name$>: NSNumber? + { + self.willAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) + let <$Attribute.name$> = self.primitiveValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) as? NSNumber + self.didAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) + return <$Attribute.name$> + } <$else$> - @NSManaged public + @NSManaged open var <$Attribute.name$>: NSNumber? <$endif$> <$else$> <$if Attribute.isReadonly$> - @NSManaged public - let <$Attribute.name$>: <$Attribute.objectAttributeType$><$if Attribute.isOptional$>?<$endif$> + open var <$Attribute.name$>: <$Attribute.objectAttributeType$><$if Attribute.isOptional$>?<$endif$> + { + self.willAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) + let <$Attribute.name$> = self.primitiveValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) as? <$Attribute.objectAttributeType$> + self.didAccessValueForKey(<$sanitizedManagedObjectClassName$>Attributes.<$Attribute.name$>.rawValue) + return <$Attribute.name$> + } <$else$> - @NSManaged public + @NSManaged open var <$Attribute.name$>: <$Attribute.objectAttributeType$><$if Attribute.isOptional$>?<$endif$> <$endif$> <$endif$> - // func validate<$Attribute.name.initialCapitalString$>(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} <$endif$> <$endforeach do$> // MARK: - Relationships <$foreach Relationship noninheritedRelationships do$> <$if Relationship.isToMany$> - @NSManaged public + @NSManaged open var <$Relationship.name$>: <$Relationship.immutableCollectionClassName$> -<$else$> - @NSManaged public - var <$Relationship.name$>: <$Relationship.destinationEntity.managedObjectClassName$><$if Relationship.isOptional$>?<$endif$> + open func <$Relationship.name$>Set() -> <$Relationship.mutableCollectionClassName$> { + return self.<$Relationship.name$>.mutableCopy() as! <$Relationship.mutableCollectionClassName$> + } - // func validate<$Relationship.name.initialCapitalString$>(value: AutoreleasingUnsafePointer, error: NSErrorPointer) {} +<$else$> + @NSManaged open + var <$Relationship.name$>: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$><$if Relationship.isOptional$>?<$endif$> <$endif$> <$endforeach do$> <$foreach FetchRequest prettyFetchRequests do$> <$if FetchRequest.singleResult$> - class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext!<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> AnyObject? { + class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> AnyObject? { return self.fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.name$><$endforeach do2$>, error: nil) } - class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext!<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> AnyObject? { - let model = managedObjectContext.persistentStoreCoordinator().managedObjectModel() + class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> AnyObject? { + guard let psc = managedObjectContext.persistentStoreCoordinator else { return nil } + let model = psc.managedObjectModel let substitutionVariables = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$> "<$Binding.name$>": <$Binding.name$>, -<$endforeach do2$><$endif$> ] + <$endforeach do2$><$endif$> + ] - let fetchRequest = model.fetchRequestFromTemplateWithName("<$FetchRequest.name$>", substitutionVariables: substitutionVariables) - assert(fetchRequest != nil, "Can't find fetch request named \"<$FetchRequest.name$>\".") + guard let fetchRequest = model.fetchRequestFromTemplateWithName("<$FetchRequest.name$>", substitutionVariables: substitutionVariables) else { + assert(false, "Can't find fetch request named \"<$FetchRequest.name$>\".") + return nil + } - var error: NSError? = nil var result: AnyObject? = nil - let results = managedObjectContext.executeFetchRequest(fetchRequest, error: &error) - - if error != nil { - outError.memory = error - } else { + do { + let results = try managedObjectContext.executeFetchRequest(fetchRequest) switch results.count { case 0: // Nothing found matching the fetch request. That's cool, though: we'll just return nil. break case 1: - result = results[0] + result = results.first default: - NSLog("WARN fetch request <$FetchRequest.name$>: 0 or 1 objects expected, %lu found (substitutionVariables:%@, results:%@)", - results.count, - substitutionVariables, - results); + print("WARN fetch request <$FetchRequest.name$>: 0 or 1 objects expected, \(results.count) found (substitutionVariables: \(substitutionVariables), results: \(results))") } - } - return result; + } catch { + print("Error executing fetch request: \(error)") + } + return result } <$else$> - class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext!<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> [AnyObject] { + class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>) -> [AnyObject]? { return self.fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.name$><$endforeach do2$>, error: nil) } - class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext!<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> [AnyObject]! { - let model = managedObjectContext.persistentStoreCoordinator!.managedObjectModel - let substitutionVariables : [NSObject : AnyObject] = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$> + class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> [AnyObject]? { + guard let psc = managedObjectContext.persistentStoreCoordinator else { return nil } + let model = psc.managedObjectModel + let substitutionVariables : [String : AnyObject] = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$> "<$Binding.name$>": <$Binding.name$>, <$endforeach do2$><$else$>:<$endif$>] let fetchRequest = model.fetchRequestFromTemplateWithName("<$FetchRequest.name$>", substitutionVariables: substitutionVariables) assert(fetchRequest != nil, "Can't find fetch request named \"<$FetchRequest.name$>\".") - var error: NSError? = nil - let results = managedObjectContext.executeFetchRequest(fetchRequest!, error: &error) - - if error != nil { - outError.memory = error + var results = Array() + do { + results = try managedObjectContext.executeFetchRequest(fetchRequest!) + } catch { + print("Error executing fetch request: \(error)") } return results @@ -156,35 +170,35 @@ class _<$managedObjectClassName$>: <$customSuperentity$> { <$endforeach do$> <$foreach FetchedProperty noninheritedFetchedProperties do$> - @NSManaged public - let <$FetchedProperty.name$>: [<$FetchedProperty.entity.managedObjectClassName$>] + @NSManaged open + let <$FetchedProperty.name$>: [<$FetchedProperty.entity.sanitizedManagedObjectClassName$>] <$endforeach do$> } <$foreach Relationship noninheritedRelationships do$><$if Relationship.isToMany$> -extension _<$managedObjectClassName$> { +extension _<$sanitizedManagedObjectClassName$> { - func add<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) { + open func add<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) { let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set - mutable.union<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set(objects as! Set) + mutable.union(objects<$if !Relationship.jr_isOrdered$> as Set<$endif$>) self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set } - func remove<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) { + open func remove<$Relationship.name.initialCapitalString$>(objects: <$Relationship.immutableCollectionClassName$>) { let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set - mutable.minus<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set(objects as! Set) + mutable.minus(objects<$if !Relationship.jr_isOrdered$> as Set<$endif$>) self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set } - func add<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.managedObjectClassName$>!) { + open func add<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$>) { let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set - mutable.addObject(value) + mutable.add(value) self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set } - func remove<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.managedObjectClassName$>!) { + open func remove<$Relationship.name.initialCapitalString$>Object(value: <$Relationship.destinationEntity.sanitizedManagedObjectClassName$>) { let mutable = self.<$Relationship.name$>.mutableCopy() as! NSMutable<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set - mutable.removeObject(value) + mutable.remove(value) self.<$Relationship.name$> = mutable.copy() as! NS<$if Relationship.jr_isOrdered$>Ordered<$endif$>Set } diff --git a/test/HumanMO.h b/test/HumanMO.h deleted file mode 100644 index c727c8dd..00000000 --- a/test/HumanMO.h +++ /dev/null @@ -1,9 +0,0 @@ -#import "_HumanMO.h" -#import - -@interface HumanMO : _HumanMO {} - -- (NSColor*)hairColor; -- (void)setHairColor:(NSColor*)value_; - -@end diff --git a/test/HumanMO.m b/test/HumanMO.m deleted file mode 100644 index 9715ba23..00000000 --- a/test/HumanMO.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "HumanMO.h" - -@implementation HumanMO - -- (NSColor*)hairColor { - NSData *storage = [self hairColorStorage]; - return storage ? [NSUnarchiver unarchiveObjectWithData:storage] : nil; -} - -- (void)setHairColor:(NSColor*)value_ { - NSData *storage = value_ ? [NSArchiver archivedDataWithRootObject:value_] : nil; - [self setHairColorStorage:storage]; -} - -@end diff --git a/test/MogenSwiftTest/MogenSwiftTest.xcodeproj/project.pbxproj b/test/MogenSwiftTest/MogenSwiftTest.xcodeproj/project.pbxproj index b91e35d3..90a9a423 100644 --- a/test/MogenSwiftTest/MogenSwiftTest.xcodeproj/project.pbxproj +++ b/test/MogenSwiftTest/MogenSwiftTest.xcodeproj/project.pbxproj @@ -182,6 +182,7 @@ 79F9CEC1196F146600D9BF82 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 0600; ORGANIZATIONNAME = "Jonathan 'Wolf' Rentzsch"; TargetAttributes = { diff --git a/test/MyProtocol.h b/test/MyProtocol.h deleted file mode 100644 index c43f8b22..00000000 --- a/test/MyProtocol.h +++ /dev/null @@ -1,2 +0,0 @@ -@protocol MyProtocol -@end \ No newline at end of file diff --git a/test/README.markdown b/test/README.markdown index 2f9b6469..a0d06215 100644 --- a/test/README.markdown +++ b/test/README.markdown @@ -27,19 +27,6 @@ If you're contributing to mogenerator, please ensure tests pass prior to issuing It does this for both MRC and ARC modes. -*Note:* if you encounter an error like this: - - $ rake - *** Clean-building mogenerator - xcodebuild: error: The project 'mogenerator' does not contain a scheme named 'mogenerator'. - rake aborted! - ERROR: xcodebuild -project ../mogenerator.xcodeproj -scheme mogenerator clean failed - /Users/wolf/Downloads/mogenerator/test/Rakefile:4:in `run_or_die' - /Users/wolf/Downloads/mogenerator/test/Rakefile:11:in `' - (See full trace by running task with --trace) - -Try opening mogenerator.xcodeproj in Xcode, closing the project and try again. That should "fix" it. *sigh* - Points of Highlight ------------------- diff --git a/test/Rakefile b/test/Rakefile index 3c25dac4..a203ba88 100644 --- a/test/Rakefile +++ b/test/Rakefile @@ -1,71 +1,72 @@ +#!/usr/bin/ruby +# Copyright (c) 2006-2016 Jonathan 'Wolf' Rentzsch: http://rentzsch.com +# Some rights reserved: http://opensource.org/licenses/mit +# http://github.com/rentzsch/mogenerator + def run_or_die(cmd) - #puts "*** #{cmd}" result = `#{cmd}` raise "ERROR: #{cmd} failed" if $?.exitstatus != 0 result end -puts "*** Clean-building mogenerator" -build_settings = run_or_die 'xcodebuild -project ../mogenerator.xcodeproj -configuration Debug -showBuildSettings' -built_products_dir = build_settings.lines.select{|line|line[/\sBUILT_PRODUCTS_DIR\s/]}[0].strip.sub('BUILT_PRODUCTS_DIR = ','') +#============================== +# Variables +#============================== +OSX_SDK="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk" +OSX_VERSION="10.10" +LINKED_FRAMEWORKS="-framework Foundation -framework AppKit -framework CoreData" + +BUILD_SETTINGS = run_or_die 'xcodebuild -project ../mogenerator.xcodeproj -configuration Debug -showBuildSettings' +BUILT_PRODUCTS_DIR = BUILD_SETTINGS.lines.select{|line|line[/\sBUILT_PRODUCTS_DIR\s/]}[0].strip.sub('BUILT_PRODUCTS_DIR = ','') +MOGENERATOR_PATH="#{BUILT_PRODUCTS_DIR}/mogenerator" + +puts "*** Clean-building mogenerator ***" + run_or_die 'xcodebuild -project ../mogenerator.xcodeproj -scheme mogenerator clean' # need this to pick up template changes run_or_die 'xcodebuild -project ../mogenerator.xcodeproj -scheme mogenerator' -mogenPath = "#{built_products_dir}/mogenerator" -def gen_and_compile(desc, mogenPath, extra_mogen_args, extra_gcc_args) - puts "*** Testing #{desc}" +def gen_and_compile_objc(mogenPath, extra_mogen_args, extra_llvm_args) + puts "*** Testing Objective-C" ENV['MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS'] = '1' run_or_die "#{mogenPath.gsub(/ /, '\\ ')} --model test.xcdatamodel --output MOs --baseClass MyBaseClass #{extra_mogen_args}" - run_or_die 'cp HumanMO.h HumanMO.m MyProtocol.h TestProtocol.m MOs' - run_or_die "clang -o testbin test.m MyBaseClass.m Gender.m MOs/*.m -I\"#{Dir.pwd}\" -framework Foundation -framework Cocoa -framework CoreData -fmodules #{extra_gcc_args}" + run_or_die 'cp ./objc/Gender.* ./objc/MyBaseClass.* MOs' + run_or_die "clang -o testbin ./objc/test.m MOs/*.m -I\"#{Dir.pwd}\" #{LINKED_FRAMEWORKS} -fmodules -isysroot #{OSX_SDK} -mmacosx-version-min=#{OSX_VERSION} -fobjc-arc #{extra_llvm_args}" run_or_die "xcrun momc -MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS test.xcdatamodel \"#{Dir.pwd}/test.mom\"" puts run_or_die './testbin' end -desc 'Generate, Compile and Run MRC Code (with objc literals)' -task :mrc do - gen_and_compile('MRC (with objc literals)', mogenPath, '', '') -end - -desc 'Generate, Compile and Run MRC Code (without objc literals)' -task :mrc_noliterals do - gen_and_compile('MRC (without objc literals)', mogenPath, '--template-var noliterals=true', '') +def gen_and_compile_swift(mogenPath, extra_mogen_args) + puts "*** Testing Swift" + ENV['MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS'] = '1' + run_or_die "#{mogenPath.gsub(/ /, '\\ ')} --swift --model test.xcdatamodel --output MOs --baseClass MyBaseClass #{extra_mogen_args}" + run_or_die 'cp ./swift/Gender.swift ./swift/MyBaseClass.swift MOs' + run_or_die "swiftc -o testbin ./swift/main.swift MOs/*.swift -sdk #{OSX_SDK} #{LINKED_FRAMEWORKS}" + run_or_die "xcrun momc -MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS test.xcdatamodel \"#{Dir.pwd}/test.mom\"" + puts run_or_die './testbin' end -desc 'Generate, Compile and Run ARC Code (with objc literals)' -task :arc do - gen_and_compile('ARC (with objc literals)', mogenPath, '--template-var arc=true', '-fobjc-arc') -end -desc 'Generate, Compile and Run ARC Code (without objc literals)' -task :arc_noliterals do - gen_and_compile('ARC (without objc literals)', mogenPath, '--template-var arc=true --template-var noliterals=true', '-fobjc-arc') +desc 'Generate, Compile and Run Objective-C' +task :objc do + Rake::Task[:clean].execute + gen_and_compile_objc(MOGENERATOR_PATH, '', '') + Rake::Task[:clean].execute end -desc 'Generate, Compile and Run ARC Code (without objc literals)' -task :v2 do +desc 'Generate, Compile and Run Swift' +task :swift do Rake::Task[:clean].execute - gen_and_compile('v2 (ARC + objc literals)', mogenPath, '--v2', '-fobjc-arc') + gen_and_compile_swift(MOGENERATOR_PATH, '') Rake::Task[:clean].execute end + desc 'Clean output' task :clean do run_or_die 'rm -rf MOs testbin test.mom' end task :default do - Rake::Task[:clean].execute - - Rake::Task[:mrc].execute - Rake::Task[:clean].execute - - Rake::Task[:mrc_noliterals].execute - Rake::Task[:clean].execute - - Rake::Task[:arc].execute - Rake::Task[:clean].execute - - Rake::Task[:arc_noliterals].execute - Rake::Task[:clean].execute -end \ No newline at end of file + Rake::Task[:objc].execute + Rake::Task[:swift].execute +end diff --git a/test/TestProtocol.h b/test/TestProtocol.h deleted file mode 100644 index 4b3a120a..00000000 --- a/test/TestProtocol.h +++ /dev/null @@ -1,6 +0,0 @@ -#import -#import "MyProtocol.h" - - -@interface TestProtocol : NSObject -@end \ No newline at end of file diff --git a/test/TestProtocol.m b/test/TestProtocol.m deleted file mode 100644 index f3ae1974..00000000 --- a/test/TestProtocol.m +++ /dev/null @@ -1,8 +0,0 @@ -#import "TestProtocol.h" - - -@implementation TestProtocol { - -} - -@end \ No newline at end of file diff --git a/test/Gender.h b/test/objc/Gender.h similarity index 97% rename from test/Gender.h rename to test/objc/Gender.h index 116d516e..7109f89a 100644 --- a/test/Gender.h +++ b/test/objc/Gender.h @@ -1,4 +1,5 @@ -#import +@import Foundation; + #import "JREnum/JREnum.h" // Mostly stolen from http://abcnews.go.com/blogs/headlines/2014/02/heres-a-list-of-58-gender-options-for-facebook-users/ diff --git a/test/Gender.m b/test/objc/Gender.m similarity index 100% rename from test/Gender.m rename to test/objc/Gender.m diff --git a/test/MyBaseClass.h b/test/objc/MyBaseClass.h similarity index 82% rename from test/MyBaseClass.h rename to test/objc/MyBaseClass.h index f99e6a5e..a5191357 100644 --- a/test/MyBaseClass.h +++ b/test/objc/MyBaseClass.h @@ -1,4 +1,4 @@ -#import +@import Cocoa; @interface MyBaseClass : NSManagedObject { double ivar; diff --git a/test/MyBaseClass.m b/test/objc/MyBaseClass.m similarity index 100% rename from test/MyBaseClass.m rename to test/objc/MyBaseClass.m diff --git a/test/ParentMO.m b/test/objc/ParentMO.m similarity index 100% rename from test/ParentMO.m rename to test/objc/ParentMO.m diff --git a/test/test-prefix.pch b/test/objc/test-prefix.pch similarity index 76% rename from test/test-prefix.pch rename to test/objc/test-prefix.pch index 7f8908e5..c658c968 100644 --- a/test/test-prefix.pch +++ b/test/objc/test-prefix.pch @@ -3,5 +3,5 @@ // #ifdef __OBJC__ - #import + @import Foundation; #endif diff --git a/test/objc/test.m b/test/objc/test.m new file mode 100644 index 00000000..29437f2c --- /dev/null +++ b/test/objc/test.m @@ -0,0 +1,79 @@ +@import Cocoa; + +#import "../MOs/MyBaseClass.h" +#import "../MOs/ParentMO.h" +#import "../MOs/ChildMO.h" +#import "../MOs/Gender.h" + +int main(int argc, char *argv[]) { + @autoreleasepool { + NSManagedObjectContext *moc; + {{ + NSURL *modelURL = [NSURL fileURLWithPath:@"test.mom"]; + assert(modelURL); + + NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + assert(model); + + NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; + assert(persistentStoreCoordinator); + + NSError *inMemoryStoreError = nil; + NSPersistentStore *persistentStore = [persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType + configuration:nil + URL:nil + options:nil + error:&inMemoryStoreError]; + + assert(persistentStore); + assert(!inMemoryStoreError); + + moc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; + moc.persistentStoreCoordinator = persistentStoreCoordinator; + assert(moc); + }} + + //-- + + ParentMO *homer = [ParentMO insertInManagedObjectContext:moc]; + homer.humanName = homer.parentName = @"homer"; + [homer setIvar:1.0]; + homer.genderValue = Gender_Male; + + ParentMO *marge = [ParentMO insertInManagedObjectContext:moc]; + marge.humanName = marge.parentName = @"marge"; + [marge setIvar:1.0]; + marge.genderValue = Gender_Female; + + assert([homer.children count] == 0); + assert([marge.children count] == 0); + + //-- + + ChildMO *bart = [ChildMO insertInManagedObjectContext:moc]; + bart.humanName = bart.childName = @"bart"; + [bart setIvar:1.0]; + bart.type = [NSNumber numberWithInt:64]; + bart.typeValue++; + + ChildMO *lisa = [ChildMO insertInManagedObjectContext:moc]; + lisa.humanName = lisa.childName = @"lisa"; + [lisa setIvar:1.0]; + + //-- + + NSError *saveError = nil; + BOOL saveSuccess = [moc save:&saveError]; + assert(saveSuccess); + assert(!saveError); + + //-- + + assert(homer.genderValue == Gender_Male); + assert(marge.genderValue == Gender_Female); + assert(bart.genderValue == Gender_Undefined); + assert([GenderToString(homer.genderValue) isEqualToString:@"Gender_Male"]); + } + puts("success"); + return 0; +} diff --git a/test/swift/Gender.swift b/test/swift/Gender.swift new file mode 100644 index 00000000..6f2b4443 --- /dev/null +++ b/test/swift/Gender.swift @@ -0,0 +1,53 @@ + +// Mostly stolen from http://abcnewsgocom/blogs/headlines/2014/02/heres-a-list-of-58-gender-options-for-facebook-users/ +enum Gender: Int32 { + case Undefined = 0, + Female, + Male, + Other, + Agender, + Androgyne, + Androgynous, + Bigender, + Cisgender, + CisgenderFemale, + CisgenderMale, + FemaleToMale, + GenderFluid, + GenderNonconforming, + GenderQuestioning, + GenderVariant, + Genderqueer, + Intersex, + MaleToFemale, + Neither, + Neutrois, + Nonbinary, + Pangender, + Trans, + TransStar, + TransFemale, + TransStarFemale, + TransMale, + TransStarMale, + TransPerson, + TransStarPerson, + Transfeminine, + Transgender, + TransgenderFemale, + TransgenderMale, + TransgenderPerson, + Transmasculine, + Transsexual, + TranssexualFemale, + TranssexualMale, + TranssexualPerson + + func toString() -> String { + return String(self) + } +} + +func ==(lhs: Gender, rhs: Gender) -> Bool { + return lhs.rawValue == rhs.rawValue +} diff --git a/test/swift/MyBaseClass.swift b/test/swift/MyBaseClass.swift new file mode 100644 index 00000000..23231198 --- /dev/null +++ b/test/swift/MyBaseClass.swift @@ -0,0 +1,6 @@ +import Foundation +import CoreData + +public class MyBaseClass: NSManagedObject { + var ivar: Double = -1.0 +} diff --git a/test/swift/main.swift b/test/swift/main.swift new file mode 100644 index 00000000..a74746c4 --- /dev/null +++ b/test/swift/main.swift @@ -0,0 +1,63 @@ +import Cocoa +import CoreData + +struct CoreDataStore { + let moc: NSManagedObjectContext + + init() { + let modelURL = NSURL(fileURLWithPath: "test.mom") + let model = NSManagedObjectModel(contentsOfURL: modelURL) + let psc = NSPersistentStoreCoordinator(managedObjectModel: model!) + + do { + try psc.addPersistentStoreWithType(NSInMemoryStoreType, configuration: nil, URL: nil, options: nil) + } catch { + assertionFailure("Can't bring up PSC") + } + + moc = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType) + moc.persistentStoreCoordinator = psc + } +} + +let dataStore = CoreDataStore() +let moc = dataStore.moc + +let homer = ParentMO(managedObjectContext: moc)! +homer.humanName = "homer" +homer.parentName = homer.humanName +homer.ivar = 1.0 +homer.gender = NSNumber(int: Gender.Male.rawValue) + +let marge = ParentMO(managedObjectContext: moc)! +marge.humanName = "marge" +marge.parentName = marge.humanName +marge.ivar = 1.0 +marge.gender = NSNumber(int: Gender.Female.rawValue) + +assert(homer.children.count == 0) +assert(marge.children.count == 0) + +let bart = ChildMO(managedObjectContext: moc)! +bart.humanName = "bart" +bart.childName = bart.humanName +bart.ivar = 1.0 +bart.type = 64 + +let lisa = ChildMO(managedObjectContext: moc)! +lisa.humanName = "lisa" +lisa.childName = lisa.humanName +lisa.ivar = 1.0 + +do { + try moc.save() + assert(Gender(rawValue: homer.gender!.intValue) == .Male) + assert(Gender(rawValue: marge.gender!.intValue) == .Female) + assert(Gender(rawValue: bart.gender!.intValue) == .Undefined) + assert(Gender(rawValue: homer.gender!.intValue)!.toString() == "Male") + +} catch { + assertionFailure("Failed to save") +} + +print("Success") diff --git a/test/test.m b/test/test.m deleted file mode 100644 index 3b84455f..00000000 --- a/test/test.m +++ /dev/null @@ -1,116 +0,0 @@ -#import -#import "MyBaseClass.h" -#import "MOs/ParentMO.h" -#import "MOs/ChildMO.h" -#import "TestProtocol.h" -#import "Gender.h" - -#if __has_feature(objc_arc) - #define autorelease self -#endif - -int main(int argc, char *argv[]) { - @autoreleasepool { - - NSManagedObjectContext *moc; - {{ - NSURL *modelURL = [NSURL fileURLWithPath:@"test.mom"]; - assert(modelURL); - - NSManagedObjectModel *model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL] autorelease]; - assert(model); - - NSPersistentStoreCoordinator *persistentStoreCoordinator = [[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model] autorelease]; - assert(persistentStoreCoordinator); - - NSError *inMemoryStoreError = nil; - NSPersistentStore *persistentStore = [persistentStoreCoordinator addPersistentStoreWithType:NSInMemoryStoreType - configuration:nil - URL:nil - options:nil - error:&inMemoryStoreError]; - - assert(persistentStore); - assert(!inMemoryStoreError); - - moc = [[[NSManagedObjectContext alloc] init] autorelease]; - [moc setPersistentStoreCoordinator:persistentStoreCoordinator]; - assert(moc); - }} - - //-- - - ParentMO *homer = [ParentMO insertInManagedObjectContext:moc]; - homer.humanName = homer.parentName = @"homer"; - [homer setIvar:1.0]; - homer.genderValue = Gender_Male; - - ParentMO *marge = [ParentMO insertInManagedObjectContext:moc]; - marge.humanName = marge.parentName = @"marge"; - [marge setIvar:1.0]; - marge.genderValue = Gender_Female; - - assert([homer.children count] == 0); - assert([marge.children count] == 0); - - //-- - - ChildMO *bart = [ChildMO insertInManagedObjectContext:moc]; - bart.humanName = bart.childName = @"bart"; - [bart setIvar:1.0]; - bart.type = [NSNumber numberWithInt:64]; - bart.typeValue++; - - ChildMO *lisa = [ChildMO insertInManagedObjectContext:moc]; - lisa.humanName = lisa.childName = @"lisa"; - [lisa setIvar:1.0]; - - ParentMO *protocolMO = [ParentMO insertInManagedObjectContext:moc]; - protocolMO.myTransformableWithProtocol = [TestProtocol new]; - - //-- - - NSError *saveError = nil; - BOOL saveSuccess = [moc save:&saveError]; - assert(saveSuccess); - assert(!saveError); - - //-- - -#if 0 - /* Unforunately this section raises the following internal exception on 10.8.0/Xcode 4.5-DP4: - 2012-08-30 16:01:12.351 test[15090:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet' - *** First throw call stack: - ( - 0 CoreFoundation 0x00007fff8c9b1716 __exceptionPreprocess + 198 - 1 libobjc.A.dylib 0x00007fff94dee470 objc_exception_throw + 43 - 2 CoreFoundation 0x00007fff8ca4b21f -[NSSet intersectsSet:] + 927 - 3 Foundation 0x00007fff8e502085 NSKeyValueWillChangeBySetMutation + 359 - 4 Foundation 0x00007fff8e5549d0 NSKeyValueWillChange + 379 - 5 Foundation 0x00007fff8e501f0f -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:withSetMutation:usingObjects:] + 318 - 6 CoreData 0x00007fff95e697e5 _sharedIMPL_addObjectToSet_core + 165 - 7 test 0x000000010d44ee6e main + 2606 - 8 libdyld.dylib 0x00007fff977127e1 start + 0 - ) - libc++abi.dylib: terminate called throwing an exception - Abort trap: 6 - */ - [homer addChildrenObject:bart]; - [homer addChildrenObject:lisa]; - [marge addChildrenObject:bart]; - [marge addChildrenObject:lisa]; - - assert([homer.children count] == 2); - assert([marge.children count] == 2); -#endif - - //-- - - assert(homer.genderValue == Gender_Male); - assert(marge.genderValue == Gender_Female); - assert(bart.genderValue == Gender_Undefined); - assert([GenderToString(homer.genderValue) isEqualToString:@"Gender_Male"]); - } - puts("success"); - return 0; -} diff --git a/test/test.xcdatamodel/contents b/test/test.xcdatamodel/contents index a344a87f..54105d88 100644 --- a/test/test.xcdatamodel/contents +++ b/test/test.xcdatamodel/contents @@ -1,9 +1,9 @@ - + - + @@ -31,8 +31,6 @@ - - @@ -53,19 +51,9 @@ - - - - - - - - - - - - + + @@ -73,13 +61,13 @@ - + - - + + \ No newline at end of file