diff --git a/filter_imgui_bindings.ps1 b/filter_imgui_bindings.ps1 index 7df1a71da..77a033b3e 100644 --- a/filter_imgui_bindings.ps1 +++ b/filter_imgui_bindings.ps1 @@ -23,7 +23,14 @@ $tmp = Get-Content -Path "$PSScriptRoot\imgui\Dalamud.Bindings.ImGui\Generated\E $tmp = $tmp.Replace("unchecked((int)GamepadStart)", "unchecked((int)ImGuiKey.GamepadStart)").Trim() $tmp | Set-Content -Path "$PSScriptRoot\imgui\Dalamud.Bindings.ImGui\Generated\Enums\ImGuiKeyPrivate.cs" -Encoding ascii -Remove-Item -Path "$PSScriptRoot\imgui\Dalamud.Bindings.ImGui\Generated\Handles\ImTextureID.cs" -Force +try +{ + Remove-Item -Path "$PSScriptRoot\imgui\Dalamud.Bindings.ImGui\Generated\Handles\ImTextureID.cs" -Force +} +catch [System.Management.Automation.ItemNotFoundException] +{ + # pass +} foreach ($sourcePath in $sourcePaths) { @@ -188,8 +195,19 @@ foreach ($sourcePath in $sourcePaths) foreach ($overload in $methods) { - # discard formatting functions or functions accepting (begin, end) or (data, size) pairs + $returnType = $overload.Groups["return"].Value.Trim() $argDef = $overload.Groups["args"].Value + + # discard functions returning a string of some sort + if ($returnType -eq "string" -and + $methodName.EndsWith("S")) + { + $null = $discardMethods.Add($methodName.Substring(0, $methodName.Length - 1)) + $null = $discardMethods.Add($methodName) + break + } + + # discard formatting functions or functions accepting (begin, end) or (data, size) pairs if ($argDef.Contains("fmt") -or $argDef -match "\btext\b" -or # $argDef.Contains("byte* textEnd") -or diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Functions/ImGui.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Functions/ImGui.gen.cs index 8336bbb40..221a16f14 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Functions/ImGui.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Functions/ImGui.gen.cs @@ -894,16 +894,6 @@ public unsafe partial class ImGui { ImGuiNative.ShowUserGuide(); } - public static byte* GetVersion() - { - byte* ret = ImGuiNative.GetVersion(); - return ret; - } - public static string GetVersionS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetVersion()); - return ret; - } public static void StyleColorsDark(ImGuiStylePtr dst) { ImGuiNative.StyleColorsDark(dst); @@ -1814,26 +1804,6 @@ public unsafe partial class ImGui int ret = ImGuiNative.TableGetRowIndex(); return ret; } - public static byte* TableGetColumnName(int columnN) - { - byte* ret = ImGuiNative.TableGetColumnName(columnN); - return ret; - } - public static byte* TableGetColumnName() - { - byte* ret = ImGuiNative.TableGetColumnName((int)(-1)); - return ret; - } - public static string TableGetColumnNameS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.TableGetColumnName((int)(-1))); - return ret; - } - public static string TableGetColumnNameS(int columnN) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.TableGetColumnName(columnN)); - return ret; - } public static ImGuiTableColumnFlags TableGetColumnFlags(int columnN) { ImGuiTableColumnFlags ret = ImGuiNative.TableGetColumnFlags(columnN); @@ -2446,16 +2416,6 @@ public unsafe partial class ImGui ImDrawListSharedDataPtr ret = ImGuiNative.GetDrawListSharedData(); return ret; } - public static byte* GetStyleColorName(ImGuiCol idx) - { - byte* ret = ImGuiNative.GetStyleColorName(idx); - return ret; - } - public static string GetStyleColorNameS(ImGuiCol idx) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetStyleColorName(idx)); - return ret; - } public static void SetStateStorage(ImGuiStoragePtr storage) { ImGuiNative.SetStateStorage(storage); @@ -2669,16 +2629,6 @@ public unsafe partial class ImGui int ret = ImGuiNative.GetKeyPressedAmount(key, repeatDelay, rate); return ret; } - public static byte* GetKeyName(ImGuiKey key) - { - byte* ret = ImGuiNative.GetKeyName(key); - return ret; - } - public static string GetKeyNameS(ImGuiKey key) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetKeyName(key)); - return ret; - } public static void SetNextFrameWantCaptureKeyboard(bool wantCaptureKeyboard) { ImGuiNative.SetNextFrameWantCaptureKeyboard(wantCaptureKeyboard ? (byte)1 : (byte)0); @@ -2879,36 +2829,6 @@ public unsafe partial class ImGui { ImGuiNative.SetNextFrameWantCaptureMouse(wantCaptureMouse ? (byte)1 : (byte)0); } - public static byte* GetClipboardText() - { - byte* ret = ImGuiNative.GetClipboardText(); - return ret; - } - public static string GetClipboardTextS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetClipboardText()); - return ret; - } - public static byte* SaveIniSettingsToMemory(nuint* outIniSize) - { - byte* ret = ImGuiNative.SaveIniSettingsToMemory(outIniSize); - return ret; - } - public static byte* SaveIniSettingsToMemory() - { - byte* ret = ImGuiNative.SaveIniSettingsToMemory((nuint*)(default)); - return ret; - } - public static string SaveIniSettingsToMemoryS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.SaveIniSettingsToMemory((nuint*)(default))); - return ret; - } - public static string SaveIniSettingsToMemoryS(nuint* outIniSize) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.SaveIniSettingsToMemory(outIniSize)); - return ret; - } public static void SetAllocatorFunctions(ImGuiMemAllocFunc allocFunc, ImGuiMemFreeFunc freeFunc, void* userData) { ImGuiNative.SetAllocatorFunctions(allocFunc, freeFunc, userData); @@ -3393,58 +3313,6 @@ public unsafe partial class ImGui ImGuiTextBufferPtr ret = ImGuiNative.ImGuiTextBuffer(); return ret; } - public static byte* begin(ImGuiTextBufferPtr self) - { - byte* ret = ImGuiNative.begin(self); - return ret; - } - public static byte* begin(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - byte* ret = ImGuiNative.begin((ImGuiTextBuffer*)pself); - return ret; - } - } - public static string beginS(ImGuiTextBufferPtr self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.begin(self)); - return ret; - } - public static string beginS(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.begin((ImGuiTextBuffer*)pself)); - return ret; - } - } - public static byte* end(ImGuiTextBufferPtr self) - { - byte* ret = ImGuiNative.end(self); - return ret; - } - public static byte* end(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - byte* ret = ImGuiNative.end((ImGuiTextBuffer*)pself); - return ret; - } - } - public static string endS(ImGuiTextBufferPtr self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.end(self)); - return ret; - } - public static string endS(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.end((ImGuiTextBuffer*)pself)); - return ret; - } - } public static int size(ImGuiTextBufferPtr self) { int ret = ImGuiNative.size(self); @@ -3480,32 +3348,6 @@ public unsafe partial class ImGui ImGuiNative.reserve((ImGuiTextBuffer*)pself, capacity); } } - public static byte* c_str(ImGuiTextBufferPtr self) - { - byte* ret = ImGuiNative.c_str(self); - return ret; - } - public static byte* c_str(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - byte* ret = ImGuiNative.c_str((ImGuiTextBuffer*)pself); - return ret; - } - } - public static string c_strS(ImGuiTextBufferPtr self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.c_str(self)); - return ret; - } - public static string c_strS(ref ImGuiTextBuffer self) - { - fixed (ImGuiTextBuffer* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.c_str((ImGuiTextBuffer*)pself)); - return ret; - } - } public static ImGuiStoragePairPtr ImGuiStoragePair(uint key, int valI) { ImGuiStoragePairPtr ret = ImGuiNative.ImGuiStoragePair(key, valI); @@ -8517,32 +8359,6 @@ public unsafe partial class ImGui return ret != 0; } } - public static byte* GetDebugName(ImFontPtr self) - { - byte* ret = ImGuiNative.GetDebugName(self); - return ret; - } - public static byte* GetDebugName(ref ImFont self) - { - fixed (ImFont* pself = &self) - { - byte* ret = ImGuiNative.GetDebugName((ImFont*)pself); - return ret; - } - } - public static string GetDebugNameS(ImFontPtr self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetDebugName(self)); - return ret; - } - public static string GetDebugNameS(ref ImFont self) - { - fixed (ImFont* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetDebugName((ImFont*)pself)); - return ret; - } - } public static void RenderChar(ImFontPtr self, ImDrawListPtr drawList, float size, Vector2 pos, uint col, ushort c) { ImGuiNative.RenderChar(self, drawList, size, pos, col, c); @@ -8896,6 +8712,7 @@ public unsafe partial class ImGui // DISCARDED: internal static void appendfNative(ImGuiTextBuffer* buffer, byte* fmt) // DISCARDED: internal static void appendfvNative(ImGuiTextBuffer* self, byte* fmt, nuint args) // DISCARDED: internal static byte ArrowButtonNative(byte* strId, ImGuiDir dir) +// DISCARDED: internal static byte* beginNative(ImGuiTextBuffer* self) // DISCARDED: internal static byte BeginNative(byte* name, bool* pOpen, ImGuiWindowFlags flags) // DISCARDED: internal static void BeginNative(ImGuiListClipper* self, int itemsCount, float itemsHeight) // DISCARDED: internal static byte BeginChildNative(byte* strId, Vector2 size, byte border, ImGuiWindowFlags flags) @@ -8908,12 +8725,15 @@ public unsafe partial class ImGui // DISCARDED: internal static byte BeginPopupContextVoidNative(byte* strId, ImGuiPopupFlags popupFlags) // DISCARDED: internal static byte BeginPopupContextWindowNative(byte* strId, ImGuiPopupFlags popupFlags) // DISCARDED: internal static byte BeginPopupModalNative(byte* name, bool* pOpen, ImGuiWindowFlags flags) +// DISCARDED: beginS // DISCARDED: internal static byte BeginTabBarNative(byte* strId, ImGuiTabBarFlags flags) // DISCARDED: internal static byte BeginTabItemNative(byte* label, bool* pOpen, ImGuiTabItemFlags flags) // DISCARDED: internal static byte BeginTableNative(byte* strId, int column, ImGuiTableFlags flags, Vector2 outerSize, float innerWidth) // DISCARDED: internal static void BulletTextNative(byte* fmt) // DISCARDED: internal static void BulletTextVNative(byte* fmt, nuint args) // DISCARDED: internal static byte ButtonNative(byte* label, Vector2 size) +// DISCARDED: internal static byte* c_strNative(ImGuiTextBuffer* self) +// DISCARDED: c_strS // DISCARDED: internal static void CalcTextSizeNative(Vector2* pOut, byte* text, byte* textEnd, byte hideTextAfterDoubleHash, float wrapWidth) // DISCARDED: internal static void CalcTextSizeANative(Vector2* pOut, ImFont* self, float size, float maxWidth, float wrapWidth, byte* textBegin, byte* textEnd, byte** remaining) // DISCARDED: internal static byte* CalcWordWrapPositionANative(ImFont* self, float scale, byte* text, byte* textEnd, float wrapWidth) @@ -8947,12 +8767,24 @@ public unsafe partial class ImGui // DISCARDED: internal static byte DragScalarNative(byte* label, ImGuiDataType dataType, void* pData, float vSpeed, void* pMin, void* pMax, byte* format, ImGuiSliderFlags flags) // DISCARDED: internal static byte DragScalarNNative(byte* label, ImGuiDataType dataType, void* pData, int components, float vSpeed, void* pMin, void* pMax, byte* format, ImGuiSliderFlags flags) // DISCARDED: internal static byte DrawNative(ImGuiTextFilter* self, byte* label, float width) +// DISCARDED: internal static byte* endNative(ImGuiTextBuffer* self) +// DISCARDED: endS // DISCARDED: internal static bool* GetBoolRefNative(ImGuiStorage* self, uint key, byte defaultVal) +// DISCARDED: internal static byte* GetClipboardTextNative() +// DISCARDED: GetClipboardTextS +// DISCARDED: internal static byte* GetDebugNameNative(ImFont* self) +// DISCARDED: GetDebugNameS // DISCARDED: internal static float* GetFloatRefNative(ImGuiStorage* self, uint key, float defaultVal) // DISCARDED: internal static uint GetIDNative(byte* strId) // DISCARDED: internal static uint GetIDNative(byte* strIdBegin, byte* strIdEnd) // DISCARDED: internal static uint GetIDNative(void* ptrId) // DISCARDED: internal static int* GetIntRefNative(ImGuiStorage* self, uint key, int defaultVal) +// DISCARDED: internal static byte* GetKeyNameNative(ImGuiKey key) +// DISCARDED: GetKeyNameS +// DISCARDED: internal static byte* GetStyleColorNameNative(ImGuiCol idx) +// DISCARDED: GetStyleColorNameS +// DISCARDED: internal static byte* GetVersionNative() +// DISCARDED: GetVersionS // DISCARDED: internal static void** GetVoidPtrRefNative(ImGuiStorage* self, uint key, void* defaultVal) // DISCARDED: internal static ImGuiTextFilter* ImGuiTextFilterNative(byte* defaultFilter) // DISCARDED: internal static ImGuiTextRange* ImGuiTextRangeNative() @@ -9000,6 +8832,8 @@ public unsafe partial class ImGui // DISCARDED: internal static byte RadioButtonNative(byte* label, int* v, int vButton) // DISCARDED: internal static void RenderTextNative(ImFont* self, ImDrawList* drawList, float size, Vector2 pos, uint col, Vector4 clipRect, byte* textBegin, byte* textEnd, float wrapWidth, byte cpuFineClip) // DISCARDED: internal static void SaveIniSettingsToDiskNative(byte* iniFilename) +// DISCARDED: internal static byte* SaveIniSettingsToMemoryNative(nuint* outIniSize) +// DISCARDED: SaveIniSettingsToMemoryS // DISCARDED: internal static byte SelectableNative(byte* label, byte selected, ImGuiSelectableFlags flags, Vector2 size) // DISCARDED: internal static byte SelectableNative(byte* label, bool* pSelected, ImGuiSelectableFlags flags, Vector2 size) // DISCARDED: internal static void SetClipboardTextNative(byte* text) @@ -9030,6 +8864,8 @@ public unsafe partial class ImGui // DISCARDED: internal static byte SliderScalarNNative(byte* label, ImGuiDataType dataType, void* pData, int components, void* pMin, void* pMax, byte* format, ImGuiSliderFlags flags) // DISCARDED: internal static byte SmallButtonNative(byte* label) // DISCARDED: internal static byte TabItemButtonNative(byte* label, ImGuiTabItemFlags flags) +// DISCARDED: internal static byte* TableGetColumnNameNative(int columnN) +// DISCARDED: TableGetColumnNameS // DISCARDED: internal static void TableHeaderNative(byte* label) // DISCARDED: internal static void TableSetupColumnNative(byte* label, ImGuiTableColumnFlags flags, float initWidthOrWeight, uint userId) // DISCARDED: internal static void TextNative(byte* fmt) diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFont.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFont.gen.cs index eb0d75fb6..8c55dc024 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFont.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFont.gen.cs @@ -94,22 +94,6 @@ public unsafe partial struct ImFont return ret; } } - public unsafe byte* GetDebugName() - { - fixed (ImFont* @this = &this) - { - byte* ret = ImGuiNative.GetDebugName(@this); - return ret; - } - } - public unsafe string GetDebugNameS() - { - fixed (ImFont* @this = &this) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetDebugName(@this)); - return ret; - } - } public unsafe float GetDistanceAdjustmentForPair(ushort leftC, ushort rightC) { fixed (ImFont* @this = &this) @@ -187,5 +171,7 @@ public unsafe partial struct ImFont } // DISCARDED: CalcWordWrapPositionA // DISCARDED: CalcWordWrapPositionAS +// DISCARDED: GetDebugName +// DISCARDED: GetDebugNameS // DISCARDED: RenderText diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFontPtr.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFontPtr.gen.cs index 0e65c3074..9d542a898 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFontPtr.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImFontPtr.gen.cs @@ -61,16 +61,6 @@ public unsafe partial struct ImFontPtr float ret = ImGuiNative.GetCharAdvance(Handle, c); return ret; } - public unsafe byte* GetDebugName() - { - byte* ret = ImGuiNative.GetDebugName(Handle); - return ret; - } - public unsafe string GetDebugNameS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.GetDebugName(Handle)); - return ret; - } public unsafe float GetDistanceAdjustmentForPair(ushort leftC, ushort rightC) { float ret = ImGuiNative.GetDistanceAdjustmentForPair(Handle, leftC, rightC); @@ -121,5 +111,7 @@ public unsafe partial struct ImFontPtr } // DISCARDED: CalcWordWrapPositionA // DISCARDED: CalcWordWrapPositionAS +// DISCARDED: GetDebugName +// DISCARDED: GetDebugNameS // DISCARDED: RenderText diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBuffer.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBuffer.gen.cs index a4abe5987..902472c02 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBuffer.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBuffer.gen.cs @@ -11,38 +11,6 @@ namespace Dalamud.Bindings.ImGui; public unsafe partial struct ImGuiTextBuffer { - public unsafe byte* begin() - { - fixed (ImGuiTextBuffer* @this = &this) - { - byte* ret = ImGuiNative.begin(@this); - return ret; - } - } - public unsafe string beginS() - { - fixed (ImGuiTextBuffer* @this = &this) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.begin(@this)); - return ret; - } - } - public unsafe byte* c_str() - { - fixed (ImGuiTextBuffer* @this = &this) - { - byte* ret = ImGuiNative.c_str(@this); - return ret; - } - } - public unsafe string c_strS() - { - fixed (ImGuiTextBuffer* @this = &this) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.c_str(@this)); - return ret; - } - } public unsafe void clear() { fixed (ImGuiTextBuffer* @this = &this) @@ -65,22 +33,6 @@ public unsafe partial struct ImGuiTextBuffer return ret != 0; } } - public unsafe byte* end() - { - fixed (ImGuiTextBuffer* @this = &this) - { - byte* ret = ImGuiNative.end(@this); - return ret; - } - } - public unsafe string endS() - { - fixed (ImGuiTextBuffer* @this = &this) - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.end(@this)); - return ret; - } - } public unsafe void reserve(int capacity) { fixed (ImGuiTextBuffer* @this = &this) @@ -100,4 +52,10 @@ public unsafe partial struct ImGuiTextBuffer // DISCARDED: append // DISCARDED: appendf // DISCARDED: appendfv +// DISCARDED: begin +// DISCARDED: beginS +// DISCARDED: c_str +// DISCARDED: c_strS +// DISCARDED: end +// DISCARDED: endS diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBufferPtr.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBufferPtr.gen.cs index a3b997b9c..f1a03482c 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBufferPtr.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Generated/Structs/ImGuiTextBufferPtr.gen.cs @@ -11,26 +11,6 @@ namespace Dalamud.Bindings.ImGui; public unsafe partial struct ImGuiTextBufferPtr { - public unsafe byte* begin() - { - byte* ret = ImGuiNative.begin(Handle); - return ret; - } - public unsafe string beginS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.begin(Handle)); - return ret; - } - public unsafe byte* c_str() - { - byte* ret = ImGuiNative.c_str(Handle); - return ret; - } - public unsafe string c_strS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.c_str(Handle)); - return ret; - } public unsafe void clear() { ImGuiNative.clear(Handle); @@ -44,16 +24,6 @@ public unsafe partial struct ImGuiTextBufferPtr byte ret = ImGuiNative.empty(Handle); return ret != 0; } - public unsafe byte* end() - { - byte* ret = ImGuiNative.end(Handle); - return ret; - } - public unsafe string endS() - { - string ret = Utils.DecodeStringUTF8(ImGuiNative.end(Handle)); - return ret; - } public unsafe void reserve(int capacity) { ImGuiNative.reserve(Handle, capacity); @@ -67,4 +37,10 @@ public unsafe partial struct ImGuiTextBufferPtr // DISCARDED: append // DISCARDED: appendf // DISCARDED: appendfv +// DISCARDED: begin +// DISCARDED: beginS +// DISCARDED: c_str +// DISCARDED: c_strS +// DISCARDED: end +// DISCARDED: endS diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Internals/Functions/ImGuiP.gen.cs b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Internals/Functions/ImGuiP.gen.cs index 5d8e8b6c7..32c98e210 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Internals/Functions/ImGuiP.gen.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/Generated/Internals/Functions/ImGuiP.gen.cs @@ -50,48 +50,6 @@ public unsafe partial class ImGuiP byte ret = ImGuiPNative.ImCharIsBlankW(c); return ret != 0; } - public static byte* ImTextCharToUtf8(byte* outBuf, uint c) - { - byte* ret = ImGuiPNative.ImTextCharToUtf8(outBuf, c); - return ret; - } - public static byte* ImTextCharToUtf8(ref byte outBuf, uint c) - { - fixed (byte* poutBuf = &outBuf) - { - byte* ret = ImGuiPNative.ImTextCharToUtf8((byte*)poutBuf, c); - return ret; - } - } - public static byte* ImTextCharToUtf8(ReadOnlySpan outBuf, uint c) - { - fixed (byte* poutBuf = outBuf) - { - byte* ret = ImGuiPNative.ImTextCharToUtf8((byte*)poutBuf, c); - return ret; - } - } - public static string ImTextCharToUtf8S(byte* outBuf, uint c) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.ImTextCharToUtf8(outBuf, c)); - return ret; - } - public static string ImTextCharToUtf8S(ref byte outBuf, uint c) - { - fixed (byte* poutBuf = &outBuf) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.ImTextCharToUtf8((byte*)poutBuf, c)); - return ret; - } - } - public static string ImTextCharToUtf8S(ReadOnlySpan outBuf, uint c) - { - fixed (byte* poutBuf = outBuf) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.ImTextCharToUtf8((byte*)poutBuf, c)); - return ret; - } - } public static int ImTextCountUtf8BytesFromStr(ushort* inText, ushort* inTextEnd) { int ret = ImGuiPNative.ImTextCountUtf8BytesFromStr(inText, inTextEnd); @@ -2159,32 +2117,6 @@ public unsafe partial class ImGuiP ImGuiWindowSettingsPtr ret = ImGuiPNative.ImGuiWindowSettings(); return ret; } - public static byte* GetName(ImGuiWindowSettingsPtr self) - { - byte* ret = ImGuiPNative.GetName(self); - return ret; - } - public static byte* GetName(ref ImGuiWindowSettings self) - { - fixed (ImGuiWindowSettings* pself = &self) - { - byte* ret = ImGuiPNative.GetName((ImGuiWindowSettings*)pself); - return ret; - } - } - public static string GetNameS(ImGuiWindowSettingsPtr self) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetName(self)); - return ret; - } - public static string GetNameS(ref ImGuiWindowSettings self) - { - fixed (ImGuiWindowSettings* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetName((ImGuiWindowSettings*)pself)); - return ret; - } - } public static ImGuiSettingsHandlerPtr ImGuiSettingsHandler() { ImGuiSettingsHandlerPtr ret = ImGuiPNative.ImGuiSettingsHandler(); @@ -2403,70 +2335,6 @@ public unsafe partial class ImGuiP } } } - public static byte* GetTabName(ImGuiTabBarPtr self, ImGuiTabItemPtr tab) - { - byte* ret = ImGuiPNative.GetTabName(self, tab); - return ret; - } - public static byte* GetTabName(ref ImGuiTabBar self, ImGuiTabItemPtr tab) - { - fixed (ImGuiTabBar* pself = &self) - { - byte* ret = ImGuiPNative.GetTabName((ImGuiTabBar*)pself, tab); - return ret; - } - } - public static byte* GetTabName(ImGuiTabBarPtr self, ref ImGuiTabItem tab) - { - fixed (ImGuiTabItem* ptab = &tab) - { - byte* ret = ImGuiPNative.GetTabName(self, (ImGuiTabItem*)ptab); - return ret; - } - } - public static byte* GetTabName(ref ImGuiTabBar self, ref ImGuiTabItem tab) - { - fixed (ImGuiTabBar* pself = &self) - { - fixed (ImGuiTabItem* ptab = &tab) - { - byte* ret = ImGuiPNative.GetTabName((ImGuiTabBar*)pself, (ImGuiTabItem*)ptab); - return ret; - } - } - } - public static string GetTabNameS(ImGuiTabBarPtr self, ImGuiTabItemPtr tab) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetTabName(self, tab)); - return ret; - } - public static string GetTabNameS(ref ImGuiTabBar self, ImGuiTabItemPtr tab) - { - fixed (ImGuiTabBar* pself = &self) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetTabName((ImGuiTabBar*)pself, tab)); - return ret; - } - } - public static string GetTabNameS(ImGuiTabBarPtr self, ref ImGuiTabItem tab) - { - fixed (ImGuiTabItem* ptab = &tab) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetTabName(self, (ImGuiTabItem*)ptab)); - return ret; - } - } - public static string GetTabNameS(ref ImGuiTabBar self, ref ImGuiTabItem tab) - { - fixed (ImGuiTabBar* pself = &self) - { - fixed (ImGuiTabItem* ptab = &tab) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetTabName((ImGuiTabBar*)pself, (ImGuiTabItem*)ptab)); - return ret; - } - } - } public static ImGuiTableColumnPtr ImGuiTableColumn() { ImGuiTableColumnPtr ret = ImGuiPNative.ImGuiTableColumn(); @@ -3900,16 +3768,6 @@ public unsafe partial class ImGuiP ImGuiPNative.NavMoveRequestTryWrapping((ImGuiWindow*)pwindow, moveFlags); } } - public static byte* GetNavInputName(ImGuiNavInput n) - { - byte* ret = ImGuiPNative.GetNavInputName(n); - return ret; - } - public static string GetNavInputNameS(ImGuiNavInput n) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.GetNavInputName(n)); - return ret; - } public static float GetNavInputAmount(ImGuiNavInput n, ImGuiNavReadMode mode) { float ret = ImGuiPNative.GetNavInputAmount(n, mode); @@ -5247,32 +5105,6 @@ public unsafe partial class ImGuiP } } } - public static byte* TableGetColumnName(ImGuiTablePtr table, int columnN) - { - byte* ret = ImGuiPNative.TableGetColumnName(table, columnN); - return ret; - } - public static byte* TableGetColumnName(ref ImGuiTable table, int columnN) - { - fixed (ImGuiTable* ptable = &table) - { - byte* ret = ImGuiPNative.TableGetColumnName((ImGuiTable*)ptable, columnN); - return ret; - } - } - public static string TableGetColumnNameS(ImGuiTablePtr table, int columnN) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.TableGetColumnName(table, columnN)); - return ret; - } - public static string TableGetColumnNameS(ref ImGuiTable table, int columnN) - { - fixed (ImGuiTable* ptable = &table) - { - string ret = Utils.DecodeStringUTF8(ImGuiPNative.TableGetColumnName((ImGuiTable*)ptable, columnN)); - return ret; - } - } public static uint TableGetColumnResizeID(ImGuiTablePtr table, int columnN, int instanceNo) { uint ret = ImGuiPNative.TableGetColumnResizeID(table, columnN, instanceNo); @@ -6697,6 +6529,12 @@ public unsafe partial class ImGuiP // DISCARDED: internal static uint GetIDNative(ImGuiWindow* self, void* ptr) // DISCARDED: internal static uint GetIDNative(ImGuiWindow* self, int n) // DISCARDED: internal static uint GetIDWithSeedNative(byte* strIdBegin, byte* strIdEnd, uint seed) +// DISCARDED: internal static byte* GetNameNative(ImGuiWindowSettings* self) +// DISCARDED: GetNameS +// DISCARDED: internal static byte* GetNavInputNameNative(ImGuiNavInput n) +// DISCARDED: GetNavInputNameS +// DISCARDED: internal static byte* GetTabNameNative(ImGuiTabBar* self, ImGuiTabItem* tab) +// DISCARDED: GetTabNameS // DISCARDED: internal static void* ImFileLoadToMemoryNative(byte* filename, byte* mode, nuint* outFileSize, int paddingBytes) // DISCARDED: internal static ImFileHandle ImFileOpenNative(byte* filename, byte* mode) // DISCARDED: internal static void ImFontAtlasBuildMultiplyRectAlpha8Native(byte* table, byte* pixels, int x, int y, int w, int h, int stride) @@ -6733,6 +6571,8 @@ public unsafe partial class ImGuiP // DISCARDED: ImStrSkipBlankS // DISCARDED: internal static void ImStrTrimBlanksNative(byte* str) // DISCARDED: internal static int ImTextCharFromUtf8Native(uint* outChar, byte* inText, byte* inTextEnd) +// DISCARDED: internal static byte* ImTextCharToUtf8Native(byte* outBuf, uint c) +// DISCARDED: ImTextCharToUtf8S // DISCARDED: internal static int ImTextCountCharsFromUtf8Native(byte* inText, byte* inTextEnd) // DISCARDED: internal static int ImTextCountUtf8BytesFromCharNative(byte* inText, byte* inTextEnd) // DISCARDED: internal static void LogRenderedTextNative(Vector2* refPos, byte* text, byte* textEnd) @@ -6749,6 +6589,8 @@ public unsafe partial class ImGuiP // DISCARDED: internal static void TabItemCalcSizeNative(Vector2* pOut, byte* label, byte hasCloseButton) // DISCARDED: internal static byte TabItemExNative(ImGuiTabBar* tabBar, byte* label, bool* pOpen, ImGuiTabItemFlags flags, ImGuiWindow* dockedWindow) // DISCARDED: internal static void TabItemLabelAndCloseButtonNative(ImDrawList* drawList, ImRect bb, ImGuiTabItemFlags flags, Vector2 framePadding, byte* label, uint tabId, uint closeButtonId, byte isContentsVisible, bool* outJustClosed, bool* outTextClipped) +// DISCARDED: internal static byte* TableGetColumnNameNative(ImGuiTable* table, int columnN) +// DISCARDED: TableGetColumnNameS // DISCARDED: internal static byte TempInputScalarNative(ImRect bb, uint id, byte* label, ImGuiDataType dataType, void* pData, byte* format, void* pClampMin, void* pClampMax) // DISCARDED: internal static void TextExNative(byte* text, byte* textEnd, ImGuiTextFlags flags) // DISCARDED: internal static byte TreeNodeBehaviorNative(uint id, ImGuiTreeNodeFlags flags, byte* label, byte* labelEnd) diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.StringReturns.cs b/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.StringReturns.cs new file mode 100644 index 000000000..c6ba44ac1 --- /dev/null +++ b/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.StringReturns.cs @@ -0,0 +1,73 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; +using System.Text; + +namespace Dalamud.Bindings.ImGui; + +[SuppressMessage("ReSharper", "InconsistentNaming")] +public unsafe partial class ImGui +{ + public static ReadOnlySpan GetVersionU8() => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetVersion()); + + public static ReadOnlySpan TableGetColumnNameU8(int columnN = -1) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.TableGetColumnName(columnN)); + + public static ReadOnlySpan GetStyleColorNameU8(this ImGuiCol idx) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetStyleColorName(idx)); + + public static ReadOnlySpan GetKeyNameU8(this ImGuiKey key) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetKeyName(key)); + + public static ReadOnlySpan GetClipboardTextU8() => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetClipboardText()); + + public static ReadOnlySpan SaveIniSettingsToMemoryU8() + { + nuint len; + var ptr = ImGuiNative.SaveIniSettingsToMemory(&len); + return new(ptr, (int)len); + } + + public static ref byte begin(this ImGuiTextBufferPtr self) => ref *ImGuiNative.begin(self.Handle); + + public static ref byte begin(this in ImGuiTextBuffer self) + { + fixed (ImGuiTextBuffer* selfPtr = &self) + return ref *ImGuiNative.begin(selfPtr); + } + + public static ref byte end(this ImGuiTextBufferPtr self) => ref *ImGuiNative.end(self.Handle); + + public static ref byte end(this in ImGuiTextBuffer self) + { + fixed (ImGuiTextBuffer* selfPtr = &self) + return ref *ImGuiNative.end(selfPtr); + } + + public static ReadOnlySpan c_str(this ImGuiTextBufferPtr self) => self.Handle->c_str(); + + public static ReadOnlySpan c_str(this scoped in ImGuiTextBuffer self) + { + fixed (ImGuiTextBuffer* selfPtr = &self) + return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.c_str(selfPtr)); + } + + public static ReadOnlySpan GetDebugNameU8(this ImFontPtr self) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetDebugName(self.Handle)); + + public static ReadOnlySpan GetDebugNameU8(this scoped in ImFont self) + { + fixed (ImFont* selfPtr = &self) + return MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiNative.GetDebugName(selfPtr)); + } + + public static string GetVersion() => Encoding.UTF8.GetString(GetVersionU8()); + public static string TableGetColumnName(int columnN = -1) => Encoding.UTF8.GetString(TableGetColumnNameU8(columnN)); + public static string GetStyleColorName(this ImGuiCol idx) => Encoding.UTF8.GetString(GetStyleColorNameU8(idx)); + public static string GetKeyName(this ImGuiKey key) => Encoding.UTF8.GetString(GetKeyNameU8(key)); + public static string GetClipboardText() => Encoding.UTF8.GetString(GetClipboardTextU8()); + public static string SaveIniSettingsToMemory() => Encoding.UTF8.GetString(SaveIniSettingsToMemoryU8()); + public static string GetDebugName(this ImFontPtr self) => Encoding.UTF8.GetString(GetDebugNameU8(self)); + public static string GetDebugName(this scoped in ImFont self) => Encoding.UTF8.GetString(GetDebugNameU8(self)); +} diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.Text.cs b/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.Text.cs index 959369c5c..4c8d7f7d0 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.Text.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/ImGui.Text.cs @@ -46,7 +46,7 @@ public static unsafe partial class ImGui text.Dispose(); } - public static void append(ImGuiTextBufferPtr self, ImU8String str) + public static void append(this ImGuiTextBufferPtr self, ImU8String str) { fixed (byte* strPtr = str.Span) ImGuiNative.append(self.Handle, strPtr, strPtr + str.Length); str.Dispose(); diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiNative.Custom.cs b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiNative.Custom.cs index 94d31e8ea..66626ee3b 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiNative.Custom.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiNative.Custom.cs @@ -19,14 +19,14 @@ public static unsafe partial class ImGuiNative } } - [LibraryImport($"{LibraryName}.dll", EntryPoint = "ImDrawList_AddCallback")] + [LibraryImport(LibraryName, EntryPoint = "ImDrawList_AddCallback")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void AddCallback( ImDrawList* self, delegate* callback, void* callbackData = null); - [LibraryImport($"{LibraryName}.dll", EntryPoint = "igInputTextEx")] + [LibraryImport(LibraryName, EntryPoint = "igInputTextEx")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int InputTextEx( byte* label, diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiP.StringReturns.cs b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiP.StringReturns.cs new file mode 100644 index 000000000..b16843f55 --- /dev/null +++ b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiP.StringReturns.cs @@ -0,0 +1,85 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace Dalamud.Bindings.ImGui; + +public unsafe partial class ImGuiP +{ + public static Span ImTextCharToUtf8(Span buf, char c) => ImTextCharToUtf8(buf, (uint)c); + + public static Span ImTextCharToUtf8(Span buf, int c) => ImTextCharToUtf8(buf, (uint)c); + + public static Span ImTextCharToUtf8(Span buf, uint c) + { + if (!new Rune(c).TryEncodeToUtf8(buf, out var len)) + throw new ArgumentException("Buffer is too small.", nameof(buf)); + return buf[..len]; + } + + public static ReadOnlySpan GetNameU8(this ImGuiWindowSettingsPtr self) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiPNative.GetName(self.Handle)); + + public static ReadOnlySpan GetTabNameU8(this ImGuiTabBarPtr self, ImGuiTabItemPtr tab) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiPNative.GetTabName(self.Handle, tab.Handle)); + + public static ReadOnlySpan GetNavInputNameU8(this ImGuiNavInput n) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiPNative.GetNavInputName(n)); + + public static ReadOnlySpan TableGetColumnNameU8(this ImGuiTablePtr table, int columnN) => + MemoryMarshal.CreateReadOnlySpanFromNullTerminated(ImGuiPNative.TableGetColumnName(table.Handle, columnN)); + + public static ReadOnlySpan GetNameU8(this in ImGuiWindowSettings self) + { + fixed (ImGuiWindowSettings* selfPtr = &self) + return GetNameU8(selfPtr); + } + + public static ReadOnlySpan GetTabNameU8(ImGuiTabBarPtr self, in ImGuiTabItem tab) + { + fixed (ImGuiTabItem* tabPtr = &tab) + return GetTabNameU8(self, tabPtr); + } + + public static ReadOnlySpan GetTabNameU8(this in ImGuiTabBar self, ImGuiTabItemPtr tab) + { + fixed (ImGuiTabBar* selfPtr = &self) + return GetTabNameU8(selfPtr, tab); + } + + public static ReadOnlySpan GetTabNameU8(this in ImGuiTabBar self, in ImGuiTabItem tab) + { + fixed (ImGuiTabBar* selfPtr = &self) + fixed (ImGuiTabItem* tabPtr = &tab) + return GetTabNameU8(selfPtr, tabPtr); + } + + public static ReadOnlySpan TableGetColumnNameU8(this in ImGuiTable table, int columnN) + { + fixed (ImGuiTable* tablePtr = &table) + return TableGetColumnNameU8(tablePtr, columnN); + } + + public static string GetName(this ImGuiWindowSettingsPtr self) => Encoding.UTF8.GetString(GetNameU8(self)); + + public static string GetTabName(this ImGuiTabBarPtr self, ImGuiTabItemPtr tab) => + Encoding.UTF8.GetString(GetTabNameU8(self, tab)); + + public static string GetTabName(this ImGuiTabBarPtr self, in ImGuiTabItem tab) => + Encoding.UTF8.GetString(GetTabNameU8(self, tab)); + + public static string GetNavInputName(this ImGuiNavInput n) => Encoding.UTF8.GetString(GetNavInputNameU8(n)); + + public static string TableGetColumnName(this ImGuiTablePtr table, int columnN) => + Encoding.UTF8.GetString(TableGetColumnNameU8(table, columnN)); + + public static string GetName(this in ImGuiWindowSettings self) => Encoding.UTF8.GetString(GetNameU8(self)); + + public static string GetTabName(this in ImGuiTabBar self, ImGuiTabItemPtr tab) => + Encoding.UTF8.GetString(GetTabNameU8(self, tab)); + + public static string GetTabName(this in ImGuiTabBar self, in ImGuiTabItem tab) => + Encoding.UTF8.GetString(GetTabNameU8(self, tab)); + + public static string TableGetColumnName(this in ImGuiTable table, int columnN) => + Encoding.UTF8.GetString(TableGetColumnNameU8(table, columnN)); +} diff --git a/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiTextBuffer.Custom.cs b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiTextBuffer.Custom.cs index a8633d5ae..49a1abbe4 100644 --- a/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiTextBuffer.Custom.cs +++ b/imgui/Dalamud.Bindings.ImGui/Custom/ImGuiTextBuffer.Custom.cs @@ -1,7 +1,14 @@ +using System.Runtime.CompilerServices; +using System.Text; + namespace Dalamud.Bindings.ImGui; public unsafe partial struct ImGuiTextBuffer { + public readonly Span Span => new(this.Buf.Data, this.Buf.Size); + + public override readonly string ToString() => Encoding.UTF8.GetString(this.Span); + public void append(ImU8String str) { fixed (ImGuiTextBuffer* thisPtr = &this) @@ -9,7 +16,11 @@ public unsafe partial struct ImGuiTextBuffer } } -public partial struct ImGuiTextBufferPtr +public unsafe partial struct ImGuiTextBufferPtr { + public readonly Span Span => new(Unsafe.AsRef(in this).Buf.Data, Unsafe.AsRef(in this).Buf.Size); + + public override readonly string ToString() => Encoding.UTF8.GetString(this.Span); + public void append(ImU8String str) => ImGui.append(this, str); }