Skip to content

Commit

Permalink
Migrate to Swift 5 and fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Liz Soubirane committed Jul 5, 2024
1 parent fac0da3 commit 9d1128a
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
16 changes: 8 additions & 8 deletions Sources/DBus/Error.swift
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion Sources/DBus/Interface.swift
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion Sources/DBus/ObjectPath.swift
Original file line number Diff line number Diff line change
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
12 changes: 6 additions & 6 deletions Sources/DBus/Signature.swift
Original file line number Diff line number Diff line change
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,7 +636,7 @@ extension DBusSignature.DictionaryType: RawRepresentable {

public extension DBusSignature {

public struct StructureType {
struct StructureType {

@_versioned
internal private(set) var elements: [ValueType]
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

0 comments on commit 9d1128a

Please sign in to comment.