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

Improve Eqaulity.stencil.swift #9

Merged
merged 1 commit into from
Dec 12, 2016
Merged

Improve Eqaulity.stencil.swift #9

merged 1 commit into from
Dec 12, 2016

Conversation

ilyapuchka
Copy link
Collaborator

@ilyapuchka ilyapuchka commented Dec 12, 2016

For now I just fixed some typos in current version of template to make it work on Insanity own model types.

But I'd like to improve that template to make it more generic:

  1. We may add if lhs === rhs { return true } in the second line of the isEqual for classes.
  2. For structs instead of generating isEqual template should generate Equitable conformance.
  3. For enums with associated values we may generate Equatable conformance based on switch like the following.
swift (lhs, rhs):
case let (.{{ case }}(lhsValue), .{{ case}}.(rhsValue)): return lhsValue == rhsValue

But that will probably require some additional checks (like in #6 for instance) and maybe a separate issue/pr will be better.

@ilyapuchka
Copy link
Collaborator Author

ilyapuchka commented Dec 12, 2016

Aslo having stencilproject/Stencil#32 would be cool. But in meantime maybe we should patch Stencil the same way as @AliSoftware patched it in SwiftGen?

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Dec 12, 2016

This template is for Insanity itself, We can add a generic one but might be worth doing that in top root folder under ExampleTemplates ?

In this pr you just tweaked spaces right? I used this template to code generate the boilerplate code for the tool so it worked, I think the spaces were inserted either by Xcode or I've to correct Swiftlint ignore entry.

I spoke with @AliSoftware and we discussed splitting GenumKit into 2 frameworks, one that does Stencil extensions, we could use that in Insanity and SwiftGen then.

@ilyapuchka
Copy link
Collaborator Author

Yes, there were few problems with spaces and new lines. With that I was able to generate the same code as what is currently checked in.

Regarding where to create a more generic template I was going to create a separate issue asking about your plans on how to distribute custom templates. This one used internally by the tool can be different and "private", but I guess there will be more useful templates coming and they will drive new features in generator. Let's discuss that there =)

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

Successfully merging this pull request may close these issues.

2 participants