Skip to content

Commit

Permalink
Merge branch '19-linker'
Browse files Browse the repository at this point in the history
  • Loading branch information
trupin committed Jul 24, 2018
2 parents d4f0d85 + 6ed4abf commit 7712ca6
Show file tree
Hide file tree
Showing 23 changed files with 990 additions and 873 deletions.
20 changes: 10 additions & 10 deletions Resources/dependency_resolver.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ final class {{resolver.targetType.name}}DependencyContainer{{resolver.targetType
{% for reference in resolver.references %}

{% if reference.parameters %}
func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.resolvedType}}
func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.abstractType}}
{% else %}{# reference.parameters #}
var {{reference.name}}: {{reference.resolvedType}} { get }
var {{reference.name}}: {{reference.abstractType}} { get }
{% endif %}{# reference.parameters #}

{% endfor %}{# resolver.references #}
Expand All @@ -86,14 +86,14 @@ extension {{resolver.targetType.name}}DependencyContainer: {{resolver.targetType

{% if reference.parameters %}

func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.resolvedType}} {
return resolve({{reference.resolvedType}}.self, name: "{{reference.name}}", parameter{% if reference.parameters.count > 1 %}s{% endif %}: {% for parameter in reference.parameters %}{{parameter.name}}{% if not forloop.last %}, {% endif %}{% endfor %})
func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.abstractType}} {
return resolve({{reference.abstractType}}.self, name: "{{reference.name}}", parameter{% if reference.parameters.count > 1 %}s{% endif %}: {% for parameter in reference.parameters %}{{parameter.name}}{% if not forloop.last %}, {% endif %}{% endfor %})
}

{% else %}{# reference.paramters #}

var {{reference.name}}: {{reference.resolvedType}} {
return resolve({{reference.resolvedType}}.self, name: "{{reference.name}}")
var {{reference.name}}: {{reference.abstractType}} {
return resolve({{reference.abstractType}}.self, name: "{{reference.name}}")
}

{% endif %}{# reference.parameters #}
Expand Down Expand Up @@ -190,14 +190,14 @@ extension {{resolver.targetType.name}}ShimDependencyContainer: {{resolver.target

{% if reference.parameters %}

func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.resolvedType}} {
return internalDependencies.resolve({{reference.resolvedType.name}}.self, name: "{{reference.name}}", parameter{% if reference.parameters.count > 1 %}s{% endif %}: {% for parameter in reference.parameters %}{{parameter.name}}{% if not forloop.last %}, {% endif %}{% endfor %})
func {{reference.name}}({% for parameter in reference.parameters %}{{parameter.name}}: {{parameter.type}}{% if not forloop.last %}, {% endif %}{% endfor %}) -> {{reference.abstractType}} {
return internalDependencies.resolve({{reference.abstractType.name}}.self, name: "{{reference.name}}", parameter{% if reference.parameters.count > 1 %}s{% endif %}: {% for parameter in reference.parameters %}{{parameter.name}}{% if not forloop.last %}, {% endif %}{% endfor %})
}

{% else %}{# reference.parameters #}

var {{reference.name}}: {{reference.resolvedType}} {
return internalDependencies.resolve({{reference.resolvedType}}.self, name: "{{reference.name}}")
var {{reference.name}}: {{reference.abstractType}} {
return internalDependencies.resolve({{reference.abstractType}}.self, name: "{{reference.name}}")
}

{% endif %}{# reference.parameters #}
Expand Down
2 changes: 1 addition & 1 deletion Sample/API/Generated/Weaver.API.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import Foundation
import WeaverDI
Expand Down
22 changes: 11 additions & 11 deletions Sample/API/Generated/Weaver.ImageManager.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import Foundation
import UIKit
Expand All @@ -9,33 +9,33 @@ final class ImageManagerDependencyContainer: DependencyContainer {
super.init()
}
override func registerDependencies(in store: DependencyStore) {
store.register(APIProtocol.self, scope: .graph, name: "movieAPI", builder: { (dependencies) in
return MovieAPI.makeMovieAPI(injecting: dependencies)
})
store.register(Logger.self, scope: .graph, name: "logger", builder: { (dependencies) in
return Logger()
})
store.register(URLSession.self, scope: .container, name: "urlSession", builder: { (dependencies) in
return self.urlSessionCustomRef()
})
store.register(APIProtocol.self, scope: .graph, name: "movieAPI", builder: { (dependencies) in
return MovieAPI.makeMovieAPI(injecting: dependencies)
})
}
}
protocol ImageManagerDependencyResolver {
var movieAPI: APIProtocol { get }
var logger: Logger { get }
var urlSession: URLSession { get }
var movieAPI: APIProtocol { get }
func urlSessionCustomRef() -> URLSession
}
extension ImageManagerDependencyContainer: ImageManagerDependencyResolver {
var movieAPI: APIProtocol {
return resolve(APIProtocol.self, name: "movieAPI")
}
var logger: Logger {
return resolve(Logger.self, name: "logger")
}
var urlSession: URLSession {
return resolve(URLSession.self, name: "urlSession")
}
var movieAPI: APIProtocol {
return resolve(APIProtocol.self, name: "movieAPI")
}
}
// MARK: - ImageManagerShim
final class ImageManagerShimDependencyContainer: DependencyContainer {
Expand All @@ -49,15 +49,15 @@ final class ImageManagerShimDependencyContainer: DependencyContainer {
}
}
extension ImageManagerShimDependencyContainer: ImageManagerDependencyResolver {
var movieAPI: APIProtocol {
return internalDependencies.resolve(APIProtocol.self, name: "movieAPI")
}
var logger: Logger {
return internalDependencies.resolve(Logger.self, name: "logger")
}
var urlSession: URLSession {
return internalDependencies.resolve(URLSession.self, name: "urlSession")
}
var movieAPI: APIProtocol {
return internalDependencies.resolve(APIProtocol.self, name: "movieAPI")
}
}
extension ImageManager {
public convenience init() {
Expand Down
22 changes: 11 additions & 11 deletions Sample/API/Generated/Weaver.MovieManager.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import Foundation
import WeaverDI
Expand All @@ -10,28 +10,28 @@ final class MovieManagerDependencyContainer: DependencyContainer {
super.init(parent)
}
override func registerDependencies(in store: DependencyStore) {
store.register(APIProtocol.self, scope: .graph, name: "movieAPI", builder: { (dependencies) in
return MovieAPI.makeMovieAPI(injecting: dependencies)
})
store.register(URLSession.self, scope: .container, name: "urlSession", builder: { (dependencies) in
return self.urlSessionCustomRef()
})
store.register(APIProtocol.self, scope: .graph, name: "movieAPI", builder: { (dependencies) in
return MovieAPI.makeMovieAPI(injecting: dependencies)
})
}
}
protocol MovieManagerDependencyResolver {
var host: String? { get }
var movieAPI: APIProtocol { get }
var urlSession: URLSession { get }
var movieAPI: APIProtocol { get }
var logger: Logger { get }
func urlSessionCustomRef() -> URLSession
}
extension MovieManagerDependencyContainer: MovieManagerDependencyResolver {
var movieAPI: APIProtocol {
return resolve(APIProtocol.self, name: "movieAPI")
}
var urlSession: URLSession {
return resolve(URLSession.self, name: "urlSession")
}
var movieAPI: APIProtocol {
return resolve(APIProtocol.self, name: "movieAPI")
}
var logger: Logger {
return resolve(Logger.self, name: "logger")
}
Expand Down Expand Up @@ -68,12 +68,12 @@ final class MovieManagerShimDependencyContainer: DependencyContainer {
}
}
extension MovieManagerShimDependencyContainer: MovieManagerDependencyResolver {
var movieAPI: APIProtocol {
return internalDependencies.resolve(APIProtocol.self, name: "movieAPI")
}
var urlSession: URLSession {
return internalDependencies.resolve(URLSession.self, name: "urlSession")
}
var movieAPI: APIProtocol {
return internalDependencies.resolve(APIProtocol.self, name: "movieAPI")
}
}
extension MovieManager {
public convenience init(logger: Logger, host: String?) {
Expand Down
54 changes: 27 additions & 27 deletions Sample/Sample/Generated/Weaver.AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import API
import UIKit
Expand All @@ -9,62 +9,62 @@ final class AppDelegateDependencyContainer: DependencyContainer {
super.init()
}
override func registerDependencies(in store: DependencyStore) {
store.register(Logger.self, scope: .container, name: "logger", builder: { (dependencies) in
return Logger()
})
store.register(URLSession.self, scope: .container, name: "urlSession", builder: { (dependencies) in
return self.urlSessionCustomRef()
})
store.register(APIProtocol.self, scope: .container, name: "movieAPI", builder: { (dependencies) in
return self.movieAPICustomRef()
})
store.register(UIViewController.self, scope: .container, name: "homeViewController", builder: { (dependencies) in
return HomeViewController.makeHomeViewController(injecting: dependencies)
store.register(ImageManaging.self, scope: .container, name: "imageManager", builder: { (dependencies) in
return self.imageManagerCustomRef()
})
store.register(MovieManaging.self, scope: .container, name: "movieManager", builder: { (dependencies) in
return self.movieManagerCustomRef()
})
store.register(Logger.self, scope: .container, name: "logger", builder: { (dependencies) in
return Logger()
})
store.register(URLSession.self, scope: .container, name: "urlSession", builder: { (dependencies) in
return self.urlSessionCustomRef()
store.register(UIViewController.self, scope: .container, name: "homeViewController", builder: { (dependencies) in
return HomeViewController.makeHomeViewController(injecting: dependencies)
})
store.register(ReviewManaging.self, scope: .container, name: "reviewManager", builder: { (dependencies) in
return ReviewManager.makeReviewManager(injecting: dependencies)
})
store.register(ImageManaging.self, scope: .container, name: "imageManager", builder: { (dependencies) in
return self.imageManagerCustomRef()
})
}
}
protocol AppDelegateDependencyResolver {
var movieAPI: APIProtocol { get }
var homeViewController: UIViewController { get }
var movieManager: MovieManaging { get }
var logger: Logger { get }
var urlSession: URLSession { get }
var reviewManager: ReviewManaging { get }
var movieAPI: APIProtocol { get }
var imageManager: ImageManaging { get }
func movieAPICustomRef() -> APIProtocol
func movieManagerCustomRef() -> MovieManaging
var movieManager: MovieManaging { get }
var homeViewController: UIViewController { get }
var reviewManager: ReviewManaging { get }
func urlSessionCustomRef() -> URLSession
func movieAPICustomRef() -> APIProtocol
func imageManagerCustomRef() -> ImageManaging
func movieManagerCustomRef() -> MovieManaging
}
extension AppDelegateDependencyContainer: AppDelegateDependencyResolver {
var logger: Logger {
return resolve(Logger.self, name: "logger")
}
var urlSession: URLSession {
return resolve(URLSession.self, name: "urlSession")
}
var movieAPI: APIProtocol {
return resolve(APIProtocol.self, name: "movieAPI")
}
var homeViewController: UIViewController {
return resolve(UIViewController.self, name: "homeViewController")
var imageManager: ImageManaging {
return resolve(ImageManaging.self, name: "imageManager")
}
var movieManager: MovieManaging {
return resolve(MovieManaging.self, name: "movieManager")
}
var logger: Logger {
return resolve(Logger.self, name: "logger")
}
var urlSession: URLSession {
return resolve(URLSession.self, name: "urlSession")
var homeViewController: UIViewController {
return resolve(UIViewController.self, name: "homeViewController")
}
var reviewManager: ReviewManaging {
return resolve(ReviewManaging.self, name: "reviewManager")
}
var imageManager: ImageManaging {
return resolve(ImageManaging.self, name: "imageManager")
}
}
16 changes: 8 additions & 8 deletions Sample/Sample/Generated/Weaver.HomeViewController.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import API
import Foundation
Expand All @@ -10,26 +10,26 @@ final class HomeViewControllerDependencyContainer: DependencyContainer {
super.init(parent)
}
override func registerDependencies(in store: DependencyStore) {
store.register(UIViewController.self, scope: .transient, name: "movieController", builder: { (dependencies, movieID: UInt, title: String) in
return MovieViewController.makeMovieViewController(injecting: dependencies, movieID: movieID, title: title)
})
store.register(Logger.self, scope: .graph, name: "logger", builder: { (dependencies) in
return Logger()
})
store.register(UIViewController.self, scope: .transient, name: "movieController", builder: { (dependencies, movieID: UInt, title: String) in
return MovieViewController.makeMovieViewController(injecting: dependencies, movieID: movieID, title: title)
})
}
}
protocol HomeViewControllerDependencyResolver {
func movieController(movieID: UInt, title: String) -> UIViewController
var logger: Logger { get }
func movieController(movieID: UInt, title: String) -> UIViewController
var movieManager: MovieManaging { get }
}
extension HomeViewControllerDependencyContainer: HomeViewControllerDependencyResolver {
func movieController(movieID: UInt, title: String) -> UIViewController {
return resolve(UIViewController.self, name: "movieController", parameters: movieID, title)
}
var logger: Logger {
return resolve(Logger.self, name: "logger")
}
func movieController(movieID: UInt, title: String) -> UIViewController {
return resolve(UIViewController.self, name: "movieController", parameters: movieID, title)
}
var movieManager: MovieManaging {
return resolve(MovieManaging.self, name: "movieManager")
}
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample/Generated/Weaver.MovieViewController.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import API
import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample/Generated/Weaver.PersonManager.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import API
import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sample/Sample/Generated/Weaver.ReviewManager.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import API
import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// This file is generated by Weaver 0.9.12
/// This file is generated by Weaver 0.9.13
/// DO NOT EDIT!
import Foundation
import WeaverDI
Expand Down
13 changes: 13 additions & 0 deletions Sources/WeaverCodeGen/AutoEquatable.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public func == (lhs: ConfigurationAnnotation, rhs: ConfigurationAnnotation) -> B
guard lhs.target == rhs.target else { return false }
return true
}
// MARK: - DependencyIndex AutoEquatable
extension DependencyIndex: Equatable {}
internal func == (lhs: DependencyIndex, rhs: DependencyIndex) -> Bool {
guard lhs.name == rhs.name else { return false }
guard compareOptionals(lhs: lhs.type, rhs: rhs.type, compare: ==) else { return false }
return true
}
// MARK: - EndOfAnyDeclaration AutoEquatable
extension EndOfAnyDeclaration: Equatable {}
public func == (lhs: EndOfAnyDeclaration, rhs: EndOfAnyDeclaration) -> Bool {
Expand Down Expand Up @@ -123,6 +130,12 @@ public func == (lhs: Type, rhs: Type) -> Bool {
guard lhs.generics == rhs.generics else { return false }
return true
}
// MARK: - TypeIndex AutoEquatable
extension TypeIndex: Equatable {}
internal func == (lhs: TypeIndex, rhs: TypeIndex) -> Bool {
guard lhs.value == rhs.value else { return false }
return true
}

// MARK: - AutoEquatable for Enums
// MARK: - ConfigurationAttribute AutoEquatable
Expand Down
Loading

0 comments on commit 7712ca6

Please sign in to comment.