0001 // 0002 // SnapKit 0003 // 0004 // Copyright (c) 2011-2015 SnapKit Team - https://github.com/SnapKit 0005 // 0006 // Permission is hereby granted, free of charge, to any person obtaining a copy 0007 // of this software and associated documentation files (the "Software"), to deal 0008 // in the Software without restriction, including without limitation the rights 0009 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0010 // copies of the Software, and to permit persons to whom the Software is 0011 // furnished to do so, subject to the following conditions: 0012 // 0013 // The above copyright notice and this permission notice shall be included in 0014 // all copies or substantial portions of the Software. 0015 // 0016 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0017 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0018 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0019 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0020 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0021 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 0022 // THE SOFTWARE. 0023 0024 #if os(iOS) || os(tvOS) 0025 import UIKit 0026 #else 0027 import AppKit 0028 #endif 0029 0030 /** 0031 Used to allow adding a snp_label to a View for debugging purposes 0032 */ 0033 public extension View { 0034 0035 public var snp_label: String? { 0036 get { 0037 return objc_getAssociatedObject(self, &labelKey) as? String 0038 } 0039 set { 0040 objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC) 0041 } 0042 } 0043 0044 } 0045 0046 /** 0047 Used to allow adding a snp_label to a LayoutConstraint for debugging purposes 0048 */ 0049 public extension LayoutConstraint { 0050 0051 public var snp_label
Debugging.swift:122 desc += ":\(object.snp_label ?? pointerDescription)": String? { 0052 get { 0053 return objc_getAssociatedObject(self, &labelKey) as? String 0054 } 0055 set { 0056 objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC) 0057 } 0058 } 0059 0060 override public var description: String { 0061 var description = "<" 0062 0063 description += descriptionForObject(self) 0064 0065 description += " \(descriptionForObject(self.firstItem))" 0066 if self.firstAttribute != .NotAnAttribute { 0067 description += ".\(self.firstAttribute.snp_description)" 0068 } 0069 0070 description += " \(self.relation.snp_description)" 0071 0072 if let secondItem: AnyObject = self.secondItem { 0073 description += " \(descriptionForObject(secondItem))" 0074 } 0075 0076 if self.secondAttribute != .NotAnAttribute { 0077 description += ".\(self.secondAttribute.snp_description)" 0078 } 0079 0080 if self.multiplier != 1.0 { 0081 description += " * \(self.multiplier)" 0082 } 0083 0084 if self.secondAttribute == .NotAnAttribute { 0085 description += " \(self.constant)" 0086 } else { 0087 if self.constant > 0.0 { 0088 description += " + \(self.constant)" 0089 } else if self.constant < 0.0 { 0090 description += " - \(CGFloat.abs(self.constant))" 0091 } 0092 } 0093 0094 if self.priority != 1000.0 { 0095 description += " ^\(self.priority)" 0096 } 0097 0098 description += ">" 0099 0100 return description 0101 } 0102 0103 internal var snp_makerFile
Debugging.swift:124 desc += ":\(object.snp_label ?? pointerDescription)": String? { 0104 return self.snp_constraint?.makerFile 0105 } 0106 0107 internal var snp_makerLine
Debugging.swift:129 if let object = object as? LayoutConstraint, let file = object.snp_makerFile, let line = object.snp_makerLine {: UInt? { 0108 return self.snp_constraint?.makerLine 0109 } 0110 0111 } 0112 0113 private var labelKey
Debugging.swift:129 if let object = object as? LayoutConstraint, let file = object.snp_makerFile, let line = object.snp_makerLine {= "" 0114 0115 private func descriptionForObject
Debugging.swift:37 return objc_getAssociatedObject(self, &labelKey) as? StringDebugging.swift:40 objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC)Debugging.swift:53 return objc_getAssociatedObject(self, &labelKey) as? StringDebugging.swift:56 objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY_NONATOMIC)(object: AnyObject) -> String { 0116 let pointerDescription = NSString(format: "%p", ObjectIdentifier(object).uintValue) 0117 var desc = "" 0118 0119 desc += object.dynamicType.description() 0120 0121 if let object = object as? View { 0122 desc += ":\(object.snp_label ?? pointerDescription)" 0123 } else if let object = object as? LayoutConstraint { 0124 desc += ":\(object.snp_label ?? pointerDescription)" 0125 } else { 0126 desc += ":\(pointerDescription)" 0127 } 0128 0129 if let object = object as? LayoutConstraint, let file = object.snp_makerFile, let line = object.snp_makerLine { 0130 desc += "@\(file)#\(line)" 0131 } 0132 0133 desc += "" 0134 return desc 0135 } 0136 0137 private extension NSLayoutRelation { 0138 0139 private var snp_description
Debugging.swift:63 description += descriptionForObject(self)Debugging.swift:65 description += " \(descriptionForObject(self.firstItem))"Debugging.swift:73 description += " \(descriptionForObject(secondItem))": String { 0140 switch self { 0141 case .Equal: return "==" 0142 case .GreaterThanOrEqual: return ">=" 0143 case .LessThanOrEqual: return "<=" 0144 } 0145 } 0146 0147 } 0148 0149 private extension NSLayoutAttribute { 0150 0151 private var snp_description
Debugging.swift:70 description += " \(self.relation.snp_description)": String { 0152 #if os(iOS) || os(tvOS) 0153 switch self { 0154 case .NotAnAttribute: return "notAnAttribute" 0155 case .Top: return "top" 0156 case .Left: return "left" 0157 case .Bottom: return "bottom" 0158 case .Right: return "right" 0159 case .Leading: return "leading" 0160 case .Trailing: return "trailing" 0161 case .Width: return "width" 0162 case .Height: return "height" 0163 case .CenterX: return "centerX" 0164 case .CenterY: return "centerY" 0165 case .Baseline: return "baseline" 0166 case .FirstBaseline: return "firstBaseline" 0167 case .TopMargin: return "topMargin" 0168 case .LeftMargin: return "leftMargin" 0169 case .BottomMargin: return "bottomMargin" 0170 case .RightMargin: return "rightMargin" 0171 case .LeadingMargin: return "leadingMargin" 0172 case .TrailingMargin: return "trailingMargin" 0173 case .CenterXWithinMargins: return "centerXWithinMargins" 0174 case .CenterYWithinMargins: return "centerYWithinMargins" 0175 } 0176 #else 0177 switch self { 0178 case .NotAnAttribute: return "notAnAttribute" 0179 case .Top: return "top" 0180 case .Left: return "left" 0181 case .Bottom: return "bottom" 0182 case .Right: return "right" 0183 case .Leading: return "leading" 0184 case .Trailing: return "trailing" 0185 case .Width: return "width" 0186 case .Height: return "height" 0187 case .CenterX: return "centerX" 0188 case .CenterY: return "centerY" 0189 case .Baseline: return "baseline" 0190 default: return "default" 0191 } 0192 #endif 0193 0194 } 0195 0196 } 0197
Debugging.swift:67 description += ".\(self.firstAttribute.snp_description)"Debugging.swift:77 description += ".\(self.secondAttribute.snp_description)"