From 97626cd9de9a92be8e8d968fc7663bd14e3c9bb8 Mon Sep 17 00:00:00 2001 From: armadavalor Date: Mon, 2 Nov 2026 00:19:46 +0300 Subject: [PATCH] Allow Unsafe.NullRef() to be passed as a null bool pointer --- src/CodeGenerator/Program.cs | 13 +- src/ImGui.NET/Generated/ImGui.gen.cs | 363 ++++++++++++++++------- src/ImNodes.NET/Generated/ImNodes.gen.cs | 22 +- src/ImPlot.NET/Generated/ImPlot.gen.cs | 22 +- 4 files changed, 306 insertions(+), 114 deletions(-) diff --git a/src/CodeGenerator/Program.cs b/src/CodeGenerator/Program.cs index 8597a718..49c4c12f 100644 --- a/src/CodeGenerator/Program.cs +++ b/src/CodeGenerator/Program.cs @@ -628,9 +628,16 @@ private static void EmitOverload( { string nativeArgName = "native_" + tr.Name; marshalledParameters[i] = new MarshalledParameter("ref bool", false, nativeArgName, false); - preCallLines.Add($"byte {nativeArgName}_val = {correctedIdentifier} ? (byte)1 : (byte)0;"); - preCallLines.Add($"byte* {nativeArgName} = &{nativeArgName}_val;"); - postCallLines.Add($"{correctedIdentifier} = {nativeArgName}_val != 0;"); + // Allow Unsafe.NullRef() to be passed through as a null pointer. + // The ref must only be read inside the branch, otherwise the JIT may load it unconditionally. + preCallLines.Add($"byte {nativeArgName}_val = 0;"); + preCallLines.Add($"byte* {nativeArgName} = null;"); + preCallLines.Add($"if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref {correctedIdentifier}))"); + preCallLines.Add("{"); + preCallLines.Add($" {nativeArgName}_val = {correctedIdentifier} ? (byte)1 : (byte)0;"); + preCallLines.Add($" {nativeArgName} = &{nativeArgName}_val;"); + preCallLines.Add("}"); + postCallLines.Add($"if ({nativeArgName} != null) {{ {correctedIdentifier} = {nativeArgName}_val != 0; }}"); } else if (tr.Type == "void*" || tr.Type == "ImWchar*") { diff --git a/src/ImGui.NET/Generated/ImGui.gen.cs b/src/ImGui.NET/Generated/ImGui.gen.cs index 94bce8d0..700c3a25 100644 --- a/src/ImGui.NET/Generated/ImGui.gen.cs +++ b/src/ImGui.NET/Generated/ImGui.gen.cs @@ -262,15 +262,20 @@ public static bool Begin(ReadOnlySpan name, ref bool p_open) native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiWindowFlags flags = (ImGuiWindowFlags)0; byte ret = ImGuiNative.igBegin(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -294,15 +299,20 @@ public static bool Begin(string name, ref bool p_open) native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiWindowFlags flags = (ImGuiWindowFlags)0; byte ret = ImGuiNative.igBegin(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -326,14 +336,19 @@ public static bool Begin(ReadOnlySpan name, ref bool p_open, ImGuiWindowFl native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBegin(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -357,14 +372,19 @@ public static bool Begin(string name, ref bool p_open, ImGuiWindowFlags flags) native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBegin(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -1682,15 +1702,20 @@ public static bool BeginPopupModal(ReadOnlySpan name, ref bool p_open) native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiWindowFlags flags = (ImGuiWindowFlags)0; byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -1714,15 +1739,20 @@ public static bool BeginPopupModal(string name, ref bool p_open) native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiWindowFlags flags = (ImGuiWindowFlags)0; byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -1746,14 +1776,19 @@ public static bool BeginPopupModal(ReadOnlySpan name, ref bool p_open, ImG native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -1777,14 +1812,19 @@ public static bool BeginPopupModal(string name, ref bool p_open, ImGuiWindowFlag native_name[native_name_offset] = 0; } else { native_name = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBeginPopupModal(native_name, native_p_open, flags); if (name_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_name); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -1982,15 +2022,20 @@ public static bool BeginTabItem(ReadOnlySpan label, ref bool p_open) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiTabItemFlags flags = (ImGuiTabItemFlags)0; byte ret = ImGuiNative.igBeginTabItem(native_label, native_p_open, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -2014,15 +2059,20 @@ public static bool BeginTabItem(string label, ref bool p_open) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiTabItemFlags flags = (ImGuiTabItemFlags)0; byte ret = ImGuiNative.igBeginTabItem(native_label, native_p_open, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -2046,14 +2096,19 @@ public static bool BeginTabItem(ReadOnlySpan label, ref bool p_open, ImGui native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBeginTabItem(native_label, native_p_open, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #endif @@ -2077,14 +2132,19 @@ public static bool BeginTabItem(string label, ref bool p_open, ImGuiTabItemFlags native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } byte ret = ImGuiNative.igBeginTabItem(native_label, native_p_open, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -2710,14 +2770,19 @@ public static bool Checkbox(ReadOnlySpan label, ref bool v) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_v_val = v ? (byte)1 : (byte)0; - byte* native_v = &native_v_val; + byte native_v_val = 0; + byte* native_v = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref v)) + { + native_v_val = v ? (byte)1 : (byte)0; + native_v = &native_v_val; + } byte ret = ImGuiNative.igCheckbox(native_label, native_v); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - v = native_v_val != 0; + if (native_v != null) { v = native_v_val != 0; } return ret != 0; } #endif @@ -2741,14 +2806,19 @@ public static bool Checkbox(string label, ref bool v) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_v_val = v ? (byte)1 : (byte)0; - byte* native_v = &native_v_val; + byte native_v_val = 0; + byte* native_v = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref v)) + { + native_v_val = v ? (byte)1 : (byte)0; + native_v = &native_v_val; + } byte ret = ImGuiNative.igCheckbox(native_label, native_v); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - v = native_v_val != 0; + if (native_v != null) { v = native_v_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -3014,15 +3084,20 @@ public static bool CollapsingHeader(ReadOnlySpan label, ref bool p_visible native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_visible_val = p_visible ? (byte)1 : (byte)0; - byte* native_p_visible = &native_p_visible_val; + byte native_p_visible_val = 0; + byte* native_p_visible = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_visible)) + { + native_p_visible_val = p_visible ? (byte)1 : (byte)0; + native_p_visible = &native_p_visible_val; + } ImGuiTreeNodeFlags flags = (ImGuiTreeNodeFlags)0; byte ret = ImGuiNative.igCollapsingHeader_BoolPtr(native_label, native_p_visible, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_visible = native_p_visible_val != 0; + if (native_p_visible != null) { p_visible = native_p_visible_val != 0; } return ret != 0; } #endif @@ -3046,15 +3121,20 @@ public static bool CollapsingHeader(string label, ref bool p_visible) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_visible_val = p_visible ? (byte)1 : (byte)0; - byte* native_p_visible = &native_p_visible_val; + byte native_p_visible_val = 0; + byte* native_p_visible = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_visible)) + { + native_p_visible_val = p_visible ? (byte)1 : (byte)0; + native_p_visible = &native_p_visible_val; + } ImGuiTreeNodeFlags flags = (ImGuiTreeNodeFlags)0; byte ret = ImGuiNative.igCollapsingHeader_BoolPtr(native_label, native_p_visible, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_visible = native_p_visible_val != 0; + if (native_p_visible != null) { p_visible = native_p_visible_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -3078,14 +3158,19 @@ public static bool CollapsingHeader(ReadOnlySpan label, ref bool p_visible native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_visible_val = p_visible ? (byte)1 : (byte)0; - byte* native_p_visible = &native_p_visible_val; + byte native_p_visible_val = 0; + byte* native_p_visible = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_visible)) + { + native_p_visible_val = p_visible ? (byte)1 : (byte)0; + native_p_visible = &native_p_visible_val; + } byte ret = ImGuiNative.igCollapsingHeader_BoolPtr(native_label, native_p_visible, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_visible = native_p_visible_val != 0; + if (native_p_visible != null) { p_visible = native_p_visible_val != 0; } return ret != 0; } #endif @@ -3109,14 +3194,19 @@ public static bool CollapsingHeader(string label, ref bool p_visible, ImGuiTreeN native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_visible_val = p_visible ? (byte)1 : (byte)0; - byte* native_p_visible = &native_p_visible_val; + byte native_p_visible_val = 0; + byte* native_p_visible = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_visible)) + { + native_p_visible_val = p_visible ? (byte)1 : (byte)0; + native_p_visible = &native_p_visible_val; + } byte ret = ImGuiNative.igCollapsingHeader_BoolPtr(native_label, native_p_visible, flags); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_visible = native_p_visible_val != 0; + if (native_p_visible != null) { p_visible = native_p_visible_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -18265,8 +18355,13 @@ public static bool MenuItem(ReadOnlySpan label, ReadOnlySpan shortcu native_shortcut[native_shortcut_offset] = 0; } else { native_shortcut = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte enabled = 1; byte ret = ImGuiNative.igMenuItem_BoolPtr(native_label, native_shortcut, native_p_selected, enabled); if (label_byteCount > Util.StackAllocationSizeLimit) @@ -18277,7 +18372,7 @@ public static bool MenuItem(ReadOnlySpan label, ReadOnlySpan shortcu { Util.Free(native_shortcut); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #endif @@ -18319,8 +18414,13 @@ public static bool MenuItem(string label, string shortcut, ref bool p_selected) native_shortcut[native_shortcut_offset] = 0; } else { native_shortcut = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte enabled = 1; byte ret = ImGuiNative.igMenuItem_BoolPtr(native_label, native_shortcut, native_p_selected, enabled); if (label_byteCount > Util.StackAllocationSizeLimit) @@ -18331,7 +18431,7 @@ public static bool MenuItem(string label, string shortcut, ref bool p_selected) { Util.Free(native_shortcut); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -18373,8 +18473,13 @@ public static bool MenuItem(ReadOnlySpan label, ReadOnlySpan shortcu native_shortcut[native_shortcut_offset] = 0; } else { native_shortcut = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte native_enabled = enabled ? (byte)1 : (byte)0; byte ret = ImGuiNative.igMenuItem_BoolPtr(native_label, native_shortcut, native_p_selected, native_enabled); if (label_byteCount > Util.StackAllocationSizeLimit) @@ -18385,7 +18490,7 @@ public static bool MenuItem(ReadOnlySpan label, ReadOnlySpan shortcu { Util.Free(native_shortcut); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #endif @@ -18427,8 +18532,13 @@ public static bool MenuItem(string label, string shortcut, ref bool p_selected, native_shortcut[native_shortcut_offset] = 0; } else { native_shortcut = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte native_enabled = enabled ? (byte)1 : (byte)0; byte ret = ImGuiNative.igMenuItem_BoolPtr(native_label, native_shortcut, native_p_selected, native_enabled); if (label_byteCount > Util.StackAllocationSizeLimit) @@ -18439,7 +18549,7 @@ public static bool MenuItem(string label, string shortcut, ref bool p_selected, { Util.Free(native_shortcut); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } public static void NewFrame() @@ -20772,8 +20882,13 @@ public static bool Selectable(ReadOnlySpan label, ref bool p_selected) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } ImGuiSelectableFlags flags = (ImGuiSelectableFlags)0; Vector2 size = new Vector2(); byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); @@ -20781,7 +20896,7 @@ public static bool Selectable(ReadOnlySpan label, ref bool p_selected) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #endif @@ -20805,8 +20920,13 @@ public static bool Selectable(string label, ref bool p_selected) native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } ImGuiSelectableFlags flags = (ImGuiSelectableFlags)0; Vector2 size = new Vector2(); byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); @@ -20814,7 +20934,7 @@ public static bool Selectable(string label, ref bool p_selected) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -20838,15 +20958,20 @@ public static bool Selectable(ReadOnlySpan label, ref bool p_selected, ImG native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } Vector2 size = new Vector2(); byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #endif @@ -20870,15 +20995,20 @@ public static bool Selectable(string label, ref bool p_selected, ImGuiSelectable native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } Vector2 size = new Vector2(); byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER @@ -20902,14 +21032,19 @@ public static bool Selectable(ReadOnlySpan label, ref bool p_selected, ImG native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } #endif @@ -20933,14 +21068,19 @@ public static bool Selectable(string label, ref bool p_selected, ImGuiSelectable native_label[native_label_offset] = 0; } else { native_label = null; } - byte native_p_selected_val = p_selected ? (byte)1 : (byte)0; - byte* native_p_selected = &native_p_selected_val; + byte native_p_selected_val = 0; + byte* native_p_selected = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_selected)) + { + native_p_selected_val = p_selected ? (byte)1 : (byte)0; + native_p_selected = &native_p_selected_val; + } byte ret = ImGuiNative.igSelectable_BoolPtr(native_label, native_p_selected, flags, size); if (label_byteCount > Util.StackAllocationSizeLimit) { Util.Free(native_label); } - p_selected = native_p_selected_val != 0; + if (native_p_selected != null) { p_selected = native_p_selected_val != 0; } return ret != 0; } public static void Separator() @@ -22026,10 +22166,15 @@ public static void ShowAboutWindow() } public static void ShowAboutWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiNative.igShowAboutWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } public static void ShowDebugLogWindow() { @@ -22038,10 +22183,15 @@ public static void ShowDebugLogWindow() } public static void ShowDebugLogWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiNative.igShowDebugLogWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } public static void ShowDemoWindow() { @@ -22050,10 +22200,15 @@ public static void ShowDemoWindow() } public static void ShowDemoWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiNative.igShowDemoWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER public static void ShowFontSelector(ReadOnlySpan label) @@ -22116,10 +22271,15 @@ public static void ShowIDStackToolWindow() } public static void ShowIDStackToolWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiNative.igShowIDStackToolWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } public static void ShowMetricsWindow() { @@ -22128,10 +22288,15 @@ public static void ShowMetricsWindow() } public static void ShowMetricsWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImGuiNative.igShowMetricsWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } public static void ShowStyleEditor() { diff --git a/src/ImNodes.NET/Generated/ImNodes.gen.cs b/src/ImNodes.NET/Generated/ImNodes.gen.cs index 89e9b4fc..19f12ffe 100644 --- a/src/ImNodes.NET/Generated/ImNodes.gen.cs +++ b/src/ImNodes.NET/Generated/ImNodes.gen.cs @@ -191,14 +191,19 @@ public static bool IsLinkCreated(ref int started_at_attribute_id, ref int ended_ } public static bool IsLinkCreated(ref int started_at_attribute_id, ref int ended_at_attribute_id, ref bool created_from_snap) { - byte native_created_from_snap_val = created_from_snap ? (byte)1 : (byte)0; - byte* native_created_from_snap = &native_created_from_snap_val; + byte native_created_from_snap_val = 0; + byte* native_created_from_snap = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref created_from_snap)) + { + native_created_from_snap_val = created_from_snap ? (byte)1 : (byte)0; + native_created_from_snap = &native_created_from_snap_val; + } fixed (int* native_started_at_attribute_id = &started_at_attribute_id) { fixed (int* native_ended_at_attribute_id = &ended_at_attribute_id) { byte ret = imnodesNative.imnodes_IsLinkCreatedBoolPtr(native_started_at_attribute_id, native_ended_at_attribute_id, native_created_from_snap); - created_from_snap = native_created_from_snap_val != 0; + if (native_created_from_snap != null) { created_from_snap = native_created_from_snap_val != 0; } return ret != 0; } } @@ -223,8 +228,13 @@ public static bool IsLinkCreated(ref int started_at_node_id, ref int started_at_ } public static bool IsLinkCreated(ref int started_at_node_id, ref int started_at_attribute_id, ref int ended_at_node_id, ref int ended_at_attribute_id, ref bool created_from_snap) { - byte native_created_from_snap_val = created_from_snap ? (byte)1 : (byte)0; - byte* native_created_from_snap = &native_created_from_snap_val; + byte native_created_from_snap_val = 0; + byte* native_created_from_snap = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref created_from_snap)) + { + native_created_from_snap_val = created_from_snap ? (byte)1 : (byte)0; + native_created_from_snap = &native_created_from_snap_val; + } fixed (int* native_started_at_node_id = &started_at_node_id) { fixed (int* native_started_at_attribute_id = &started_at_attribute_id) @@ -234,7 +244,7 @@ public static bool IsLinkCreated(ref int started_at_node_id, ref int started_at_ fixed (int* native_ended_at_attribute_id = &ended_at_attribute_id) { byte ret = imnodesNative.imnodes_IsLinkCreatedIntPtr(native_started_at_node_id, native_started_at_attribute_id, native_ended_at_node_id, native_ended_at_attribute_id, native_created_from_snap); - created_from_snap = native_created_from_snap_val != 0; + if (native_created_from_snap != null) { created_from_snap = native_created_from_snap_val != 0; } return ret != 0; } } diff --git a/src/ImPlot.NET/Generated/ImPlot.gen.cs b/src/ImPlot.NET/Generated/ImPlot.gen.cs index cb0ba801..81fa758d 100644 --- a/src/ImPlot.NET/Generated/ImPlot.gen.cs +++ b/src/ImPlot.NET/Generated/ImPlot.gen.cs @@ -81853,10 +81853,15 @@ public static void ShowDemoWindow() } public static void ShowDemoWindow(ref bool p_open) { - byte native_p_open_val = p_open ? (byte)1 : (byte)0; - byte* native_p_open = &native_p_open_val; + byte native_p_open_val = 0; + byte* native_p_open = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_open)) + { + native_p_open_val = p_open ? (byte)1 : (byte)0; + native_p_open = &native_p_open_val; + } ImPlotNative.ImPlot_ShowDemoWindow(native_p_open); - p_open = native_p_open_val != 0; + if (native_p_open != null) { p_open = native_p_open_val != 0; } } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER public static bool ShowInputMapSelector(ReadOnlySpan label) @@ -81921,10 +81926,15 @@ public static void ShowMetricsWindow() } public static void ShowMetricsWindow(ref bool p_popen) { - byte native_p_popen_val = p_popen ? (byte)1 : (byte)0; - byte* native_p_popen = &native_p_popen_val; + byte native_p_popen_val = 0; + byte* native_p_popen = null; + if (!System.Runtime.CompilerServices.Unsafe.IsNullRef(ref p_popen)) + { + native_p_popen_val = p_popen ? (byte)1 : (byte)0; + native_p_popen = &native_p_popen_val; + } ImPlotNative.ImPlot_ShowMetricsWindow(native_p_popen); - p_popen = native_p_popen_val != 0; + if (native_p_popen != null) { p_popen = native_p_popen_val != 0; } } public static void ShowStyleEditor() {