Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Swift 5 #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ let package = Package(
]
)
],
swiftLanguageVersions: [4]
swiftLanguageVersions: [5]
)
2 changes: 1 addition & 1 deletion Sources/DBus/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public final class DBusConnection {
// MARK: - Class Methods

/// This method sets a global flag for whether `dbus_connection_new()` will set `SIGPIPE` behavior to `SIG_IGN`.
public static func setChangeSIGPIPE(change: Bool) {
static func setChangeSIGPIPE(change: Bool) {

dbus_connection_set_change_sigpipe(dbus_bool_t(change))
}
Expand Down
18 changes: 9 additions & 9 deletions Sources/DBus/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct DBusError: Error, Equatable, Hashable {
internal extension DBusError {

/// Internal class for working with the C DBus error API
internal final class Reference {
final class Reference {

// MARK: - Internal Properties

Expand Down Expand Up @@ -126,7 +126,7 @@ extension DBusError: CustomNSError {

public extension DBusError {

public struct Name: Equatable, Hashable {
struct Name: Equatable, Hashable {

public let rawValue: String

Expand All @@ -143,7 +143,7 @@ public extension DBusError {

public extension DBusError.Name {

public init(_ interface: DBusInterface) {
init(_ interface: DBusInterface) {

// should be valid
self.rawValue = interface.rawValue
Expand All @@ -163,32 +163,32 @@ public extension DBusError.Name {
/// A generic error; "something went wrong" - see the error message for more.
///
/// `org.freedesktop.DBus.Error.Failed`
public static let failed = DBusError.Name(rawValue: DBUS_ERROR_FAILED)!
static let failed = DBusError.Name(rawValue: DBUS_ERROR_FAILED)!

/// No Memory
///
/// `org.freedesktop.DBus.Error.NoMemory`
public static let noMemory = DBusError.Name(rawValue: DBUS_ERROR_NO_MEMORY)!
static let noMemory = DBusError.Name(rawValue: DBUS_ERROR_NO_MEMORY)!

/// Existing file and the operation you're using does not silently overwrite.
///
/// `org.freedesktop.DBus.Error.FileExists`
public static let fileExists = DBusError.Name(rawValue: DBUS_ERROR_FILE_EXISTS)!
static let fileExists = DBusError.Name(rawValue: DBUS_ERROR_FILE_EXISTS)!

/// Missing file.
///
/// `org.freedesktop.DBus.Error.FileNotFound`
public static let fileNotFound = DBusError.Name(rawValue: DBUS_ERROR_FILE_NOT_FOUND)!
static let fileNotFound = DBusError.Name(rawValue: DBUS_ERROR_FILE_NOT_FOUND)!

/// Invalid arguments
///
/// `org.freedesktop.DBus.Error.InvalidArgs`
public static let invalidArguments = DBusError.Name(rawValue: DBUS_ERROR_INVALID_ARGS)!
static let invalidArguments = DBusError.Name(rawValue: DBUS_ERROR_INVALID_ARGS)!

/// Invalid signature
///
/// `org.freedesktop.DBus.Error.InvalidSignature`
public static let invalidSignature = DBusError.Name(rawValue: DBUS_ERROR_INVALID_SIGNATURE)!
static let invalidSignature = DBusError.Name(rawValue: DBUS_ERROR_INVALID_SIGNATURE)!
}

extension DBusError.Name: CustomStringConvertible {
Expand Down
6 changes: 3 additions & 3 deletions Sources/DBus/Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import CDBus
*/
public struct DBusInterface {

@_versioned
@usableFromInline
internal private(set) var elements: [Element]

/// Cached string.
Expand All @@ -46,7 +46,7 @@ public struct DBusInterface {
/// - Note: Any subsequent mutation will set this value to nil, and `rawValue` and `description` getters
/// will have to rebuild the string for every invocation. Mutating leads to an unoptimized code path,
/// but for values created from either a string or an array of elements, this value is cached.
@_versioned
@usableFromInline
internal private(set) var string: String?

/// Initialize with an array of elements.
Expand Down Expand Up @@ -226,7 +226,7 @@ extension DBusInterface: RandomAccessCollection { }
public extension DBusInterface {

/// An element in the object path
public struct Element {
struct Element {

/// Don't copy buffer of individual elements, because these elements will always be created
/// from a bigger string, which we should just internally reference.
Expand Down
10 changes: 5 additions & 5 deletions Sources/DBus/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public extension DBusMessage {
/**
Creates a new message that is an exact replica of the message specified, except that its refcount is set to 1, its message serial is reset to 0, and if the original message was "locked" (in the outgoing message queue and thus not modifiable) the new message will not be locked.
*/
public func copy() throws -> DBusMessage {
func copy() throws -> DBusMessage {

guard let copyPointer = dbus_message_copy(internalPointer)
else { throw DBusError(name: .noMemory, message: "Could not copy message") }
Expand All @@ -391,7 +391,7 @@ extension DBusMessage: Sequence {
public extension DBusMessage {

/// DBus Message Iterator
public struct Iterator: IteratorProtocol {
struct Iterator: IteratorProtocol {

public typealias Element = DBusMessageArgument

Expand All @@ -416,7 +416,7 @@ public extension DBusMessage {

public extension DBusMessage {

public struct Error {
struct Error {

public let replyTo: DBusMessage
public let name: DBusError.Name
Expand All @@ -438,7 +438,7 @@ public extension DBusMessage {

public extension DBusMessage {

public struct MethodCall {
struct MethodCall {

public let destination: DBusBusName?
public let path: DBusObjectPath
Expand All @@ -450,7 +450,7 @@ public extension DBusMessage {
public extension DBusMessage {

/// A signal is identified by its originating object path, interface, and the name of the signal.
public struct Signal {
struct Signal {

public let path: String
public let interface: String
Expand Down
8 changes: 4 additions & 4 deletions Sources/DBus/MessageArgument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum DBusMessageArgument: Equatable {
public extension DBusMessageArgument {

/// Argument value type.
public var type: DBusSignature.ValueType {
var type: DBusSignature.ValueType {

switch self {
case .byte: return .byte
Expand All @@ -62,7 +62,7 @@ public extension DBusMessageArgument {
public extension DBusMessageArgument {

/// File Descriptor
public struct FileDescriptor: RawRepresentable, Equatable, Hashable {
struct FileDescriptor: RawRepresentable, Equatable, Hashable {

public var rawValue: CInt

Expand All @@ -76,7 +76,7 @@ public extension DBusMessageArgument {
public extension DBusMessageArgument {

/// Structure
public struct Structure: Equatable {
struct Structure: Equatable {

/// Structure elements.
internal let elements: [DBusMessageArgument]
Expand Down Expand Up @@ -148,7 +148,7 @@ extension DBusMessageArgument.Structure: RandomAccessCollection {

public extension DBusMessageArgument {

public struct Array: Equatable {
struct Array: Equatable {

/// Array elements.
internal let elements: [DBusMessageArgument]
Expand Down
6 changes: 3 additions & 3 deletions Sources/DBus/ObjectPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import CDBus
*/
public struct DBusObjectPath {

@_versioned
@usableFromInline
internal private(set) var elements: [Element]

/// Cached string.
Expand All @@ -36,7 +36,7 @@ public struct DBusObjectPath {
/// - Note: Any subsequent mutation will set this value to nil, and `rawValue` and `description` getters
/// will have to rebuild the string for every invocation. So mutating leads to the unoptimized code path,
/// but for values created from either a string or an array of elements, this value is cached.
@_versioned
@usableFromInline
internal private(set) var string: String?

/// Initialize with an array of elements.
Expand Down Expand Up @@ -274,7 +274,7 @@ extension DBusObjectPath: RandomAccessCollection { }
public extension DBusObjectPath {

/// An element in the object path
public struct Element {
struct Element {

/// Don't copy buffer of individual elements, because these elements will always be created
/// from a bigger string, which we should just internally reference.
Expand Down
18 changes: 9 additions & 9 deletions Sources/DBus/Signature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CDBus
public struct DBusSignature {

/// Elements.
@_versioned
@usableFromInline
internal private(set) var elements: [Element]

/// Cached string.
Expand All @@ -20,7 +20,7 @@ public struct DBusSignature {
/// - Note: Any subsequent mutation will set this value to nil, and `rawValue` and `description` getters
/// will have to rebuild the string for every invocation. Mutating leads to an unoptimized code path,
/// but for values created from either a string or an array of elements, this value is cached.
@_versioned
@usableFromInline
internal private(set) var string: String?

public init(_ elements: [Element] = []) {
Expand Down Expand Up @@ -359,7 +359,7 @@ extension DBusSignature: RandomAccessCollection { }

public extension DBusSignature {

public indirect enum ValueType: Equatable {
indirect enum ValueType: Equatable {

/// Type code marking an 8-bit unsigned integer.
case byte
Expand Down Expand Up @@ -432,7 +432,7 @@ public extension DBusSignature {

public extension DBusSignature.ValueType {

public var isContainer: Bool {
var isContainer: Bool {

switch self {
case .struct,
Expand Down Expand Up @@ -464,7 +464,7 @@ public extension String {
public extension DBusSignature {

/// DBus Signature Character
public enum Character: String {
enum Character: String {

// MARK: - Fixed Length Types

Expand Down Expand Up @@ -592,7 +592,7 @@ public extension String {

public extension DBusSignature {

public struct DictionaryType: Equatable {
struct DictionaryType: Equatable {

public let key: ValueType

Expand Down Expand Up @@ -636,9 +636,9 @@ extension DBusSignature.DictionaryType: RawRepresentable {

public extension DBusSignature {

public struct StructureType {
struct StructureType {

@_versioned
@usableFromInline
internal private(set) var elements: [ValueType]

/// Empty structures are not allowed; there must be at least one type code between the parentheses.
Expand All @@ -662,7 +662,7 @@ extension DBusSignature.StructureType: Equatable {

public extension DBusSignature.StructureType {

public var characters: [DBusSignature.Character] {
var characters: [DBusSignature.Character] {

return [.structStart] + elements.reduce([], { $0 + $1.characters }) + [.structEnd]
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/DBus/Timeout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public struct Timeout: RawRepresentable {

public extension Timeout {

public static let `default`: Timeout = -1 //Timeout(rawValue: DBUS_TIMEOUT_USE_DEFAULT)
static let `default`: Timeout = -1 //Timeout(rawValue: DBUS_TIMEOUT_USE_DEFAULT)

public static let infinite: Timeout = Timeout(rawValue: .max) //Timeout(rawValue: DBUS_TIMEOUT_INFINITE)
static let infinite: Timeout = Timeout(rawValue: .max) //Timeout(rawValue: DBUS_TIMEOUT_INFINITE)
}

extension Timeout: ExpressibleByIntegerLiteral {
Expand Down