diff --git a/.swift-version b/.swift-version index 6b244dc..cdb98d2 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.0.1 +5.1.3 diff --git a/.swiftlint.yml b/.swiftlint.yml index c4f007b..8b07cad 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,15 +1,25 @@ included: - Sources + - Tests excluded: - - docs + - .build - build + - docs - Sources/CImGui - Sources/Demos - - Tests + - Sources/Demos/*/main.swift - Sources/ImGui/ImGui+Definitions.swift + - Tests/*/*/XCTestManifests.swift + - Tests/*/XCTestManifests.swift + - Tests/LinuxMain.swift identifier_name: excluded: - id + - i + - y + - x + - z + - w line_length: 220 number_separator: minimum_length: 5 @@ -89,7 +99,7 @@ opt_in_rules: - switch_case_on_newline - toggle_bool - trailing_closure - - unavailable_function + #- unavailable_function - unneeded_parentheses_in_closure_argument - untyped_error_in_catch - unused_import diff --git a/Makefile b/Makefile index d4478e9..85bc0b2 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ lint: swiftlint autocorrect --format swiftlint lint --quiet +lintErrorOnly: + @swiftlint autocorrect --format --quiet + @swiftlint lint --quiet | grep error + genLinuxTests: swift test --generate-linuxmain swiftlint autocorrect --format --path Tests/ @@ -60,3 +64,6 @@ genXcodeOpen: genXcode open *.xcodeproj precommit: lint genLinuxTests + +testReadme: + markdown-link-check -p -v ./README.md diff --git a/Package.swift b/Package.swift index d64ee0f..ab5f585 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.1 import PackageDescription var package = Package( diff --git a/README.md b/README.md index cbbdae7..9d91890 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ import PackageDescription let package = Package( name: "YourPackageName", dependencies: [ - .package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.0.0") + .package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.1.0") ], targets: [ .target( @@ -108,7 +108,7 @@ Things that need to be done are, among others: ## 🏷️ Versioning -We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](tags). +We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](/releases). ## ✍️ Authors diff --git a/Sources/AutoWrapper/ArgT.swift b/Sources/AutoWrapper/ArgT.swift index 4bd98c4..18f4659 100644 --- a/Sources/AutoWrapper/ArgT.swift +++ b/Sources/AutoWrapper/ArgT.swift @@ -5,18 +5,16 @@ // Created by Christian Treffs on 25.10.19. // -struct ArgType: Decodable { - let isConst: Bool +public struct ArgType: Decodable { + public let isConst: Bool + public let isUnsigned: Bool + public let type: DataType - let isUnsigned: Bool - - let type: DataType - - @inlinable var isValid: Bool { - return type.isValid + @inlinable public var isValid: Bool { + type.isValid } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() var raw: String = try container.decode(String.self) @@ -47,20 +45,20 @@ struct ArgType: Decodable { extension ArgType: Equatable { } extension ArgType: Hashable { } -struct ArgsT: Decodable { - let name: String - let type: DataType - let ret: String? - let signature: String? +public struct ArgsT: Decodable { + public let name: String + public let type: DataType + public let ret: String? + public let signature: String? - enum Keys: String, CodingKey { + public enum Keys: String, CodingKey { case name case type case ret case signature } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: Keys.self) self.name = try container.decode(String.self, forKey: .name).swiftEscaped self.type = try container.decode(DataType.self, forKey: .type) @@ -68,11 +66,11 @@ struct ArgsT: Decodable { self.signature = try container.decodeIfPresent(String.self, forKey: .signature) } - @inlinable var isValid: Bool { - return type.isValid && name != "..." + @inlinable public var isValid: Bool { + type.isValid && name != "..." } - var argName: String { + public var argName: String { switch name { case "...": return "arguments" @@ -81,7 +79,7 @@ struct ArgsT: Decodable { } } - var toSwift: String { + public var toSwift: String { switch self.type.type { case let .custom(name) where name.hasSuffix("Callback") && argName.contains("callback"): return "_ \(argName): @escaping \(self.type.toString(.argSwift))" @@ -90,7 +88,8 @@ struct ArgsT: Decodable { } } - func wrapCArg(_ arg: String) -> String { + // swiftlint:disable:next cyclomatic_complexity + public func wrapCArg(_ arg: String) -> String { switch self.type.meta { case .primitive: return arg @@ -100,7 +99,13 @@ struct ArgsT: Decodable { case .array: return "&\(arg)" case let .arrayFixedSize(count) where self.type.isConst == false: - return "UnsafeMutableBufferPointer<\(self.type.toString(.argSwift, wrapped: false))>(start: &\(arg).0, count: \(count)).baseAddress!" + if type.type.isNumber && count < 5 { + // SIMD + return "withUnsafeMutablePointer(to: &\(arg)) { $0.withMemoryRebound(to: \(self.type.toString(.argSwift, wrapped: false)).self, capacity: \(count)) { $0 } }" + } else { + return "UnsafeMutableBufferPointer<\(self.type.toString(.argSwift, wrapped: false))>(start: &\(arg).0, count: \(count)).baseAddress!" + } + case let .arrayFixedSize(count): return "UnsafeBufferPointer<\(self.type.toString(.argSwift, wrapped: false))>(start: &\(arg).0, count: \(count)).baseAddress!" case .reference: @@ -121,7 +126,7 @@ struct ArgsT: Decodable { } } - var toC: String { + public var toC: String { var out: String = argName switch type.type { case .char where type.isConst == true && type.meta == .pointer: diff --git a/Sources/AutoWrapper/DataType.swift b/Sources/AutoWrapper/DataType.swift index 9ae285e..b3bc550 100644 --- a/Sources/AutoWrapper/DataType.swift +++ b/Sources/AutoWrapper/DataType.swift @@ -5,28 +5,30 @@ // Created by Christian Treffs on 25.10.19. // -struct DataType: Decodable { - let meta: MetaType - let isConst: Bool - let type: ValueType - - init(meta: MetaType, type: ValueType, isConst: Bool) { +// swiftlint:disable cyclomatic_complexity +// swiftlint:disable function_body_length +public struct DataType: Decodable { + public let meta: MetaType + public let isConst: Bool + public let type: ValueType + + public init(meta: MetaType, type: ValueType, isConst: Bool) { self.meta = meta self.type = type self.isConst = isConst } - @inlinable var isValid: Bool { - return meta != .unknown && type != .unknown && type != .generic + @inlinable public var isValid: Bool { + meta != .unknown && type != .unknown && type != .generic } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() let raw = try container.decode(String.self) self.init(string: raw) } - init(string: String) { + public init(string: String) { var string = string // const @@ -119,13 +121,13 @@ struct DataType: Decodable { } - enum Context { + public enum Context { case argSwift case argC case ret } - func wrapIn(_ context: Context, _ toWrap: String) -> String { + public func wrapIn(_ context: Context, _ toWrap: String) -> String { switch meta { case .primitive: return toWrap @@ -141,8 +143,14 @@ struct DataType: Decodable { return "inout [\(toWrap)]" //return "inout UnsafePointer<\(toWrap)>!" case let .arrayFixedSize(size) where isConst == false: - // tuple - return "inout (\((0.." + } else { + // tuple + return "inout (\((0.. String { + public func toString(_ context: Context, wrapped: Bool = true) -> String { let out: String switch type { @@ -214,92 +222,6 @@ struct DataType: Decodable { return out } } - - // - // var toSwift: String { - // switch (type, meta, isConst) { - // case (.void, _, _): - // return "Void" - // case (.bool, _, _): - // return "Bool" - // case (.int, _, _): - // return "Int32" - // case (.uint, _, _): - // return "UInt32" - // case (.char, _, _): - // return "CChar" - // case (.float, _, _): - // return "Float" - // case (.double, _, _): - // return "Double" - // case (.size_t, _, _): - // return "Int" - // case (.va_list, _, _): - // return "CVarArg..." - // case let (_,.arrayFixedSize(count), const) where const == true: - // return "(\((0.." - // } - // } - // - // var returnSwift: String { - // switch self { - // case .void: - // return "Void" - // case .bool: - // return "Bool" - // case .int: - // return "Int32" - // case .uint: - // return "UInt32" - // case .char: - // return "CChar" - // case .float: - // return "Float" - // case .double: - // return "Double" - // case .size_t: - // return "Int" - // case .va_list: - // return "CVarArg..." - // case let .arrayFixedSize(dataType, count): - // //return "(\((0..!" - // case let .reference(dataType): - // return "UnsafeMutablePointer<\(dataType.toSwift)>!" - // case let .pointer(dataType) where dataType == .char: - // return "String" - // case let .pointer(dataType): - // return "UnsafeMutablePointer<\(dataType.toSwift)>!" - // case let .custom(string): - // return string - // case .unknown: - // return "<#TYPE#>" - // } - // } - // - // func fromSwift(name: String) -> String { - // switch self { - // case let .pointer(dataType) where dataType == .char: - // return "\(name).cStrPtr()" - // case .reference, .pointer, .arrayFixedSize: - // return "&\(name)" - // default: - // return "\(name)" - // } - // } - } extension DataType: Equatable { } @@ -307,7 +229,7 @@ extension DataType: Hashable { } // MARK: - MetaType extension DataType { - enum MetaType: Equatable, Hashable { + public enum MetaType: Equatable, Hashable { case primitive case arrayFixedSize(Int) case array @@ -321,7 +243,7 @@ extension DataType { // MARK: - Value Type extension DataType { - enum ValueType: Equatable, Hashable { + public enum ValueType: Equatable, Hashable { case void case bool case int @@ -329,14 +251,16 @@ extension DataType { case char case float case double + // swiftlint:disable:next identifier_name case size_t + // swiftlint:disable:next identifier_name case va_list case custom(String) case generic case unknown - init?(rawValue: String) { + public init?(rawValue: String) { switch rawValue { case "void": self = .void @@ -363,5 +287,18 @@ extension DataType { return nil } } + + @inlinable public var isNumber: Bool { + switch self { + case .int, + .uint, + .float, + .double: + return true + + default: + return false + } + } } } diff --git a/Sources/AutoWrapper/Definitions.swift b/Sources/AutoWrapper/Definitions.swift index c51c012..096a633 100644 --- a/Sources/AutoWrapper/Definitions.swift +++ b/Sources/AutoWrapper/Definitions.swift @@ -5,60 +5,52 @@ // Created by Christian Treffs on 25.10.19. // -typealias Definitions = [String: [Definition]] - -struct DestructorDef: Decodable { - let destructor: Bool - let args: String - let signature: String - - let cimguiname: String - - let stname: String - let argsT: [ArgsT] +public typealias Definitions = [String: [Definition]] + +public struct DestructorDef: Decodable { + public let destructor: Bool + public let args: String + public let signature: String + public let cimguiname: String + public let stname: String + public let argsT: [ArgsT] } -struct ConstructorDef: Decodable { - let constructor: Bool - let args: String - let signature: String - - let cimguiname: String - - let stname: String - let argsT: [ArgsT] +public struct ConstructorDef: Decodable { + public let constructor: Bool + public let args: String + public let signature: String + public let cimguiname: String + public let stname: String + public let argsT: [ArgsT] } -struct FunctionDef: Decodable { - let funcname: String - - let args: String - let signature: String - - let cimguiname: String - let ov_cimguiname: String - - let stname: String - let argsT: [ArgsT] - let ret: DataType? - - let templated: Bool = false - - let namespace: String? - - @inlinable var isValid: Bool { - return argsT.allSatisfy { $0.isValid } && returnType.isValid && !Exceptions.unresolvedIdentifier.contains(ov_cimguiname) +public struct FunctionDef: Decodable { + public let funcname: String + public let args: String + public let signature: String + public let cimguiname: String + // swiftlint:disable:next identifier_name + public let ov_cimguiname: String + public let stname: String + public let argsT: [ArgsT] + public let ret: DataType? + public let templated: Bool = false + public let namespace: String? + + @inlinable public var isValid: Bool { + argsT.allSatisfy { $0.isValid } && returnType.isValid && !Exceptions.unresolvedIdentifier.contains(ov_cimguiname) } - func encode(swift def: [ArgsT]) -> String { - return def.map { $0.toSwift }.joined(separator: ", ") + public func encode(swift def: [ArgsT]) -> String { + def.map { $0.toSwift }.joined(separator: ", ") } - func encode(c def: [ArgsT]) -> String { - return def.map { $0.toC }.joined(separator: ",") + public func encode(c def: [ArgsT]) -> String { + def.map { $0.toC }.joined(separator: ",") } - var encodedFuncname: String { + public var encodedFuncname: String { guard let range = ov_cimguiname.range(of: funcname) else { assertionFailure("Original name should contain funcname") return funcname @@ -84,7 +76,7 @@ struct FunctionDef: Decodable { return combinedName.replacingOccurrences(of: "_", with: "") } - var returnType: DataType { + public var returnType: DataType { guard let ret = self.ret else { return DataType(meta: .primitive, type: .void, isConst: false) } @@ -92,7 +84,7 @@ struct FunctionDef: Decodable { return ret } - func wrapCCall(_ call: @autoclosure () -> String) -> String { + public func wrapCCall(_ call: @autoclosure () -> String) -> String { switch (returnType.meta, returnType.type) { case (.pointer, .char): return "String(cString: \(call()))" @@ -101,7 +93,7 @@ struct FunctionDef: Decodable { } } - var innerReturn: String { + public var innerReturn: String { switch returnType.type { case .void where returnType.isConst == true: return "" @@ -110,7 +102,7 @@ struct FunctionDef: Decodable { } } - var funcDefs: String { + public var funcDefs: String { switch returnType.type { case .bool: return "@inlinable @discardableResult public func" @@ -119,8 +111,8 @@ struct FunctionDef: Decodable { } } - var toSwift: String { - return """ + public var toSwift: String { + """ \(funcDefs) \(encodedFuncname)(\(encode(swift: self.argsT))) -> \(returnType.toString(.ret)) { \t\(innerReturn)\(wrapCCall("\(self.ov_cimguiname)(\(encode(c: self.argsT)))")) } @@ -130,27 +122,27 @@ struct FunctionDef: Decodable { extension FunctionDef: Equatable { } extension FunctionDef: Hashable { } extension FunctionDef: Comparable { - static func < (lhs: FunctionDef, rhs: FunctionDef) -> Bool { - return lhs.encodedFuncname < rhs.encodedFuncname + public static func < (lhs: FunctionDef, rhs: FunctionDef) -> Bool { + lhs.encodedFuncname < rhs.encodedFuncname } } -struct Definition: Decodable { - enum Keys: String, CodingKey { +public struct Definition: Decodable { + public enum Keys: String, CodingKey { case funcname case destructor case constructor } - let functions: Set - let destructors: [DestructorDef] - let constructors: [ConstructorDef] + public let functions: Set + public let destructors: [DestructorDef] + public let constructors: [ConstructorDef] - var validFunctions: Set { - return functions.filter { $0.isValid } + public var validFunctions: Set { + functions.filter { $0.isValid } } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: Keys.self) var functions: Set = [] @@ -170,51 +162,3 @@ struct Definition: Decodable { self.constructors = constructors } } - -/* - struct Prototype { - let args: String - let signature: String - - let callArgs: String - let cimguiname: String - let ovCimguiname: String - let stname: String - let argsT: [ArgsT] - - let defaults: Defaults - let funcname: String? - - let ret: String? - let argsoriginal: String? - - let nonUdt: Int? - let retorig: Retorig? - let constructor: Bool? - let destructor: Bool? - let isvararg: Isvararg? - let manual: Bool? - let templated: Bool? - let retref: String? - let namespace: Namespace? - } - - enum Defaults { - case anythingArray([Any?]) - case stringMap([String: String]) - } - - enum Isvararg { - case empty - } - - enum Namespace { - case imGui - } - - enum Retorig { - case imColor - case imVec2 - case imVec4 - } - */ diff --git a/Sources/AutoWrapper/Exceptions.swift b/Sources/AutoWrapper/Exceptions.swift index 93e0979..d8a0e10 100644 --- a/Sources/AutoWrapper/Exceptions.swift +++ b/Sources/AutoWrapper/Exceptions.swift @@ -6,12 +6,12 @@ // // Conversion process is not perfect yet so we have a small list of exceptions -enum Exceptions { +public enum Exceptions { /// Set of missing functions that are not exposed to Swift automatically, /// but are present in definitions.json /// /// causes "Use of unresolved identifier '...'" compiler error. - static let unresolvedIdentifier: Set = [ + public static let unresolvedIdentifier: Set = [ "ImVector_capacity", "ImVector_clear", "ImVector_empty", @@ -25,17 +25,17 @@ enum Exceptions { ] /// causes "Use of undeclared type '...'" compiler error. - static let undeclardTypes: [String: Declaration] = [ + public static let undeclardTypes: [String: Declaration] = [ "ImGuiContext": Declaration(name: "ImGuiContext", typealiasType: "OpaquePointer"), "ImDrawListSharedData": Declaration(name: "ImDrawListSharedData", typealiasType: "OpaquePointer") ] } -struct Declaration { - let name: String - let typealiasType: String - var dataType: DataType { - return DataType(meta: .primitive, type: .custom(name), isConst: true) +public struct Declaration { + public let name: String + public let typealiasType: String + public var dataType: DataType { + DataType(meta: .primitive, type: .custom(name), isConst: true) } } diff --git a/Sources/AutoWrapper/SwiftKeywords.swift b/Sources/AutoWrapper/SwiftKeywords.swift index cffdde2..8bcb6c4 100644 --- a/Sources/AutoWrapper/SwiftKeywords.swift +++ b/Sources/AutoWrapper/SwiftKeywords.swift @@ -5,7 +5,8 @@ // Created by Christian Treffs on 25.10.19. // -enum SwiftKeyword: String { +// swiftlint:disable identifier_name +public enum SwiftKeyword: String { case `Self` case `Type` case `as` @@ -86,7 +87,7 @@ enum SwiftKeyword: String { } extension String { - var swiftEscaped: String { + public var swiftEscaped: String { guard let swiftKeyword = SwiftKeyword(rawValue: self) else { return self } diff --git a/Sources/AutoWrapper/main.swift b/Sources/AutoWrapper/main.swift index 5d3c013..0a78c02 100644 --- a/Sources/AutoWrapper/main.swift +++ b/Sources/AutoWrapper/main.swift @@ -8,18 +8,33 @@ import struct Foundation.URL import struct Foundation.Data -// Input: /3rdparty/cimgui/generator/output/definitions.json -// Output /Source/ImGui/ImGui+Definitions.swift +public struct ConversionError: Swift.Error { + public let localizedDescription: String +} -struct ConversionError: Swift.Error { - let localizedDescription: String +public func getDirectory(ofFile filePath: String = #file) -> String { + guard let lastSlashIdx = filePath.lastIndex(of: "/") else { + return filePath + } + var dirPath = filePath + dirPath.removeSubrange(lastSlashIdx../3rdparty/cimgui/generator/output/definitions.json +public let kInputFile: String +// Output /Sources/ImGui/ImGui+Definitions.swift +public let kOutputFile: String + +if CommandLine.arguments.count == 3 { + kInputFile = CommandLine.arguments[1] + kOutputFile = CommandLine.arguments[2] +} else { + kInputFile = getDirectory() + "/../../3rdparty/cimgui/generator/output/definitions.json" + kOutputFile = getDirectory() + "/../ImGui/ImGui+Definitions.swift" } -let header = """ +public let kHeader = """ // -- THIS FILE IS AUTOGENERATED - DO NOT EDIT!!! --- import CImGui @@ -34,17 +49,17 @@ import CImGui """ -let footer = """ +public let kFooter = """ """ -try convert(filePath: CommandLine.arguments[1], validOnly: true) { body in - let out: String = [header, body, footer].joined(separator: "\n\n") +try convert(filePath: kInputFile, validOnly: true) { body in + let out: String = [kHeader, body, kFooter].joined(separator: "\n\n") guard let data: Data = out.data(using: .utf8) else { throw ConversionError(localizedDescription: "Could not generate data from output string \(out)") } - let outURL = URL(fileURLWithPath: CommandLine.arguments[2]) + let outURL = URL(fileURLWithPath: kOutputFile) try data.write(to: outURL) } diff --git a/Sources/Demos/Metal/Renderer.swift b/Sources/Demos/Metal/Renderer.swift index e578c6c..984d08e 100644 --- a/Sources/Demos/Metal/Renderer.swift +++ b/Sources/Demos/Metal/Renderer.swift @@ -11,7 +11,7 @@ import MetalKit var show_demo_window: Bool = true var show_another_window: Bool = false -var clear_color: (Float, Float, Float) = (x: 0.28, y: 0.36, z: 0.5) +var clear_color: SIMD3 = .init(x: 0.28, y: 0.36, z: 0.5) var f: Float = 0.0 var counter: Int = 0 @@ -59,9 +59,9 @@ extension Renderer: MTKViewDelegate { return } - renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: Double(clear_color.0), - green: Double(clear_color.1), - blue: Double(clear_color.2), + renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColor(red: Double(clear_color.x), + green: Double(clear_color.x), + blue: Double(clear_color.z), alpha: 1.0) // Here, you could do additional rendering work, including other passes as necessary. diff --git a/Sources/ImGui/Helper.swift b/Sources/ImGui/Helper.swift index b8e4edb..4b33ce8 100644 --- a/Sources/ImGui/Helper.swift +++ b/Sources/ImGui/Helper.swift @@ -25,13 +25,13 @@ extension String { } public mutating func cMutableStrPtr() -> UnsafeMutablePointer! { - return UnsafeMutablePointer(mutating: self.cStrPtr()) + UnsafeMutablePointer(mutating: self.cStrPtr()) } } extension Array { public subscript(representable: R) -> Element where R: RawRepresentable, R.RawValue: FixedWidthInteger { - get { return self[Int(representable.rawValue)] } + get { self[Int(representable.rawValue)] } set { self[Int(representable.rawValue)] = newValue } } } @@ -45,12 +45,12 @@ public struct CArray { } public var count: Int { - return ptr.count + ptr.count } public subscript(index: I) -> T where I: FixedWidthInteger { get { - return ptr[Int(index)] + ptr[Int(index)] } set { ptr[Int(index)] = newValue @@ -59,7 +59,7 @@ public struct CArray { public subscript(representable: R) -> T where R: RawRepresentable, R.RawValue: FixedWidthInteger { get { - return self[representable.rawValue] + self[representable.rawValue] } set { self[representable.rawValue] = newValue @@ -67,6 +67,7 @@ public struct CArray { } } +// swiftlint:disable large_tuple extension CArray { public init(_ cArray: inout (T, T)) { self.init(&cArray.0, MemoryLayout.size(ofValue: cArray)) @@ -100,6 +101,7 @@ extension CArray { self.init(&cArray.0, MemoryLayout.size(ofValue: cArray)) } + // swiftlint:disable:next line_length public init(_ cArray: inout (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T)) { self.init(&cArray.0, MemoryLayout.size(ofValue: cArray)) } @@ -107,15 +109,15 @@ extension CArray { /// Offset of _MEMBER within _TYPE. Standardized as offsetof() in modern C++. public func IM_OFFSETOF(_ member: PartialKeyPath) -> Int { - return MemoryLayout.offset(of: member)! + MemoryLayout.offset(of: member)! } /// Size of a static C-style array. Don't use on pointers! public func IM_ARRAYSIZE(_ cTupleArray: T) -> Int { //#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR))) - let m = Mirror(reflecting: cTupleArray) - precondition(m.displayStyle == Mirror.DisplayStyle.tuple, "IM_ARRAYSIZE may only be applied to C array tuples") - return m.children.count + let mirror = Mirror(reflecting: cTupleArray) + precondition(mirror.displayStyle == Mirror.DisplayStyle.tuple, "IM_ARRAYSIZE may only be applied to C array tuples") + return mirror.children.count } /// Debug Check Version diff --git a/Sources/ImGui/ImGui+Definitions.swift b/Sources/ImGui/ImGui+Definitions.swift index 1dcad59..f088df4 100644 --- a/Sources/ImGui/ImGui+Definitions.swift +++ b/Sources/ImGui/ImGui+Definitions.swift @@ -645,20 +645,20 @@ public typealias ImGuiContext = OpaquePointer return igColorConvertU32ToFloat4_nonUDT2(`in`) } -@inlinable @discardableResult public func ImGuiColorEdit3(_ label: String?, _ col: inout (Float,Float,Float), _ flags: ImGuiColorEditFlags) -> Bool { - return igColorEdit3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &col.0, count: 3).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiColorEdit3(_ label: String?, _ col: inout SIMD3, _ flags: ImGuiColorEditFlags) -> Bool { + return igColorEdit3(label?.cStrPtr(),withUnsafeMutablePointer(to: &col) { $0.withMemoryRebound(to: Float.self, capacity: 3) { $0 } },flags) } -@inlinable @discardableResult public func ImGuiColorEdit4(_ label: String?, _ col: inout (Float,Float,Float,Float), _ flags: ImGuiColorEditFlags) -> Bool { - return igColorEdit4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &col.0, count: 4).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiColorEdit4(_ label: String?, _ col: inout SIMD4, _ flags: ImGuiColorEditFlags) -> Bool { + return igColorEdit4(label?.cStrPtr(),withUnsafeMutablePointer(to: &col) { $0.withMemoryRebound(to: Float.self, capacity: 4) { $0 } },flags) } -@inlinable @discardableResult public func ImGuiColorPicker3(_ label: String?, _ col: inout (Float,Float,Float), _ flags: ImGuiColorEditFlags) -> Bool { - return igColorPicker3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &col.0, count: 3).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiColorPicker3(_ label: String?, _ col: inout SIMD3, _ flags: ImGuiColorEditFlags) -> Bool { + return igColorPicker3(label?.cStrPtr(),withUnsafeMutablePointer(to: &col) { $0.withMemoryRebound(to: Float.self, capacity: 3) { $0 } },flags) } -@inlinable @discardableResult public func ImGuiColorPicker4(_ label: String?, _ col: inout (Float,Float,Float,Float), _ flags: ImGuiColorEditFlags, _ ref_col: UnsafePointer!) -> Bool { - return igColorPicker4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &col.0, count: 4).baseAddress!,flags,ref_col) +@inlinable @discardableResult public func ImGuiColorPicker4(_ label: String?, _ col: inout SIMD4, _ flags: ImGuiColorEditFlags, _ ref_col: UnsafePointer!) -> Bool { + return igColorPicker4(label?.cStrPtr(),withUnsafeMutablePointer(to: &col) { $0.withMemoryRebound(to: Float.self, capacity: 4) { $0 } },flags,ref_col) } @inlinable public func ImGuiColumns(_ count: Int32, _ id: String?, _ border: Bool) -> Void { @@ -701,16 +701,16 @@ public typealias ImGuiContext = OpaquePointer return igDragFloat(label?.cStrPtr(),v,v_speed,v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiDragFloat2(_ label: String?, _ v: inout (Float,Float), _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igDragFloat2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiDragFloat2(_ label: String?, _ v: inout SIMD2, _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igDragFloat2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 2) { $0 } },v_speed,v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiDragFloat3(_ label: String?, _ v: inout (Float,Float,Float), _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igDragFloat3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiDragFloat3(_ label: String?, _ v: inout SIMD3, _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igDragFloat3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 3) { $0 } },v_speed,v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiDragFloat4(_ label: String?, _ v: inout (Float,Float,Float,Float), _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igDragFloat4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiDragFloat4(_ label: String?, _ v: inout SIMD4, _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igDragFloat4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 4) { $0 } },v_speed,v_min,v_max,format?.cStrPtr(),power) } @inlinable @discardableResult public func ImGuiDragFloatRange2(_ label: String?, _ v_current_min: UnsafeMutablePointer!, _ v_current_max: UnsafeMutablePointer!, _ v_speed: Float, _ v_min: Float, _ v_max: Float, _ format: String?, _ format_max: String?, _ power: Float) -> Bool { @@ -721,16 +721,16 @@ public typealias ImGuiContext = OpaquePointer return igDragInt(label?.cStrPtr(),v,v_speed,v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiDragInt2(_ label: String?, _ v: inout (Int32,Int32), _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igDragInt2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiDragInt2(_ label: String?, _ v: inout SIMD2, _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igDragInt2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 2) { $0 } },v_speed,v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiDragInt3(_ label: String?, _ v: inout (Int32,Int32,Int32), _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igDragInt3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiDragInt3(_ label: String?, _ v: inout SIMD3, _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igDragInt3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 3) { $0 } },v_speed,v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiDragInt4(_ label: String?, _ v: inout (Int32,Int32,Int32,Int32), _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igDragInt4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,v_speed,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiDragInt4(_ label: String?, _ v: inout SIMD4, _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igDragInt4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 4) { $0 } },v_speed,v_min,v_max,format?.cStrPtr()) } @inlinable @discardableResult public func ImGuiDragIntRange2(_ label: String?, _ v_current_min: UnsafeMutablePointer!, _ v_current_max: UnsafeMutablePointer!, _ v_speed: Float, _ v_min: Int32, _ v_max: Int32, _ format: String?, _ format_max: String?) -> Bool { @@ -1249,32 +1249,32 @@ public typealias ImGuiContext = OpaquePointer return igInputFloat(label?.cStrPtr(),v,step,step_fast,format?.cStrPtr(),flags) } -@inlinable @discardableResult public func ImGuiInputFloat2(_ label: String?, _ v: inout (Float,Float), _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { - return igInputFloat2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,format?.cStrPtr(),flags) +@inlinable @discardableResult public func ImGuiInputFloat2(_ label: String?, _ v: inout SIMD2, _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputFloat2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 2) { $0 } },format?.cStrPtr(),flags) } -@inlinable @discardableResult public func ImGuiInputFloat3(_ label: String?, _ v: inout (Float,Float,Float), _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { - return igInputFloat3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,format?.cStrPtr(),flags) +@inlinable @discardableResult public func ImGuiInputFloat3(_ label: String?, _ v: inout SIMD3, _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputFloat3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 3) { $0 } },format?.cStrPtr(),flags) } -@inlinable @discardableResult public func ImGuiInputFloat4(_ label: String?, _ v: inout (Float,Float,Float,Float), _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { - return igInputFloat4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,format?.cStrPtr(),flags) +@inlinable @discardableResult public func ImGuiInputFloat4(_ label: String?, _ v: inout SIMD4, _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputFloat4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 4) { $0 } },format?.cStrPtr(),flags) } @inlinable @discardableResult public func ImGuiInputInt(_ label: String?, _ v: UnsafeMutablePointer!, _ step: Int32, _ step_fast: Int32, _ flags: ImGuiInputTextFlags) -> Bool { return igInputInt(label?.cStrPtr(),v,step,step_fast,flags) } -@inlinable @discardableResult public func ImGuiInputInt2(_ label: String?, _ v: inout (Int32,Int32), _ flags: ImGuiInputTextFlags) -> Bool { - return igInputInt2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiInputInt2(_ label: String?, _ v: inout SIMD2, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputInt2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 2) { $0 } },flags) } -@inlinable @discardableResult public func ImGuiInputInt3(_ label: String?, _ v: inout (Int32,Int32,Int32), _ flags: ImGuiInputTextFlags) -> Bool { - return igInputInt3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiInputInt3(_ label: String?, _ v: inout SIMD3, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputInt3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 3) { $0 } },flags) } -@inlinable @discardableResult public func ImGuiInputInt4(_ label: String?, _ v: inout (Int32,Int32,Int32,Int32), _ flags: ImGuiInputTextFlags) -> Bool { - return igInputInt4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,flags) +@inlinable @discardableResult public func ImGuiInputInt4(_ label: String?, _ v: inout SIMD4, _ flags: ImGuiInputTextFlags) -> Bool { + return igInputInt4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 4) { $0 } },flags) } @inlinable @discardableResult public func ImGuiInputScalar(_ label: String?, _ data_type: ImGuiDataType, _ p_data: UnsafeMutableRawPointer!, _ p_step: UnsafeRawPointer!, _ p_step_fast: UnsafeRawPointer!, _ format: String?, _ flags: ImGuiInputTextFlags) -> Bool { @@ -1909,32 +1909,32 @@ public typealias ImGuiContext = OpaquePointer return igSliderFloat(label?.cStrPtr(),v,v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiSliderFloat2(_ label: String?, _ v: inout (Float,Float), _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igSliderFloat2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiSliderFloat2(_ label: String?, _ v: inout SIMD2, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igSliderFloat2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 2) { $0 } },v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiSliderFloat3(_ label: String?, _ v: inout (Float,Float,Float), _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igSliderFloat3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiSliderFloat3(_ label: String?, _ v: inout SIMD3, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igSliderFloat3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 3) { $0 } },v_min,v_max,format?.cStrPtr(),power) } -@inlinable @discardableResult public func ImGuiSliderFloat4(_ label: String?, _ v: inout (Float,Float,Float,Float), _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { - return igSliderFloat4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,v_min,v_max,format?.cStrPtr(),power) +@inlinable @discardableResult public func ImGuiSliderFloat4(_ label: String?, _ v: inout SIMD4, _ v_min: Float, _ v_max: Float, _ format: String?, _ power: Float) -> Bool { + return igSliderFloat4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Float.self, capacity: 4) { $0 } },v_min,v_max,format?.cStrPtr(),power) } @inlinable @discardableResult public func ImGuiSliderInt(_ label: String?, _ v: UnsafeMutablePointer!, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { return igSliderInt(label?.cStrPtr(),v,v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiSliderInt2(_ label: String?, _ v: inout (Int32,Int32), _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igSliderInt2(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 2).baseAddress!,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiSliderInt2(_ label: String?, _ v: inout SIMD2, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igSliderInt2(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 2) { $0 } },v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiSliderInt3(_ label: String?, _ v: inout (Int32,Int32,Int32), _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igSliderInt3(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 3).baseAddress!,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiSliderInt3(_ label: String?, _ v: inout SIMD3, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igSliderInt3(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 3) { $0 } },v_min,v_max,format?.cStrPtr()) } -@inlinable @discardableResult public func ImGuiSliderInt4(_ label: String?, _ v: inout (Int32,Int32,Int32,Int32), _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { - return igSliderInt4(label?.cStrPtr(),UnsafeMutableBufferPointer(start: &v.0, count: 4).baseAddress!,v_min,v_max,format?.cStrPtr()) +@inlinable @discardableResult public func ImGuiSliderInt4(_ label: String?, _ v: inout SIMD4, _ v_min: Int32, _ v_max: Int32, _ format: String?) -> Bool { + return igSliderInt4(label?.cStrPtr(),withUnsafeMutablePointer(to: &v) { $0.withMemoryRebound(to: Int32.self, capacity: 4) { $0 } },v_min,v_max,format?.cStrPtr()) } @inlinable @discardableResult public func ImGuiSliderScalar(_ label: String?, _ data_type: ImGuiDataType, _ p_data: UnsafeMutableRawPointer!, _ p_min: UnsafeRawPointer!, _ p_max: UnsafeRawPointer!, _ format: String?, _ power: Float) -> Bool { diff --git a/Sources/ImGui/ImVec+Extensions.swift b/Sources/ImGui/ImVec+Extensions.swift index e5da91f..b9ef974 100644 --- a/Sources/ImGui/ImVec+Extensions.swift +++ b/Sources/ImGui/ImVec+Extensions.swift @@ -9,14 +9,14 @@ import CImGui extension ImVec2: Equatable { public static func == (lhs: ImVec2, rhs: ImVec2) -> Bool { - return lhs.x == rhs.x && + lhs.x == rhs.x && lhs.y == rhs.y } } extension ImVec4: Equatable { public static func == (lhs: ImVec4, rhs: ImVec4) -> Bool { - return lhs.x == rhs.x && + lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z && lhs.w == rhs.w diff --git a/SwiftImGui.podspec b/SwiftImGui.podspec new file mode 100644 index 0000000..38c371d --- /dev/null +++ b/SwiftImGui.podspec @@ -0,0 +1,135 @@ +# +# Be sure to run `pod spec lint SwiftImGui.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |spec| + + # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # These will help people to find your library, and whilst it + # can feel like a chore to fill in it's definitely to your advantage. The + # summary should be tweet-length, and the description more in depth. + # + + spec.name = "SwiftImGui" + spec.version = "1.0.1" + spec.summary = "A short description of SwiftImGui." + + # This description is used to generate tags and improve search results. + # * Think: What does it do? Why did you write it? What is the focus? + # * Try to keep it short, snappy and to the point. + # * Write the description between the DESC delimiters below. + # * Finally, don't worry about the indent, CocoaPods strips it! + spec.description = <<-DESC + DESC + + spec.homepage = "http://EXAMPLE/SwiftImGui" + # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Licensing your code is important. See https://choosealicense.com for more info. + # CocoaPods will detect a license file if there is a named LICENSE* + # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. + # + + spec.license = "MIT (example)" + # spec.license = { :type => "MIT", :file => "FILE_LICENSE" } + + + # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the authors of the library, with email addresses. Email addresses + # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also + # accepts just a name if you'd rather not provide an email address. + # + # Specify a social_media_url where others can refer to, for example a twitter + # profile URL. + # + + spec.author = { "Christian Treffs" => "" } + # spec.social_media_url = "https://twitter.com/Juan Romero" + + # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If this Pod runs only on iOS or OS X, then specify the platform and + # the deployment target. You can optionally include the target after the platform. + # + + # spec.platform = :ios + # spec.platform = :ios, "5.0" + + # When using multiple platforms + # spec.ios.deployment_target = "5.0" + # spec.osx.deployment_target = "10.7" + # spec.watchos.deployment_target = "2.0" + # spec.tvos.deployment_target = "9.0" + + + # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the location from where the source should be retrieved. + # Supports git, hg, bzr, svn and HTTP. + # + + spec.source = { :git => "http://EXAMPLE/SwiftImGui.git", :tag => "#{spec.version}" } + + + # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # CocoaPods is smart about how it includes source code. For source files + # giving a folder will include any swift, h, m, mm, c & cpp files. + # For header files it will include any header in the folder. + # Not including the public_header_files will make all headers public. + # + + spec.source_files = "Classes", "Classes/**/*.{h,m}" + spec.exclude_files = "Classes/Exclude" + + # spec.public_header_files = "Classes/**/*.h" + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # A list of resources included with the Pod. These are copied into the + # target bundle with a build phase script. Anything else will be cleaned. + # You can preserve files from being cleaned, please don't preserve + # non-essential files like tests, examples and documentation. + # + + # spec.resource = "icon.png" + # spec.resources = "Resources/*.png" + + # spec.preserve_paths = "FilesToSave", "MoreFilesToSave" + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Link your library with frameworks, or libraries. Libraries do not include + # the lib prefix of their name. + # + + # spec.framework = "SomeFramework" + # spec.frameworks = "SomeFramework", "AnotherFramework" + + # spec.library = "iconv" + # spec.libraries = "iconv", "xml2" + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If your library depends on compiler flags you can set them in the xcconfig hash + # where they will only apply to your library. If you depend on other Podspecs + # you can include multiple dependencies to ensure it works. + + # spec.requires_arc = true + + # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } + # spec.dependency "JSONKit", "~> 1.4" + +end diff --git a/Tests/ImGuiTests/ImGuiTests.swift b/Tests/ImGuiTests/ImGuiTests.swift index 695279e..bbcd6cf 100644 --- a/Tests/ImGuiTests/ImGuiTests.swift +++ b/Tests/ImGuiTests/ImGuiTests.swift @@ -1,7 +1,7 @@ -import XCTest import ImGui +import XCTest -final class ImGuiTests: XCTestCase { +public final class ImGuiTests: XCTestCase { func testVersion() { XCTAssertNotNil(ImGuiGetVersion()) XCTAssertEqual(ImGuiGetVersion(), "1.74 WIP") diff --git a/Tests/ImGuiTests/XCTestManifests.swift b/Tests/ImGuiTests/XCTestManifests.swift index 34aa7ad..f29fc38 100644 --- a/Tests/ImGuiTests/XCTestManifests.swift +++ b/Tests/ImGuiTests/XCTestManifests.swift @@ -8,13 +8,13 @@ extension ImGuiTests { static let __allTests__ImGuiTests = [ ("testCreateContext", testCreateContext), ("testGetIO", testGetIO), - ("testVersion", testVersion), + ("testVersion", testVersion) ] } public func __allTests() -> [XCTestCaseEntry] { return [ - testCase(ImGuiTests.__allTests__ImGuiTests), + testCase(ImGuiTests.__allTests__ImGuiTests) ] } #endif