ARC uses different @property qualifiers than non-ARC code. Of specific note to mogenerator is the use of strong instead of retain. For projects using ARC it would be nice to have the generated header files use the new qualifiers.
To that end, I though of a couple of possibilities and put them together.
With a new custom template
With an --arc argument
I prefer the utility of the --arc argument, but the implementation feels a little hacky. From what I could see, the only way to actually pass things through to the template level was to add methods on the entity/relationship categories, requiring me to also add a global (as with the custom base class option). Perhaps there is something I am missing.
If you're happy with one or the other solutions then let me know and I'll set up an appropriate Pull Request. Alternatively, let me know if you know of some better solution that I could implement instead.
Thanks for the forks! Awesome.
The ideal would be able to pass arbitrary command-line options through to the template itself. I'm thinking something like mogenerator --template-var foo=bar. mogenerator would pick up all the --template-var options, break down their key=value payload and call -[MiscMergeEngine setEngineValue:forKey:] for each engine instance (four in total, machineH, machineM, humanH and humanM).
mogenerator --template-var foo=bar
The main set of templates would be enhanced to look for an arc template var and generate different code for it (but should generate code that's semantically identical (whitespace changes don't matter) to today's code by default).
I've never used MiscMerge's engine contexts yet, so there may be dragons there. But it seems like just what we need for this feature.
I agree, that sounds like a far better solution, especially in the long term.
I'll take a look and see what I can do!
And it looks like we have a potential solution.
[https://github.com/extremeboredom/mogenerator/tree/template_arguments](Template Arguments Branch)
The command line parser can now optionally pick up key=value type arguments. It sets them as a key path on the target, so --template-var arc=true sets the value of true at templateVar.arc. Additionally it will parse out NSNumbers for numbers or booleans as it sets the value.
So the template vars get set into an NSMutableDictionary, templateVar on the application delegate. When the merge engines are set up, that dictionary is set as TemplateVar, making arguments available inside the template using TemplateVar.<name>. Since it's set in a dictionary, the return value for any key that can't be found is nil so <$if TemplateVar.arc$> checks in the template automatically evaluate false.
I think that pretty much covers it, shall I set up a Pull Request?
Awesome, that's exactly what I wanted! :-) Go ahead and toss me a pull request