-
-
Save wjlafrance/c25dd6e6a3c802685292 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef NS_OPTIONS(NSUInteger, LSRBorderSide) { | |
LSRBorderSideNone = 1 << 0, | |
LSRBorderSideLeft = 1 << 1, | |
LSRBorderSideRight = 1 << 2, | |
LSRBorderSideBottom = 1 << 3, | |
LSRBorderSideTop = 1 << 4 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Nasty implementation of NS_Options for Swift. | |
struct Border : RawOptionSetType, BooleanType { | |
//Detailed protocol implementation of RawOptionSetType which is a collection of protocols listed here -> _RawOptionSetType, BitwiseOperationsType, NilLiteralConvertible | |
typealias RawValue = UInt | |
private var value: UInt = 0 | |
init(_ value: UInt) { self.value = value } | |
init(rawValue value: UInt) { self.value = value } | |
init(nilLiteral: ()) { self.value = 0 } | |
static var allZeros: Border { return self(0) } | |
static func fromMask(raw: UInt) -> Border { return self(raw) } | |
var rawValue: UInt { return self.value } | |
//Implementation of BooleanType protocol | |
var boolValue:Bool { get { return self.value != 0 }} | |
static var None: Border { return self(0) } | |
static var Left: Border { return Border(1 << 0) } | |
static var Right: Border { return Border(1 << 1) } | |
static var Bottom: Border { return Border(1 << 2) } | |
static var Top: Border { return Border(1 << 3) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment