Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreffs committed Jan 13, 2020
2 parents e953ab1 + 2c7985a commit 91cec05
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 99 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ copyLibImGui:
cp $(imgui_src)/generator/output/cimgui.cpp $(c_imgui_src)

generateCInterface:
cd $(imgui_src)/generator && luajit ./generator.lua gcc glfw opengl3 opengl2 sdl
cd $(imgui_src)/generator && luajit ./generator.lua clang sdl glfw glut metal

buildCImGui: updateCLibImGui generateCInterface copyLibImGui

Expand All @@ -47,6 +47,7 @@ runCI:

wrapLibImGui: buildAutoWrapper
$(release_dir)/AutoWrapper $(imgui_src)/generator/output/definitions.json $(swift_imgui_src)/ImGui+Definitions.swift
#$(release_dir)/AutoWrapper $(imgui_src)/generator/output/impl_definitions.json $(swift_imgui_src)/ImGui+ImplDefinitions.swift

clean:
swift package reset
Expand Down
2 changes: 1 addition & 1 deletion 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.1.0")
.package(url: "https://github.com/ctreffs/SwiftImGui.git", from: "1.1.1")
],
targets: [
.target(
Expand Down
18 changes: 15 additions & 3 deletions Sources/AutoWrapper/Definitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,23 @@ public struct Definition: Decodable {
var constructors: [ConstructorDef] = []

if container.contains(.funcname) && !container.contains(.destructor) && !container.contains(.constructor) {
functions.insert(try FunctionDef(from: decoder))
do {
functions.insert(try FunctionDef(from: decoder))
} catch {
print("DECODING ERROR FunctionDef", decoder.codingPath, error.localizedDescription)
}
} else if container.contains(.destructor) {
destructors.append(try DestructorDef(from: decoder))
do {
destructors.append(try DestructorDef(from: decoder))
} catch {
print("DECODING ERROR DestructorDef", decoder.codingPath, error.localizedDescription)
}
} else if container.contains(.constructor) {
constructors.append(try ConstructorDef(from: decoder))
do {
constructors.append(try ConstructorDef(from: decoder))
} catch {
print("DECODING ERROR ConstructorDef", decoder.codingPath, error.localizedDescription)
}
}

self.functions = functions
Expand Down
30 changes: 17 additions & 13 deletions Sources/AutoWrapper/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ public func getDirectory(ofFile filePath: String = #file) -> String {
}

// Input: <SRC_ROOT>/3rdparty/cimgui/generator/output/definitions.json
public let kInputFile: String
public let kInputFiles: [String]
// Output <SRC_ROOT>/Sources/ImGui/ImGui+Definitions.swift
public let kOutputFile: String
public let kOutputFiles: [String]

if CommandLine.arguments.count == 3 {
kInputFile = CommandLine.arguments[1]
kOutputFile = CommandLine.arguments[2]
kInputFiles = [CommandLine.arguments[1]]
kOutputFiles = [CommandLine.arguments[2]]
} else {
kInputFile = getDirectory() + "/../../3rdparty/cimgui/generator/output/definitions.json"
kOutputFile = getDirectory() + "/../ImGui/ImGui+Definitions.swift"
let src = getDirectory() + "/../../3rdparty/cimgui/generator/output/"
let dest = getDirectory() + "/../ImGui/"
kInputFiles = ["definitions.json"].map { "\(src)\($0)" }
kOutputFiles = ["ImGui+Definitions.swift"].map { "\(dest)\($0)" }
}

public let kHeader = """
Expand All @@ -52,14 +54,16 @@ import CImGui
public let kFooter = """
"""

try convert(filePath: kInputFile, validOnly: true) { body in
let out: String = [kHeader, body, kFooter].joined(separator: "\n\n")
for (inputFile, outputFile) in zip(kInputFiles, kOutputFiles) {
try convert(filePath: inputFile, 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)")
}
guard let data: Data = out.data(using: .utf8) else {
throw ConversionError(localizedDescription: "Could not generate data from output string \(out)")
}

let outURL = URL(fileURLWithPath: kOutputFile)
let outURL = URL(fileURLWithPath: outputFile)

try data.write(to: outURL)
try data.write(to: outURL)
}
}
3 changes: 2 additions & 1 deletion Sources/CImGui/cimgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
//based on imgui.h file version "1.74 WIP" from Dear ImGui https://github.com/ocornut/imgui

#include "./imgui/imgui.h"
#include "./imgui/imgui_internal.h"
#include "cimgui.h"

#include "./imgui/imgui_internal.h"


CIMGUI_API ImVec2* ImVec2_ImVec2(void)
{
Expand Down
Loading

0 comments on commit 91cec05

Please sign in to comment.