Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreffs committed Jan 13, 2020
2 parents bb91b64 + e91f753 commit ec69bec
Show file tree
Hide file tree
Showing 18 changed files with 382 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.1
5.1.3
16 changes: 13 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -60,3 +64,6 @@ genXcodeOpen: genXcode
open *.xcodeproj

precommit: lint genLinuxTests

testReadme:
markdown-link-check -p -v ./README.md
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.1
import PackageDescription

var package = Package(
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down
51 changes: 28 additions & 23 deletions Sources/AutoWrapper/ArgT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -47,32 +45,32 @@ 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)
self.ret = try container.decodeIfPresent(String.self, forKey: .ret)
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"
Expand All @@ -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))"
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
Loading

0 comments on commit ec69bec

Please sign in to comment.