Fix ItemInfo struct layout (ImGuiTestItemInfo bitfields)#22
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22 +/- ##
==========================================
+ Coverage 28.22% 28.75% +0.52%
==========================================
Files 5 5
Lines 960 960
==========================================
+ Hits 271 276 +5
+ Misses 689 684 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| end | ||
|
|
||
| struct ImGuiTestGenericVars | ||
| mutable struct ImGuiTestGenericVars |
There was a problem hiding this comment.
Why is this and other structs now mutable?
There was a problem hiding this comment.
I think it's Clang.jl-generated...
| uuid = "464e2eba-0a11-4ed3-b274-413caa1a1cca" | ||
| authors = ["JamesWrigley <james@puiterwijk.org>"] | ||
| version = "1.0.3" | ||
| version = "1.0.4" |
There was a problem hiding this comment.
Also need to update the changelog entry for the new release.
| # te.ItemInfo and ig.GetItemRectMin/Max query the same widget, so their | ||
| # rects must agree. A mismatch means the ImGuiTestItemInfo binding's field | ||
| # offsets disagree with the compiled C++ struct (packed NavLayer:1 / Depth:16). | ||
| @test sizeof(lib.ImGuiTestItemInfo) == 104 |
There was a problem hiding this comment.
I would not put this in a test, it's way too easy to break in new versions of the test engine.
| FrameCount::Cint | ||
| DebugName::NTuple{64, Cchar} | ||
| Result::ImGuiTestItemInfo | ||
| data::NTuple{168, UInt8} |
There was a problem hiding this comment.
Somehow it seems odd to me that a struct containing bitfield structs as fields itself gets treated as a bitfield struct by Clang 🤔 @Gnimuc, do you know if that's right? It looks like it calculates the offsets correctly and everything, I just don't know if it's actually needed.
te.ItemInfo(...)returned wrongRectFull/flags:ImGuiTestItemInfowas read with the wrong field offsets because the C++ struct packsNavLayer : 1/Depth : 16bitfields, making it 104 bytes (the binding assumed 112). Every field from offset 48 on was shifted, soRectFullwas read 4 bytes off.Regenerated against
CImGuiPack_jll0.12.2 (whosecimgui_te.hnow carries the bitfields) → correct 104-byteImGuiTestItemInfo, and the structs that embed it by value (ImGuiTestContext,ImGuiTestInfoTask) get the matching opaque layout. Adds a struct-layout regression test comparingte.ItemInfo(...).RectFulltoig.GetItemRectMin/Maxfor the same widget.