Skip to content

Commit

Permalink
Remove old trace method
Browse files Browse the repository at this point in the history
  • Loading branch information
theolampert committed Oct 30, 2024
1 parent db34cab commit 81179da
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions Sources/SQLite/Core/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -437,34 +437,7 @@ public final class Connection {
///
/// db.trace { SQL in print(SQL) }
public func trace(_ callback: ((String) -> Void)?) {
if #available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *) {
trace_v2(callback)
} else {
trace_v1(callback)
}
}

@available(OSX, deprecated: 10.12)
@available(iOS, deprecated: 10.0)
@available(watchOS, deprecated: 3.0)
@available(tvOS, deprecated: 10.0)
fileprivate func trace_v1(_ callback: ((String) -> Void)?) {
guard let callback else {
sqlite3_trace(handle, nil /* xCallback */, nil /* pCtx */)
trace = nil
return
}
let box: Trace = { (pointer: UnsafeRawPointer) in
callback(String(cString: pointer.assumingMemoryBound(to: UInt8.self)))
}
sqlite3_trace(handle, { (context: UnsafeMutableRawPointer?, SQL: UnsafePointer<Int8>?) in
if let context, let SQL {
unsafeBitCast(context, to: Trace.self)(SQL)
}
},
unsafeBitCast(box, to: UnsafeMutableRawPointer.self)
)
trace = box
trace_v2(callback)
}

@available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *)
Expand Down

0 comments on commit 81179da

Please sign in to comment.