Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-cain13 committed Aug 1, 2015
2 parents c228d3e + 7459922 commit 01fcd6b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
13 changes: 8 additions & 5 deletions R.swift/func.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,20 @@ func storyboardStructForStoryboard(storyboard: Storyboard) -> Struct {
// Nib

func nibStructFromNibs(nibs: [Nib]) -> Struct {
return Struct(type: Type(name: "nib"), lets: [], vars: nibs.map(nibVarForNib), functions: [], structs: nibs.map(nibStructForNib))
return Struct(type: Type(name: "nib"), lets: [], vars: nibs.map(nibVarForNib), functions: [], structs: [])
}

func internalNibStructFromNibs(nibs: [Nib]) -> Struct {
return Struct(type: Type(name: "nib"), lets: [], vars: [], functions: [], structs: nibs.map(nibStructForNib))
}

func nibVarForNib(nib: Nib) -> Var {
let structType = Type(name: nib.name)
let structType = Type(name: "_R.nib._\(nib.name)")
return Var(isStatic: true, name: nib.name, type: structType, getter: "return \(structType)()")
}

func nibStructForNib(nib: Nib) -> Struct {



let instantiateParameters = [
Function.Parameter(name: "ownerOrNil", type: Type._AnyObject.asOptional()),
Function.Parameter(name: "options", localName: "optionsOrNil", type: Type(name: "[NSObject : AnyObject]", optional: true))
Expand Down Expand Up @@ -203,8 +205,9 @@ func nibStructForNib(nib: Nib) -> Struct {
reuseProtocols = []
}

let sanitizedName = sanitizedSwiftName(nib.name, lowercaseFirstCharacter: false)
return Struct(
type: Type(name: sanitizedSwiftName(nib.name, lowercaseFirstCharacter: false)),
type: Type(name: "_\(sanitizedName)"),
implements: [NibResourceProtocol.type] + reuseProtocols,
lets: [],
vars: [instanceVar] + reuseIdentifierVars,
Expand Down
38 changes: 23 additions & 15 deletions R.swift/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,39 @@ inputDirectories(NSProcessInfo.processInfo())
let reusables = (nibs.map { $0 as ReusableContainer } + storyboards.map { $0 as ReusableContainer })
.flatMap { $0.reusables }

// Generate
let structs = [
imageStructFromAssetFolders(assetFolders),
segueStructFromStoryboards(storyboards),
storyboardStructFromStoryboards(storyboards),
nibStructFromNibs(nibs),
reuseIdentifierStructFromReusables(reusables),
]

let functions = [
validateAllFunctionWithStoryboards(storyboards),
]

// Generate resource file contents
let resourceStruct = Struct(
type: Type(name: "R"),
lets: [],
vars: [],
functions: functions,
structs: structs
functions: [
validateAllFunctionWithStoryboards(storyboards),
],
structs: [
imageStructFromAssetFolders(assetFolders),
segueStructFromStoryboards(storyboards),
storyboardStructFromStoryboards(storyboards),
nibStructFromNibs(nibs),
reuseIdentifierStructFromReusables(reusables),
]
)

let internalResourceStruct = Struct(
type: Type(name: "_R"),
implements: [],
lets: [],
vars: [],
functions: [],
structs: [
internalNibStructFromNibs(nibs)
]
)

let fileContents = join("\n", [
Header, "",
Imports, "",
resourceStruct.description, "",
internalResourceStruct.description, "",
ReuseIdentifier.description, "",
NibResourceProtocol.description, "",
ReusableProtocol.description, "",
Expand Down

0 comments on commit 01fcd6b

Please sign in to comment.