|
@@ -23,17 +23,17 @@
|
|
|
|
|
|
/* array of bits */
|
|
/* array of bits */
|
|
extension Int {
|
|
extension Int {
|
|
-
|
|
|
|
init(bits: [Bit]) {
|
|
init(bits: [Bit]) {
|
|
self.init(bitPattern: integerFrom(bits) as UInt)
|
|
self.init(bitPattern: integerFrom(bits) as UInt)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/* array of bytes */
|
|
|
|
-extension Int {
|
|
|
|
-
|
|
|
|
- /** Array of bytes with optional padding */
|
|
|
|
- func bytes(totalBytes: Int = MemoryLayout<Int>.size) -> Array<UInt8> {
|
|
|
|
|
|
+extension FixedWidthInteger {
|
|
|
|
+ @_transparent
|
|
|
|
+ func bytes(totalBytes: Int = MemoryLayout<Self>.size) -> Array<UInt8> {
|
|
return arrayOfBytes(value: self, length: totalBytes)
|
|
return arrayOfBytes(value: self, length: totalBytes)
|
|
|
|
+ // TODO: adjust bytes order
|
|
|
|
+ // var value = self
|
|
|
|
+ // return withUnsafeBytes(of: &value, Array.init).reversed()
|
|
}
|
|
}
|
|
}
|
|
}
|