should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
//
// DuckDB
// https://github.com/duckdb/duckdb-swift
//
// Copyright © 2018-2024 Stichting DuckDB Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
#if canImport(TabularData)
import TabularData
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
public extension TabularData.Column {
/// Creates a tabular data column initialized from a DuckDB column
init(_ column: DuckDB.Column<WrappedElement>) {
self.init(name: column.name, contents: column)
}
}
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
public extension TabularData.AnyColumn {
/// Creates a type-erased tabular data column from a DuckDB column
init<T>(_ column: DuckDB.Column<T>) {
self = TabularData.Column(column).eraseToAnyColumn()
}
}
#endif

View File

@@ -0,0 +1,33 @@
//
// DuckDB
// https://github.com/duckdb/duckdb-swift
//
// Copyright © 2018-2024 Stichting DuckDB Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
import Foundation
public extension Foundation.Date {
/// Creates a date value initialized from a DuckDB Date value
init(_ date: Date) {
self.init(timeIntervalSince1970: TimeInterval(date.days * 24 * 60 * 60))
}
}

View File

@@ -0,0 +1,73 @@
//
// DuckDB
// https://github.com/duckdb/duckdb-swift
//
// Copyright © 2018-2024 Stichting DuckDB Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
import Foundation
public extension Decimal {
init(_ source: IntHuge) {
let magnitude = source.magnitude
let mantissa: (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
let significantBitCount = magnitude.bitWidth - magnitude.leadingZeroBitCount
let length = (significantBitCount + (UInt16.bitWidth - 1)) / UInt16.bitWidth
mantissa.0 = UInt16(truncatingIfNeeded: magnitude >> (0 * 16))
mantissa.1 = UInt16(truncatingIfNeeded: magnitude >> (1 * 16))
mantissa.2 = UInt16(truncatingIfNeeded: magnitude >> (2 * 16))
mantissa.3 = UInt16(truncatingIfNeeded: magnitude >> (3 * 16))
mantissa.4 = UInt16(truncatingIfNeeded: magnitude >> (4 * 16))
mantissa.5 = UInt16(truncatingIfNeeded: magnitude >> (5 * 16))
mantissa.6 = UInt16(truncatingIfNeeded: magnitude >> (6 * 16))
mantissa.7 = UInt16(truncatingIfNeeded: magnitude >> (7 * 16))
self = .init(
_exponent: 0,
_length: UInt32(length),
_isNegative: source.signum() < 0 ? 1 : 0,
_isCompact: 0,
_reserved: 0,
_mantissa: mantissa
)
}
init(_ source: UIntHuge) {
let mantissa: (UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16, UInt16)
let significantBitCount = source.bitWidth - source.leadingZeroBitCount
let length = (significantBitCount + (UInt16.bitWidth - 1)) / UInt16.bitWidth
mantissa.0 = UInt16(truncatingIfNeeded: source >> (0 * 16))
mantissa.1 = UInt16(truncatingIfNeeded: source >> (1 * 16))
mantissa.2 = UInt16(truncatingIfNeeded: source >> (2 * 16))
mantissa.3 = UInt16(truncatingIfNeeded: source >> (3 * 16))
mantissa.4 = UInt16(truncatingIfNeeded: source >> (4 * 16))
mantissa.5 = UInt16(truncatingIfNeeded: source >> (5 * 16))
mantissa.6 = UInt16(truncatingIfNeeded: source >> (6 * 16))
mantissa.7 = UInt16(truncatingIfNeeded: source >> (7 * 16))
self = .init(
_exponent: 0,
_length: UInt32(length),
_isNegative: 0,
_isCompact: 0,
_reserved: 0,
_mantissa: mantissa
)
}
}

View File

@@ -0,0 +1,41 @@
//
// DuckDB
// https://github.com/duckdb/duckdb-swift
//
// Copyright © 2018-2024 Stichting DuckDB Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
import Foundation
public extension Foundation.Date {
/// Creates a date value initialized from a DuckDB Time value
init(_ date: Time) {
self.init(timeIntervalSince1970: TimeInterval(date.microseconds) * 1e-3)
}
}
public extension Time {
/// Creates a time value initialized from a Foundation Date
init(_ date: Foundation.Date) {
self.init(microseconds: Int64(date.timeIntervalSince1970 * 1e3))
}
}

View File

@@ -0,0 +1,41 @@
//
// DuckDB
// https://github.com/duckdb/duckdb-swift
//
// Copyright © 2018-2024 Stichting DuckDB Foundation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
import Foundation
public extension Foundation.Date {
/// Creates a date value initialized from a DuckDB Timestamp value
init(_ timestamp: Timestamp) {
self.init(timeIntervalSince1970: TimeInterval(timestamp.microseconds) * 1e-3)
}
}
public extension Timestamp {
/// Creates a timestamp value initialized from a Foundation Date
init(_ date: Foundation.Date) {
self.init(microseconds: Int64(date.timeIntervalSince1970 * 1e3))
}
}