Skip to content

Commit

Permalink
issue rentzsch#83: add template var to make Mike Ash-style structs op…
Browse files Browse the repository at this point in the history
…tional
  • Loading branch information
seanm committed Jul 22, 2015
1 parent f95d84b commit 6e99d9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,12 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
[templateVar setObject:@YES forKey:@"modules"];
}

// Default to generating Mike Ash-style structures if nothing specific was specified in the command arguments
if ([templateVar objectForKey:@"ash-structures"] == nil)
{
[templateVar setObject:@YES forKey:@"ash-structures"];
}

gSwift = _swift;

if (baseClassForce) {
Expand Down
4 changes: 4 additions & 0 deletions templates/machine.h.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "<$additionalHeaderFileName$>"
<$endif$>

<$if TemplateVar.ash-structures$>

<$if noninheritedAttributes.@count > 0$>
extern const struct <$managedObjectClassName$>Attributes {<$foreach Attribute noninheritedAttributes do$>
<$if TemplateVar.arc$>__unsafe_unretained<$endif$> NSString *<$Attribute.name$>;<$endforeach do$>
Expand All @@ -33,6 +35,8 @@ extern const struct <$managedObjectClassName$>UserInfo {<$foreach UserInfo userI
} <$managedObjectClassName$>UserInfo;
<$endif$>

<$endif$>

<$foreach Relationship noninheritedRelationships do$>@class <$Relationship.destinationEntity.managedObjectClassName$>;
<$endforeach do$>
<$foreach Attribute noninheritedAttributes do$>
Expand Down
4 changes: 4 additions & 0 deletions templates/machine.m.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#import "_<$managedObjectClassName$>.h"

<$if TemplateVar.ash-structures$>

<$if noninheritedAttributes.@count > 0$>
const struct <$managedObjectClassName$>Attributes <$managedObjectClassName$>Attributes = {<$foreach Attribute noninheritedAttributes do$>
.<$Attribute.name$> = @"<$Attribute.name$>",<$endforeach do$>
Expand All @@ -27,6 +29,8 @@ const struct <$managedObjectClassName$>UserInfo <$managedObjectClassName$>UserIn
};
<$endif$>

<$endif$>

@implementation <$managedObjectClassName$>ID
@end

Expand Down

0 comments on commit 6e99d9f

Please sign in to comment.