Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Swift42 branch changes #385

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
65b9ea9
Merge remote-tracking branch 'upstream/master'
radianttap Nov 12, 2016
a8e4e0a
Merge branch 'master' of github.com:rentzsch/mogenerator
radianttap Jun 18, 2017
41aeab4
Swiftified both templates
radianttap Jun 18, 2017
93b4d7c
Merge branch 'swift-templates' of git://github.com/radianttap/mogener…
atomicbird Jul 29, 2018
04e8a21
Fix codegen errors from merge
atomicbird Jul 29, 2018
3b24550
Keep generated code in the “machine” file.
atomicbird Aug 4, 2018
bd5fe02
Remove convenience init, unnecessary since iOS 10.
atomicbird Aug 4, 2018
c428928
Don’t try to make a struct inherit from String.
atomicbird Aug 4, 2018
92d46f9
Fix “overriding non-@objc declarations from extensions is not support…
atomicbird Aug 4, 2018
d19acbb
Update Swift test code for new templates
atomicbird Aug 4, 2018
3900410
Merge branch 'radianttap-swift-templates' into swift42
atomicbird Aug 4, 2018
39a6634
Update OSX_SDK to target Xcode 10 beta
atomicbird Aug 4, 2018
85d4f1b
Change version to 1.32 “beta”
atomicbird Aug 5, 2018
c27a020
Add README credits for upcoming release.
atomicbird Aug 5, 2018
4f4bd33
Merge branch 'master' into swift42
atomicbird Aug 5, 2018
0123229
Merge branch 'master' into swift42
atomicbird Aug 11, 2018
3f3eb0f
Add `attributeRawValueEnumType` to handle Swift enums with numeric ra…
atomicbird Aug 18, 2018
d4927d1
Fix typos
atomicbird Sep 1, 2018
28c0a72
Add Codable property support via a new attributeCodableTypeName user …
atomicbird Sep 1, 2018
6d5927e
Update tests to use/require Xcode 10.
atomicbird Sep 8, 2018
47e39c1
Add explanatory comments in generated code
atomicbird Sep 8, 2018
670af2c
Merge branch 'master' into swift42
atomicbird Oct 3, 2018
4ce7534
Fix attributeRawValueEnumType for non-optionals.
atomicbird Jan 1, 2019
a6682db
Merge branch 'master' into swift42
atomicbird Feb 6, 2019
bbb2357
Re-add new README description for this branch and update version.
atomicbird Apr 20, 2019
9f8504c
One more README bullet
atomicbird Apr 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ Senseful wrote up a [nice summary of mogenerator's command-line options](http://

## Version History

### v1.33: Date TBD

* [NEW] Update Swift templates for better Swift style ([Aleksandar Vacić](https://github.com/rentzsch/mogenerator/pull/368))

* [FIX] Fixed invalid call of `NSManagedObject.fetchRequest()` ([Vincent Esche](https://github.com/rentzsch/mogenerator/pull/372))

* [NEW] Add support for URI and UUID attribute types ([Trevor Squires](https://github.com/rentzsch/mogenerator/pull/370))

* [NEW] Expose information when custom type is set through userInfo ([Aleksandar Vacić](https://github.com/rentzsch/mogenerator/pull/369))

* [NEW] Add Codable property support via a new attributeCodableTypeName user info key ([Tom Harrington](https://github.com/rentzsch/mogenerator/issues/375))

* [CHANGE] Nullability annotations for generated primitive accessors ([Michael Babin](https://github.com/rentzsch/mogenerator/pull/363))

* [FIX] Support for “Uses Scalar Type” ([Rok Gregorič](https://github.com/rentzsch/mogenerator/pull/352))

* [FIX] Swift 3 `NSData` to `Data` ([Christopher Rogers](https://github.com/rentzsch/mogenerator/pull/350))

* [FIX] Add specialized `fetchRequest()` func to Swift's machine generated files ([0xpablo](https://github.com/rentzsch/mogenerator/pull/358))

* [FIX] Correct Swift machine template for singleton (fetchOne…) fetch request results ([Warren Burton](https://github.com/rentzsch/mogenerator/pull/359))

* [FIX] Expose allAttributes and allRelationships ([Trevor Squires](https://github.com/rentzsch/mogenerator/pull/360))

### v1.32: Wed Jan 30 2019 [download](https://github.com/rentzsch/mogenerator/releases/tag/1.32)

* [NEW] Support for URL and UUID property types ([Trevor Squires](https://github.com/tomekc/mogenerator/pull/1), [original PR](https://github.com/rentzsch/mogenerator/pull/370))
Expand Down
23 changes: 22 additions & 1 deletion mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

static const NSString *const kAttributeValueScalarTypeKey = @"attributeValueScalarType";
static const NSString *const kAdditionalHeaderFileNameKey = @"additionalHeaderFileName";
static const NSString *const kUsesRawValueEnumType = @"attributeRawValueEnumType";
static const NSString *const kAdditionalImportsKey = @"additionalImports";
static const NSString *const kCustomBaseClass = @"mogenerator.customBaseClass";
static const NSString *const kReadOnly = @"mogenerator.readonly";
Expand Down Expand Up @@ -457,6 +458,15 @@ - (BOOL)hasScalarAttributeType {
}
}

- (BOOL)usesRawValueEnumType {
NSNumber *usesRawValueEnumType = [[self userInfo] objectForKey:kUsesRawValueEnumType];
return (usesRawValueEnumType != NULL);
}

- (NSString *)attributeRawValueEnumType {
return [[self userInfo] objectForKey:kUsesRawValueEnumType];
}

- (BOOL)usesScalarAttributeType {
NSNumber *usesScalarAttributeType = [[self userInfo] objectForKey:kUsesScalarAttributeType];

Expand Down Expand Up @@ -586,6 +596,13 @@ - (NSString*)objectAttributeClassName {
if (!result) {
result = gSwift ? @"AnyObject" : @"NSObject";
}
} else if (gSwift && [self attributeType] == NSBinaryDataAttributeType) {
NSString *codableName = [self userInfo][@"attributeCodableTypeName"];
if (!codableName) {
result = @"Data";
} else {
result = codableName;
}
} else {
// Forcibly generate the correct class name in case we are
// running on macOS < 10.13
Expand Down Expand Up @@ -638,6 +655,10 @@ - (BOOL)usesCustomObjectAttributeType {
return (attributeValueClassName != nil);
}

- (BOOL)usesCustomCodableAttributeType {
return [self userInfo][@"attributeCodableTypeName"] != NULL;
}

- (NSString*)objectAttributeType {
NSString *result = [self objectAttributeClassName];
if ([result isEqualToString:@"Class"]) {
Expand Down Expand Up @@ -1063,7 +1084,7 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
}

if (_version) {
printf("mogenerator 1.32. By Jonathan 'Wolf' Rentzsch + friends.\n");
printf("mogenerator 1.33. By Jonathan 'Wolf' Rentzsch + friends.\n");
return EXIT_SUCCESS;
}

Expand Down
10 changes: 7 additions & 3 deletions templates/human.swift.motemplate
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Foundation
import CoreData

@objc(<$sanitizedManagedObjectClassName$>)
open class <$sanitizedManagedObjectClassName$>: <$customSuperentity$> {

// Put custom code for <$sanitizedManagedObjectClassName$> here.
// This file will be created if it doesn't exist, but mogenerator will not replace an existing copy.

@objc(<$managedObjectClassName$>)
open class <$managedObjectClassName$>: _<$managedObjectClassName$> {
// Custom logic goes here.
}
Loading