32
32
import Foundation
33
33
import Dispatch
34
34
import SkipSQL
35
+ #if SKIP
36
+ import SkipFFI
37
+ #endif
35
38
36
39
/// A connection to SQLite.
37
40
public final class Connection {
@@ -104,10 +107,12 @@ public final class Connection {
104
107
/// - Returns: A new database connection.
105
108
public init ( _ location: Location = . inMemory, readonly: Bool = false ) throws {
106
109
let flags = readonly ? SQLITE_OPEN_READONLY : ( SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE)
107
- try check ( SQLite3 . sqlite3_open_v2 ( location. description,
108
- & _handle,
109
- flags | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_URI,
110
- nil ) )
110
+ try check ( withUnsafeMutablePointer ( to: & _handle) { ptr in
111
+ SQLite3 . sqlite3_open_v2 ( location. description,
112
+ ptr,
113
+ flags | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_URI,
114
+ nil )
115
+ } )
111
116
#if !SKIP // SkipSQLDB TODO
112
117
queue. setSpecific ( key: Connection . queueKey, value: queueContext)
113
118
#endif
@@ -128,7 +133,7 @@ public final class Connection {
128
133
///
129
134
/// - Returns: A new database connection.
130
135
public convenience init ( _ filename: String , readonly: Bool = false ) throws {
131
- try self . init ( . uri( filename) , readonly: readonly)
136
+ try self . init ( Location . uri ( filename) , readonly: readonly)
132
137
}
133
138
134
139
deinit {
@@ -687,12 +692,13 @@ public final class Connection {
687
692
throw error
688
693
}
689
694
690
-
695
+ #if !SKIP // SkipSQLDB TODO
691
696
fileprivate var queue = DispatchQueue ( label: " SQLite.Database " , attributes: [ ] )
692
697
693
698
fileprivate static let queueKey = DispatchSpecificKey < Int > ( )
694
699
695
700
fileprivate lazy var queueContext : Int = unsafeBitCast ( self , to: Int . self)
701
+ #endif
696
702
697
703
}
698
704
0 commit comments