Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 85 additions & 0 deletions .cosy/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
version: "1.0"

env:
Workspace: "./.CosyCache/Workspace"

targets:
clone-repos:
steps:
- name: Make temp dir
uses: core:mkdir@v1
with:
path: ${{ env.Workspace }}

- name: Clone cimgui
uses: core:checkout@v1
with:
repo: https://github.com/JunaMeinhold/cimgui.git
submodules: true
path: ${{ env.Workspace }}/cimgui

- name: Clone cimplot
uses: core:checkout@v1
with:
repo: https://github.com/JunaMeinhold/cimplot.git
submodules: true
path: ${{ env.Workspace }}/cimplot

- name: Clone cimnodes
uses: core:checkout@v1
with:
repo: https://github.com/JunaMeinhold/cimnodes.git
submodules: true
path: ${{ env.Workspace }}/cimnodes

- name: Clone cimguizmo
uses: core:checkout@v1
with:
repo: https://github.com/JunaMeinhold/cimguizmo.git
submodules: true
path: ${{ env.Workspace }}/cimguizmo

run-generators:
needs: [clone-repos]
steps:
- name: Generate cimgui
shell: bash
run: |
cd ${{ env.Workspace }}/cimgui/generator
luajit ./generator.lua gcc "comments internal noimstrv" glfw opengl3 opengl2 sdl2 sdl3 vulkan
- name: Generate cimplot
shell: bash
run: |
cd ${{ env.Workspace }}/cimplot/generator
luajit ./generator.lua gcc "internal"
- name: Generate cimnodes
run: |
cd ${{ env.Workspace }}/cimnodes/generator
luajit ./generator.lua gcc
- name: Generate cimguizmo
run: |
cd ${{ env.Workspace }}/cimguizmo/generator
luajit ./generator.lua gcc "comments"

copy-files:
needs: [run-generators]
steps:
- name: Copy Headers and JSONs
shell: bash
run: |
cp ${{ env.Workspace }}/cimgui/cimgui.h Generator/cimgui
cp ${{ env.Workspace }}/cimplot/cimplot.h Generator/cimplot
cp ${{ env.Workspace }}/cimnodes/cimnodes.h Generator/cimnodes
cp ${{ env.Workspace }}/cimguizmo/cimguizmo.h Generator/cimguizmo

cp ${{ env.Workspace }}/cimgui/cimgui.h Generator/cimplot
cp ${{ env.Workspace }}/cimgui/cimgui.h Generator/cimnodes
cp ${{ env.Workspace }}/cimgui/cimgui.h Generator/cimguizmo
cp ${{ env.Workspace }}/cimgui/cimgui.h Generator/backends

cp ${{ env.Workspace }}/cimgui/generator/output/*.json Generator/cimgui
cp ${{ env.Workspace }}/cimplot/generator/output/*.json Generator/cimplot
cp ${{ env.Workspace }}/cimnodes/generator/output/*.json Generator/cimnodes
cp ${{ env.Workspace }}/cimguizmo/generator/output/*.json Generator/cimguizmo


5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,7 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

token.txt
token.txt

# Cosy CI/CD workflows tool
.CosyCache/
8 changes: 8 additions & 0 deletions .idea/.idea.Hexa.NET.ImGui/.idea/projectSettingsUpdater.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

303 changes: 303 additions & 0 deletions .idea/.idea.Hexa.NET.ImGui/.idea/workspace.xml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Examples/ExampleAndroid/ExampleAndroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-android</TargetFramework>
<TargetFramework>net9.0-android</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.4" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.15.0.1" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.1.1" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.17.0" />
<PackageReference Include="Hexa.NET.ImGui.Widgets" Version="1.1.18" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions Generator/Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HexaGen.Legacy" Version="1.0.7" />
<PackageReference Include="HexaGen" Version="1.1.23.5" />
<PackageReference Include="HexaGen.BuildSystems" Version="0.0.1-alpha" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 5 additions & 8 deletions Generator/ImGuiCodeGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Batteries.Legacy.Steps;
using HexaGen.Core.CSharp;
using HexaGen.CppAst.Model.Metadata;
using HexaGen.FunctionGeneration;
using HexaGen.FunctionGeneration.ParameterWriters;
using HexaGen.GenerationSteps;
using System.Collections.Generic;

public class ImGuiCodeGenerator : CsCodeGenerator
Expand All @@ -23,13 +23,9 @@ protected override void OnConfigureGenerator()
protected override void OnPostConfigure(CsCodeGeneratorConfig config)
{
config.LogLevel = HexaGen.Core.Logging.LogSeverity.Error;
config.Defines.Add("IMGUI_USE_WCHAR32");
config.Defines.Add("IMGUI_ENABLE_FREETYPE");
config.Defines.Add("CIMGUI_DEFINE_ENUMS_AND_STRUCTS");
LogLevel = HexaGen.Core.Logging.LogSeverity.Error;

Environment.SetEnvironmentVariable("VCINSTALLDIR", @"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532");
Environment.SetEnvironmentVariable("VCToolsInstallDir", @"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\");
//Environment.SetEnvironmentVariable("VCINSTALLDIR", @"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532");
//Environment.SetEnvironmentVariable("VCToolsInstallDir", @"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\");
}

public override bool GenerateCore(CppCompilation compilation, List<string> headerFiles, string outputPath, List<string>? allowedHeaders = null)
Expand All @@ -45,6 +41,7 @@ public ImGuiFunctionGenerator(CsCodeGeneratorConfig config) : base(config)
AddRule(new FunctionGenRuleRef());
AddRule(new FunctionGenRuleSpan());
AddRule(new FunctionGenRuleString());
AddRule(new FunctionGenRuleArray(config));
AddStep(new ImGuiDefaultValueStep());
AddStep(new ImGuiReturnVariationStep());
AddStep(new StringReturnGenStep());
Expand Down
7 changes: 5 additions & 2 deletions Generator/ImGuiDefinitionsPatch.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Core.Mapping;
using HexaGen.CppAst.Model.Metadata;
using HexaGen.Patching;
using Microsoft.CodeAnalysis;

public enum InternalsGenerationType
{
Expand All @@ -23,12 +24,14 @@ public ImGuiDefinitionsPatch(InternalsGenerationType generationType)
this.generationType = generationType;
}

protected override void PatchCompilation(CsCodeGeneratorConfig settings, CppCompilation compilation)
protected override void PatchCompilation(CsCodeGeneratorConfig settings, ParseResult result)
{
if (settings.LibName == "cimgui_impl")
{
return;
}
var compilation = result.Compilation;

ImguiDefinitions imguiDefinitions = new();
imguiDefinitions.LoadFrom(settings.LibName);

Expand Down
2 changes: 1 addition & 1 deletion Generator/ImGuiPostPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override void Apply(PatchContext context, CsCodeGeneratorMetadata metadat
}

Generate(metadata, CImGuiHeader, CImGuiInternalsConfig, ImGuiInternalsOutputPath, InternalsGenerationType.OnlyInternals, out var internalsMetadata);
metadata.Merge(internalsMetadata, true);
metadata.Merge(internalsMetadata, new HexaGen.Metadata.MergeOptions() { MergeFunctionTable = true });
File.Delete(Path.Combine(ImGuiOutputPath, "FunctionTable.cs")); // Delete base.
File.Delete(Path.Combine(ImGuiInternalsOutputPath, "FunctionTable.cs")); // Delete intermediate.

Expand Down
3 changes: 1 addition & 2 deletions Generator/ImGuiPrePatch.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Patching;
using System.Collections.Generic;

public class ImGuiPrePatch : PrePatch
{
public override void Apply(PatchContext context, CsCodeGeneratorConfig config, List<string> files, CppCompilation compilation)
public override void Apply(PatchContext context, CsCodeGeneratorConfig config, List<string> files, ParseResult result)
{
if (config.LibName != "cimgui")
{
Expand Down
3 changes: 1 addition & 2 deletions Generator/ImGuizmoPrePatch.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Core.Mapping;
using HexaGen.Patching;

public class ImGuizmoPrePatch : PrePatch
{
protected override void PatchCompilation(CsCodeGeneratorConfig settings, CppCompilation compilation)
protected override void PatchCompilation(CsCodeGeneratorConfig settings, ParseResult parseResult)
{
if (settings.LibName != "cimguizmo")
{
Expand Down
6 changes: 3 additions & 3 deletions Generator/ImVectorPatch.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.CppAst.Model.Declarations;
using HexaGen.Patching;
using System.Collections.Generic;

public class ImVectorPatch : PrePatch
{
public override void Apply(PatchContext context, CsCodeGeneratorConfig settings, List<string> files, CppCompilation compilation)
public override void Apply(PatchContext context, CsCodeGeneratorConfig settings, List<string> files, ParseResult result)
{
base.Apply(context, settings, files, compilation);
base.Apply(context, settings, files, result);
}

protected override void PatchClass(CsCodeGeneratorConfig settings, CppClass cppClass)
Expand Down
14 changes: 8 additions & 6 deletions Generator/ManualFunctionGenRuleSpan.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
namespace Generator
{
using CppAst;
using HexaGen;
using HexaGen.Core.CSharp;
using HexaGen.Core.Mapping;
using HexaGen.CppAst.Model.Declarations;
using HexaGen.CppAst.Model.Types;
using HexaGen.FunctionGeneration;

public class ManualFunctionGenRuleSpan : FunctionGenRule
{
public override CsParameterInfo CreateParameter(CppParameter cppParameter, string csParamName, CppPrimitiveKind kind, Direction direction, CsCodeGeneratorConfig settings, IList<CppParameter> cppParameters, CsParameterInfo[] csParameterList, int paramIndex, CsFunctionVariation variation)
public override CsParameterInfo CreateParameter(CppParameter cppParameter, ParameterMapping? mapping, string csParamName, CppPrimitiveKind kind, Direction direction, CsCodeGeneratorConfig settings, IList<CppParameter> cppParameters, CsParameterInfo[] csParameters, int paramIndex, CsFunctionVariation variation)
{
if (cppParameter.Type is CppArrayType arrayType)
{
if (arrayType.Size > 0)
{
return new(csParamName, cppParameter.Type, new($"ReadOnlySpan<{settings.GetCsTypeName(arrayType.ElementType, false)}>", kind), direction);
return new(csParamName, cppParameter.Type, new($"ReadOnlySpan<{settings.GetCsTypeName(arrayType.ElementType)}>", kind), direction);
}
}
else if (cppParameter.Type.IsString())
else if (cppParameter.Type.IsString(settings, out var stringKind))
{
switch (kind)
switch (stringKind)
{
case CppPrimitiveKind.Char:
if (direction == Direction.InOut || direction == Direction.Out) break;
Expand All @@ -30,7 +32,7 @@ public override CsParameterInfo CreateParameter(CppParameter cppParameter, strin
}
}

return CreateDefaultWrapperParameter(cppParameter, csParamName, kind, direction, settings);
return CreateDefaultWrapperParameter(cppParameter, mapping, csParamName, kind, direction, settings);
}
}
}
5 changes: 5 additions & 0 deletions Generator/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Generator.Targets;
using HexaGen.BuildSystems;

var start = DateTime.Now;
var builder =
BuildSystemBuilder.Create()
.WithArgs(args)
Expand All @@ -14,6 +15,10 @@

var context = builder.Build();
context.Execute();
var end = DateTime.Now;
var duration = end - start;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"Generation completed in {duration.TotalSeconds:F2} seconds.");

Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("All done! Have fun!");
Expand Down
2 changes: 1 addition & 1 deletion Generator/Targets/ImGuiBackendsTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private static void GenerateBackend(string[] headers, string configPath, string
.GetMetadata(out metadata)
.GetConfig(out var config);

lib?.Merge(metadata, true);
lib?.Merge(metadata, new() { MergeFunctionTable = true });

string destPath = Path.Combine(originalOutput, "FunctionTable.cs");
File.Move(Path.Combine(output, "FunctionTable.cs"), destPath, true);
Expand Down
1 change: 0 additions & 1 deletion Generator/Targets/ImGuiBaseTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ protected void Generate(IEnumerable<string> headers, string settingsPath, string

protected virtual void OnSetup(GeneratorBuilder builder)
{

}
}
}
Loading