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

Add implements and inherits properties to type #42

Closed
ilyapuchka opened this issue Dec 17, 2016 · 6 comments
Closed

Add implements and inherits properties to type #42

ilyapuchka opened this issue Dec 17, 2016 · 6 comments
Assignees

Comments

@ilyapuchka
Copy link
Collaborator

As now we have a separation between implementing and inheriting types collections in generator we may as well add corresponding properties to Type model.
Then inheritedTypes (should be renamed to based probably?) becomes analogous to types.based, implements to types.implementing and inherits to types.inheriting.

With that instead of variable.type.inheritedTypes.MyProtocol it will be possible to do variable.type.implements.MyProtocol which just reads better. Also it will be more consistent with mentioned separation of inheriting and implementing types in generator.

@krzysztofzablocki
Copy link
Owner

I'll add it 👍

@krzysztofzablocki
Copy link
Owner

This will be needed for the following to work properly:

protocol AutoEquatable {}

struct AStruct: Equatable {
  public static func == (l: AStruct, r: AStruct) -> Bool {
    return true
  }
}

struct Book: AutoEquatable {
  let aStruct: AStruct
}

Given template like

{% for type in types.implementing.AutoEquatable %}
  {% for variable in type.storedVariables %}
    {% if variable.type.inheritedTypes.AutoEquatable %}
      {{ variable.type }}
    {% endif %}
  {% endfor %}
{% endfor %}

It should not generate code

@ilyapuchka
Copy link
Collaborator Author

Ah, so if inheritedTypes is just an array of strings we can not use it in if type.inheritedTypes.SomeType? Then looks like those collections should be "dummy" dictionaries like ["TypeName": "TypeName"]?

@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Dec 17, 2016

well right now we don't store real types in inheritedTypes, and I think we want to because with flattening types it will be much more reliable right?

@ilyapuchka
Copy link
Collaborator Author

We may store them like [TypeName: Type], but I'm not sure we will get something from storing actual type references, because what we need is just to check if the type name is inside the implementing types collection and not to access the metadata of those types. At least I don't see it useful right now.

@krzysztofzablocki
Copy link
Owner

Implemneted in 0.4.1

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

No branches or pull requests

2 participants