Repository navigation
Allow passing Unsafe.NullRef<bool>() for nullable bool* parameters - #535
Open
armadavalor wants to merge 1 commit into
Open
armadavalor wants to merge 1 commit into
armadavalor wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated wrappers that take a
ref boolfor a nativebool*(such asp_openinBeginTabItem,Begin,CollapsingHeader,BeginPopupModal) always dereference the ref. Passingref Unsafe.NullRef<bool>()either crashes with aNullReferenceExceptionor never hands a null pointer to cimgui, so there is no way to get the native "no close button" behaviour through theref booloverloads.This change makes the code generator check
Unsafe.IsNullReffirst. If the ref is null,nullis passed to the native function and nothing is written back. Otherwise the behaviour is the same as before. The ref is only read inside the branch; with the value folded into a single&&expression, the JIT could still load it unconditionally and fault.The generated files for ImGui.NET, ImPlot.NET and ImNodes.NET are regenerated with the updated generator. ImGuizmo has no
bool*parameters and is unchanged. Only thebool*marshalling blocks change; the rest of the regenerated output was left as it is in master.Tested on win-x64 with the bundled cimgui (Debug and Release):
BeginTabItem("a", ref Unsafe.NullRef<bool>(), ...)now shows the tab,ref falsestill hides it, andref truestaystrue.Closes #495