Skip to content

Commit 6fa8c69

Browse files
committed
[plutil] Rename DisplayType enum cases
1 parent 4111cc9 commit 6fa8c69

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

Diff for: Tools/plutil/main.swift

+37-35
Original file line numberDiff line numberDiff line change
@@ -183,109 +183,111 @@ func convert(_ options: Options) -> Int32 {
183183
}
184184

185185
enum DisplayType {
186-
case Primary
187-
case Key
188-
case Value
186+
case primary
187+
case key
188+
case value
189189
}
190190

191191
extension Dictionary {
192-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
192+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
193193
let indentation = String(repeating: " ", count: indent * 2)
194-
if type == .Primary || type == .Key {
194+
switch type {
195+
case .primary, .key:
195196
print("\(indentation)[\n", terminator: "")
196-
} else {
197+
case .value:
197198
print("[\n", terminator: "")
198199
}
199-
200+
200201
forEach() {
201202
if let key = $0.0 as? String {
202-
key.display(indent + 1, type: .Key)
203+
key.display(indent + 1, type: .key)
203204
} else {
204205
fatalError("plists should have strings as keys but got a \(type(of: $0.0))")
205206
}
206207
print(" => ", terminator: "")
207-
displayPlist($0.1, indent: indent + 1, type: .Value)
208+
displayPlist($0.1, indent: indent + 1, type: .value)
208209
}
209210

210211
print("\(indentation)]\n", terminator: "")
211212
}
212213
}
213214

214215
extension Array {
215-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
216+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
216217
let indentation = String(repeating: " ", count: indent * 2)
217-
if type == .Primary || type == .Key {
218+
switch type {
219+
case .primary, .key:
218220
print("\(indentation)[\n", terminator: "")
219-
} else {
221+
case .value:
220222
print("[\n", terminator: "")
221223
}
222-
224+
223225
for idx in 0..<count {
224226
print("\(indentation) \(idx) => ", terminator: "")
225-
displayPlist(self[idx], indent: indent + 1, type: .Value)
227+
displayPlist(self[idx], indent: indent + 1, type: .value)
226228
}
227229

228230
print("\(indentation)]\n", terminator: "")
229231
}
230232
}
231233

232234
extension String {
233-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
235+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
234236
let indentation = String(repeating: " ", count: indent * 2)
235-
if type == .Primary {
237+
switch type {
238+
case .primary:
236239
print("\(indentation)\"\(self)\"\n", terminator: "")
237-
}
238-
else if type == .Key {
240+
case .key:
239241
print("\(indentation)\"\(self)\"", terminator: "")
240-
} else {
242+
case .value:
241243
print("\"\(self)\"\n", terminator: "")
242244
}
243245
}
244246
}
245247

246248
extension Bool {
247-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
249+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
248250
let indentation = String(repeating: " ", count: indent * 2)
249-
if type == .Primary {
251+
switch type {
252+
case .primary:
250253
print("\(indentation)\"\(self ? "1" : "0")\"\n", terminator: "")
251-
}
252-
else if type == .Key {
254+
case .key:
253255
print("\(indentation)\"\(self ? "1" : "0")\"", terminator: "")
254-
} else {
256+
case .value:
255257
print("\"\(self ? "1" : "0")\"\n", terminator: "")
256258
}
257259
}
258260
}
259261

260262
extension NSNumber {
261-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
263+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
262264
let indentation = String(repeating: " ", count: indent * 2)
263-
if type == .Primary {
265+
switch type {
266+
case .primary:
264267
print("\(indentation)\"\(self)\"\n", terminator: "")
265-
}
266-
else if type == .Key {
268+
case .key:
267269
print("\(indentation)\"\(self)\"", terminator: "")
268-
} else {
270+
case .value:
269271
print("\"\(self)\"\n", terminator: "")
270272
}
271273
}
272274
}
273275

274276
extension NSData {
275-
func display(_ indent: Int = 0, type: DisplayType = .Primary) {
277+
func display(_ indent: Int = 0, type: DisplayType = .primary) {
276278
let indentation = String(repeating: " ", count: indent * 2)
277-
if type == .Primary {
279+
switch type {
280+
case .primary:
278281
print("\(indentation)\"\(self)\"\n", terminator: "")
279-
}
280-
else if type == .Key {
282+
case .key:
281283
print("\(indentation)\"\(self)\"", terminator: "")
282-
} else {
284+
case .value:
283285
print("\"\(self)\"\n", terminator: "")
284286
}
285287
}
286288
}
287289

288-
func displayPlist(_ plist: Any, indent: Int = 0, type: DisplayType = .Primary) {
290+
func displayPlist(_ plist: Any, indent: Int = 0, type: DisplayType = .primary) {
289291
if let val = plist as? Dictionary<String, Any> {
290292
val.display(indent, type: type)
291293
} else if let val = plist as? Array<Any> {

0 commit comments

Comments
 (0)