Skip to content

Commit

Permalink
issue rentzsch#83: Added option to make Mike Ash-style classes optional
Browse files Browse the repository at this point in the history
No change in behaviour by default.

But now if the command line includes `--template-var include-ash-classes=false` then these classes will not be created.

If you don't use them, this reduces code size a bit (200 KB / 0.12 % in my case) and removes things from Xcode's autocomplete that are just clutter.
  • Loading branch information
seanm committed Oct 18, 2024
1 parent 2d7f9b4 commit b89f8cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,11 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments {
return EXIT_SUCCESS;
}

// Default to generating Mike Ash-style classes if nothing specific was specified in the command arguments
NSNumber * useAshClassesObj = [templateVar objectForKey:@"include-ash-classes"];
BOOL useAshClasses = !useAshClassesObj || [useAshClassesObj boolValue];
[templateVar setObject:[NSNumber numberWithBool:useAshClasses] forKey:@"include-ash-classes"];

gSwift = _swift;

if (baseClassForce) {
Expand Down
3 changes: 3 additions & 0 deletions templates/machine.h.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
<$endforeach do$>
@end

<$if TemplateVar.include-ash-classes$>

<$if noninheritedAttributes.@count > 0$>
@interface <$managedObjectClassName$>Attributes: NSObject <$foreach Attribute noninheritedAttributes do$>
Expand All @@ -196,4 +197,6 @@ NS_ASSUME_NONNULL_BEGIN
@end
<$endif$>

<$endif$>

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions templates/machine.m.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@
@end
<$endif$><$endif$><$endforeach do$>

<$if TemplateVar.include-ash-classes$>

<$if noninheritedAttributes.@count > 0$>
@implementation <$managedObjectClassName$>Attributes <$foreach Attribute noninheritedAttributes do$>
+ (NSString *)<$Attribute.name$> {
Expand Down Expand Up @@ -308,3 +310,5 @@
}<$endforeach do$>
@end
<$endif$>

<$endif$>

0 comments on commit b89f8cd

Please sign in to comment.