Skip to content

Commit

Permalink
Merge pull request #3 from bannzai/fix/access_control
Browse files Browse the repository at this point in the history
Fix/access control
  • Loading branch information
bannzai authored Nov 12, 2017
2 parents 3f6c53a + 1adc830 commit 2adec85
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 117 deletions.
176 changes: 88 additions & 88 deletions ResourceKitDemo/Resource.generated.swift

Large diffs are not rendered by default.

Binary file modified ResourceKitDemo/ResourceKit
Binary file not shown.
Binary file modified ResourceKitDemo/ResourceKitDemo/ResourceKit
Binary file not shown.
18 changes: 9 additions & 9 deletions Sources/ResourceKitCore/Extensions/ExtensionsOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,46 @@ import Foundation
public struct ExtensionsOutputImpl {
public init() { }
public let reusableProtocolContent: String = [
"protocol ReusableProtocol {",
"public protocol ReusableProtocol {",
" associatedtype View",
" static var name: String { get }",
"}",
].joined(separator: Const.newLine)

public let xibProtocolContent: String = [
"protocol XibProtocol: ReusableProtocol {",
"public protocol XibProtocol: ReusableProtocol {",
"\(Const.tab1)static func nib() -> UINib",
"\(Const.tab1)static func view() -> View",
"}",
].joined(separator: Const.newLine)

public let tableViewExtensionContent: String = [
"extension UITableView {",
"\(Const.tab1)func register<X: XibProtocol>(xib: X.Type) -> Void where X.View: UITableViewCell {",
"public extension UITableView {",
"\(Const.tab1)public func register<X: XibProtocol>(xib: X.Type) -> Void where X.View: UITableViewCell {",
"\(Const.tab2)register(xib.nib(), forCellReuseIdentifier: xib.name)",
"\(Const.tab1)}",
" ",
"\(Const.tab1)func register<X: XibProtocol>(xibs: [X.Type]) -> Void where X.View: UITableViewCell {",
"\(Const.tab1)public func register<X: XibProtocol>(xibs: [X.Type]) -> Void where X.View: UITableViewCell {",
"\(Const.tab2)xibs.forEach { register(xib: $0) }",
"\(Const.tab1)}",
" ",
"\(Const.tab1)func dequeueReusableCell<R: ReusableProtocol>(with reusable: R.Type, for indexPath: IndexPath) -> R.View where R.View: UITableViewCell {",
"\(Const.tab1)public func dequeueReusableCell<R: ReusableProtocol>(with reusable: R.Type, for indexPath: IndexPath) -> R.View where R.View: UITableViewCell {",
"\(Const.tab2)return dequeueReusableCell(withIdentifier: reusable.name, for: indexPath) as! R.View",
"\(Const.tab1)}",
"}",
].joined(separator: Const.newLine)

public let collectionViewExtensionContent = [
"extension UICollectionView {",
"\(Const.tab1)func register<X: XibProtocol>(xib: X.Type) -> Void where X.View: UICollectionViewCell {",
"\(Const.tab1)public func register<X: XibProtocol>(xib: X.Type) -> Void where X.View: UICollectionViewCell {",
"\(Const.tab2)register(xib.nib(), forCellWithReuseIdentifier: xib.name)",
"\(Const.tab1)}",
" ",
"\(Const.tab1)func register<X: XibProtocol>(xibs: [X.Type]) -> Void where X.View: UICollectionViewCell {",
"\(Const.tab1)public func register<X: XibProtocol>(xibs: [X.Type]) -> Void where X.View: UICollectionViewCell {",
"\(Const.tab2)xibs.forEach { register(xib: $0) }",
"\(Const.tab1)}",
" ",
"\(Const.tab1)func dequeueReusableCell<R: ReusableProtocol>(with reusable: R.Type, for indexPath: IndexPath) -> R.View where R.View: UICollectionViewCell {",
"\(Const.tab1)public func dequeueReusableCell<R: ReusableProtocol>(with reusable: R.Type, for indexPath: IndexPath) -> R.View where R.View: UICollectionViewCell {",
"\(Const.tab2)return dequeueReusableCell(withReuseIdentifier: reusable.name, for: indexPath) as! R.View",
"\(Const.tab1)}",
"}",
Expand Down
8 changes: 4 additions & 4 deletions Sources/ResourceKitCore/Image/ImageOutputer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ extension ImageOutputerImpl {
let imageNames: [String]

public var begin: String {
return "\(Const.tab1)struct Asset {"
return "\(Const.tab1)public struct Asset {"
}
public var body: String {
let body = imageNames
.flatMap { "\(Const.tab2)static let \($0): UIImage = \(ImageOutputerImpl.imageFunction($0))" }
.flatMap { "\(Const.tab2)public static let \($0): UIImage = \(ImageOutputerImpl.imageFunction($0))" }
.joined(separator: Const.newLine)
return body
}
Expand All @@ -81,11 +81,11 @@ extension ImageOutputerImpl {
let imageNames: [String]

public var begin: String {
return "\(Const.tab1)struct Resource {"
return "\(Const.tab1)public struct Resource {"
}
public var body: String {
let body = imageNames
.flatMap { "\(Const.tab2)static let \($0): UIImage = \(ImageOutputerImpl.imageFunction($0))" }
.flatMap { "\(Const.tab2)public static let \($0): UIImage = \(ImageOutputerImpl.imageFunction($0))" }
.joined(separator: Const.newLine)
return body
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public struct LocalizedStringOutputerImpl: LocalizedStringOutputer {
public var declaration: String {
return [
"extension String {",
"\(Const.tab1)struct Localized {",
"\(Const.tab1)public struct Localized {",
"\(generateLocalizableConstants().joined(separator: Const.newLine))",
"\(Const.tab1)}",
"}",
Expand All @@ -35,7 +35,7 @@ fileprivate extension LocalizedStringOutputerImpl {

}
return localizedStrings.keys.flatMap {
return "\(Const.tab2)static let \(toConstantName($0)) = NSLocalizedString(\"\($0)\", comment: \"\")"
return "\(Const.tab2)public static let \(toConstantName($0)) = NSLocalizedString(\"\($0)\", comment: \"\")"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public struct ReusableResourceOutputImpl: ReusableResourceOutput {
public var declaration: String {
let names = reusableIdentifers
.map {
return " static let name: String = \"\($0)\""
return " public static let name: String = \"\($0)\""
}
.joined(separator: Const.newLine)

return [
"extension \(className) {",
" struct Reusable: ReusableProtocol {",
" typealias View = \(className)",
" public struct Reusable: ReusableProtocol {",
" public typealias View = \(className)",
"\(names)",
" }",
"}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ fileprivate extension ViewControllerOutputImpl {
return ""
}

let begin = "\(Const.tab1)struct Segue {"
let begin = "\(Const.tab1)public struct Segue {"
let body: String = seguesForGenerateStruct
.flatMap {
"\(Const.tab2)static let \($0.lowerFirst): String = \"\($0)\""
"\(Const.tab2)public static let \($0.lowerFirst): String = \"\($0)\""
}
.joined()
let end = "\(Const.tab1)}"
Expand Down Expand Up @@ -137,14 +137,14 @@ fileprivate extension ViewControllerOutputImpl {
let head = "\(Const.tab1)\(overrideOrObjC)"
if config.segue.addition {
return [
"\(head)func performSegue\(segueIdentifier)(closure: ((UIStoryboardSegue) -> Void)? = nil) {",
"\(head)open func performSegue\(segueIdentifier)(closure: ((UIStoryboardSegue) -> Void)? = nil) {",
"\(Const.tab2)performSegue(\"\(segueIdentifier)\", closure: closure)",
"\(Const.tab1)}",
]
.joined(separator: Const.newLine)
}
return [
"\(head)func performSegue\(segueIdentifier)(sender: AnyObject? = nil) {",
"\(head)open func performSegue\(segueIdentifier)(sender: AnyObject? = nil) {",
"\(Const.tab2)performSegue(withIdentifier: \"\(segueIdentifier)\", sender: sender)",
"\(Const.tab1)}",
]
Expand All @@ -158,7 +158,7 @@ fileprivate extension ViewControllerOutputImpl {

let overrideOrNil = makeOverrideIfNeededForFromStoryboardFunction(from: storyboard)
let overrideOrObjC = overrideOrNil == nil ? "@objc " : overrideOrNil! + " "
let head = "\(Const.tab1)\(overrideOrObjC)class func "
let head = "\(Const.tab1)\(overrideOrObjC)open class func "
if storyboardInfos.filter({ $0.storyboardName == storyboard.storyboardName }).count > 1 {
return [
head + "instanceFrom\(storyboard.storyboardName + storyboard.storyboardIdentifier)() -> \(name) {",
Expand All @@ -183,7 +183,7 @@ fileprivate extension ViewControllerOutputImpl {
func fromStoryboardForInitial(from storyboard: ViewControllerInfoOfStoryboard) -> String {
let overrideOrNil = makeOverrideIfNeededForFromStoryboardFunction(from: storyboard)
let overrideOrObjC = overrideOrNil == nil ? "@objc " : overrideOrNil! + " "
let head = "\(Const.tab1)\(overrideOrObjC)class func "
let head = "\(Const.tab1)\(overrideOrObjC)open class func "

if storyboardInfos.filter ({ $0.isInitial }).count > 1 {
return [
Expand Down
10 changes: 5 additions & 5 deletions Sources/ResourceKitCore/Xib/XibOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ public struct XibOutputImpl: XibOutput {
public var declaration: String {
return [
"extension \(className) {",
"\(Const.tab1)struct Xib: XibProtocol {",
"\(Const.tab2)typealias View = \(className)",
"\(Const.tab2)static let name: String = \"\(className)\"",
"\(Const.tab1)public struct Xib: XibProtocol {",
"\(Const.tab2)public typealias View = \(className)",
"\(Const.tab2)public static let name: String = \"\(className)\"",
" ",
"\(Const.tab2)static func nib() -> UINib {",
"\(Const.tab2)public static func nib() -> UINib {",
"\(Const.tab3)return UINib(nibName: \"\(nibName)\", bundle: Bundle(for: \(className).classForCoder()))",
"\(Const.tab2)}",
"",
"\(Const.tab2)static func view() -> \(className) {",
"\(Const.tab2)public static func view() -> \(className) {",
"\(Const.tab3)return nib().instantiate(withOwner: nil, options: nil)[0] as! \(className)",
"\(Const.tab2)}",
"",
Expand Down

0 comments on commit 2adec85

Please sign in to comment.