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

No support for ARC-style @property qualifiers #63

Closed
extremeboredom opened this issue Jun 21, 2011 · 4 comments
Closed

No support for ARC-style @property qualifiers #63

extremeboredom opened this issue Jun 21, 2011 · 4 comments

Comments

@extremeboredom
Copy link
Contributor

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.

Cheers,
Adam.

@rentzsch
Copy link
Owner

Hey Adam,

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).

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.

@extremeboredom
Copy link
Contributor Author

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!

@extremeboredom
Copy link
Contributor Author

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?

@rentzsch
Copy link
Owner

Awesome, that's exactly what I wanted! :-) Go ahead and toss me a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants