File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Sources/SwiftDocC/Utility/LMDB Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,24 @@ extension String: LMDBData {
8989 }
9090}
9191
92- extension Array : LMDBData where Element: FixedWidthInteger { }
92+ // This is required for macOS, for Linux the default implementation works as expected.
93+ extension Array : LMDBData where Element: FixedWidthInteger {
94+
95+ #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
96+ public init ? ( data: UnsafeRawBufferPointer ) {
97+ var array = Array < Element > ( repeating: 0 , count: data. count / MemoryLayout< Element> . stride)
98+ _ = array. withUnsafeMutableBytes { data. copyBytes ( to: $0) }
99+ self = array
100+ }
101+
102+ public func read< R> ( _ body: ( UnsafeRawBufferPointer ) throws -> R ) rethrows -> R {
103+ let data = self . withUnsafeBufferPointer { Data ( buffer: $0) }
104+ return try data. read ( body)
105+ }
106+ #endif
107+
108+ }
109+
93110extension Bool : LMDBData { }
94111extension Int : LMDBData { }
95112extension Int8 : LMDBData { }
You can’t perform that action at this time.
0 commit comments