Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for handling internals #364

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Revert some of my changes now that I understand a bit more.
  • Loading branch information
Thraka committed Mar 22, 2024
commit 5c45b25c77e7558492547bbcbc4fc3ad068448d9
13 changes: 0 additions & 13 deletions src/CodeGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ static async Task<int> Main(string[] args)
foreach (TypeDefinition td in defs.Types)
{
if (TypeInfo.CustomDefinedTypes.Contains(td.Name)) { continue; }
if (TypeInfo.ScratchedTypes.Contains(td.Name)) { continue; }

using (CSharpCodeWriter writer = new CSharpCodeWriter(Path.Combine(GetOutputPath(td.IsInternal), td.Name + ".gen.cs")))
{
Expand All @@ -180,9 +179,6 @@ static async Task<int> Main(string[] args)
{
string typeStr = GetTypeString(field.Type, field.IsFunctionPointer);

if (TypeInfo.SkippedMembers.Contains($"{td.Name}.{field.Name}")) { continue; }
if (TypeInfo.ScratchedTypes.Contains(field.Type)) { continue; }

if (field.ArraySize != 0)
{
if (TypeInfo.LegalFixedTypes.Contains(typeStr))
Expand Down Expand Up @@ -219,7 +215,6 @@ static async Task<int> Main(string[] args)
string rawType = typeStr;

if (TypeInfo.SkippedMembers.Contains($"{ptrTypeName}.{field.Name}")) { continue; }
if (TypeInfo.ScratchedTypes.Contains(field.Type)) { continue; }

if (TypeInfo.WellKnownFieldReplacements.TryGetValue(field.Type, out string wellKnownFieldType))
{
Expand Down Expand Up @@ -293,9 +288,6 @@ static async Task<int> Main(string[] args)
continue;
}

if (overload.Parameters.Any(tr => TypeInfo.ScratchedTypes.Contains(tr.Type))) { continue; }
if (TypeInfo.ScratchedTypes.Contains(overload.ReturnType)) { continue; }

string exportedName = overload.ExportedName;
if (exportedName.StartsWith("ig"))
{
Expand Down Expand Up @@ -394,9 +386,6 @@ void EmitImGuiNativeFunctions(CSharpCodeWriter writer, bool isInternal)

if (overload.Parameters.Any(tr => tr.Type.Contains('('))) { continue; } // TODO: Parse function pointer parameters.

if (overload.Parameters.Any(tr => TypeInfo.ScratchedTypes.Contains(tr.Type))) { continue; }
if (TypeInfo.ScratchedTypes.Contains(overload.ReturnType)) { continue; }

string ret = GetTypeString(overload.ReturnType, false);

bool hasVaList = false;
Expand Down Expand Up @@ -501,8 +490,6 @@ void EmitImGuiFunctions(CSharpCodeWriter writer, bool isInternal)
}
if (exportedName.Contains("~")) { continue; }
if (overload.Parameters.Any(tr => tr.Type.Contains('('))) { continue; } // TODO: Parse function pointer parameters.
if (overload.Parameters.Any(tr => TypeInfo.ScratchedTypes.Contains(tr.Type))) { continue; }
if (TypeInfo.ScratchedTypes.Contains(overload.ReturnType)) { continue; }

if ((overload.FriendlyName == "GetID" || overload.FriendlyName == "PushID") && overload.Parameters.Length > 1)
{
Expand Down
48 changes: 5 additions & 43 deletions src/CodeGenerator/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,58 +172,20 @@ public class TypeInfo
"double",
};

public static readonly HashSet<string> ScratchedTypes = new HashSet<string>()
{
"ImGuiStyleMod",
"ImGuiStyleMod*",
"ImGuiInputEvent",
"ImGuiInputEvent*",
"ImGuiDockNode",
"ImGuiDockNode*",
"ImDrawDataBuilder",
"ImDrawDataBuilder*",
"ImGuiTable",
"ImGuiTable*",
"ImGuiInputEvent",
"ImGuiInputEvent*",
};

public static readonly HashSet<string> SkippedFunctions = new HashSet<string>()
{
"igInputText",
"igInputTextMultiline",
"igInputTextWithHint",
"igFindBestWindowPosForPopupEx",

// Table related
"igDebugNodeTable",
"igGetCurrentTable"
};

public static readonly HashSet<string> SkippedMembers = new HashSet<string>()
{
"ImGuiContextPtr.StyleVarStack",
"ImGuiContextPtr.SettingsWindows",
"ImGuiContextPtr.SettingsTables",
"ImGuiContextPtr.ItemFlagsStack",
"ImGuiContextPtr.Tables",
"ImGuiContextPtr.TabBars",
"ImGuiContextPtr.LocalizationTable",
"ImGuiContextPtr.InputEventsQueue",
"ImGuiContextPtr.InputEventsTrail",
"ImGuiContextPtr.DrawChannelsTempMergeBuffer",

"ImGuiContext.StyleVarStack",
"ImGuiContext.SettingsWindows",
"ImGuiContext.SettingsTables",
"ImGuiContext.ItemFlagsStack",
"ImGuiContext.Tables",
"ImGuiContext.TabBars",
"ImGuiContext.InputEventsQueue",
"ImGuiContext.InputEventsTrail",
"ImGuiContext.DrawChannelsTempMergeBuffer",

"ImGuiViewportPPtr.BgFgDrawLists",
// This can be used to rip members out of internal when you simply want to exclude them.
// You must be careful when using this to not mess with data structures that are used
// by ImGui
// Add an entry for the type.name, such as:
// "ImGuiContextPtr.StyleVarStack"
};
}
}
Loading