1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

Swift native in/out array handling

This commit is contained in:
Giles Payne
2020-09-03 21:31:11 +09:00
parent bedabc15ae
commit 8b61719a9d
13 changed files with 347 additions and 136 deletions
@@ -12,6 +12,11 @@ public extension ByteVector {
self.init(data:data);
}
convenience init(_ array:[UInt8]) {
let data = array.withUnsafeBufferPointer { Data(buffer: $0) }
self.init(data:data);
}
subscript(index: Int) -> Int8 {
get {
return self.get(index)
@@ -25,6 +30,14 @@ public extension ByteVector {
return ret
}
}
var unsignedArray: [UInt8] {
get {
var ret = Array<UInt8>(repeating: 0, count: data.count/MemoryLayout<UInt8>.stride)
_ = ret.withUnsafeMutableBytes { data.copyBytes(to: $0) }
return ret
}
}
}
extension ByteVector : Sequence {