Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ImGuiTestEngine"
uuid = "464e2eba-0a11-4ed3-b274-413caa1a1cca"
authors = ["JamesWrigley <james@puiterwijk.org>"]
version = "1.0.3"
version = "1.0.4"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to update the changelog entry for the new release.


[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -14,7 +14,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[compat]
CEnum = "0.5.0"
CImGui = "8"
CImGuiPack_jll = "0.12.1"
CImGuiPack_jll = "0.12.2"
DocStringExtensions = "0.9.3"
ScopedValues = "1.2.1"
Test = "1"
Expand Down
165 changes: 104 additions & 61 deletions lib/i686-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,39 +247,75 @@ end


struct ImGuiTestItemInfo
ID::Cuint
DebugLabel::NTuple{32, Cchar}
Window::Ptr{ImGuiWindow}
NavLayer::Cuint
Depth::Cint
TimestampMain::Cint
TimestampStatus::Cint
ParentID::Cuint
RectFull::ImRect
RectClipped::ImRect
ItemFlags::Cint
StatusFlags::Cint
data::NTuple{96, UInt8}
end

function Base.getproperty(x::Ptr{ImGuiTestItemInfo}, f::Symbol)
f === :ID && return Ptr{Cuint}(x + 0)
f === :DebugLabel && return Ptr{NTuple{32, Cchar}}(x + 4)
f === :Window && return Ptr{Ptr{ImGuiWindow}}(x + 36)
f === :NavLayer && return Ptr{Cuint}(x + 40)
f === :Depth && return Ptr{Cint}(x + 44)
f === :TimestampMain && return Ptr{Cint}(x + 48)
f === :TimestampStatus && return Ptr{Cint}(x + 52)
f === :ParentID && return Ptr{Cuint}(x + 56)
f === :RectFull && return Ptr{ImRect}(x + 60)
f === :RectClipped && return Ptr{ImRect}(x + 76)
f === :ItemFlags && return Ptr{Cint}(x + 92)
f === :StatusFlags && return Ptr{Cint}(x + 96)
f === :NavLayer && return (Ptr{Cuint}(x + 40), 0, 1)
f === :Depth && return (Ptr{Cint}(x + 40), 1, 16)
f === :TimestampMain && return Ptr{Cint}(x + 44)
f === :TimestampStatus && return Ptr{Cint}(x + 48)
f === :ParentID && return Ptr{Cuint}(x + 52)
f === :RectFull && return Ptr{ImRect}(x + 56)
f === :RectClipped && return Ptr{ImRect}(x + 72)
f === :ItemFlags && return Ptr{Cint}(x + 88)
f === :StatusFlags && return Ptr{Cint}(x + 92)
return getfield(x, f)
end

function Base.getproperty(x::ImGuiTestItemInfo, f::Symbol)
r = Ref{ImGuiTestItemInfo}(x)
ptr = Base.unsafe_convert(Ptr{ImGuiTestItemInfo}, r)
fptr = getproperty(ptr, f)
begin
if fptr isa Ptr
return GC.@preserve(r, unsafe_load(fptr))
else
(baseptr, offset, width) = fptr
ty = eltype(baseptr)
baseptr32 = convert(Ptr{UInt32}, baseptr)
u64 = GC.@preserve(r, unsafe_load(baseptr32))
if offset + width > 32
u64 |= GC.@preserve(r, unsafe_load(baseptr32 + 4)) << 32
end
u64 = u64 >> offset & (1 << width - 1)
return u64 % ty
end
end
end

function Base.setproperty!(x::Ptr{ImGuiTestItemInfo}, f::Symbol, v)
unsafe_store!(getproperty(x, f), v)
fptr = getproperty(x, f)
if fptr isa Ptr
unsafe_store!(getproperty(x, f), v)
else
(baseptr, offset, width) = fptr
baseptr32 = convert(Ptr{UInt32}, baseptr)
u64 = unsafe_load(baseptr32)
straddle = offset + width > 32
if straddle
u64 |= unsafe_load(baseptr32 + 4) << 32
end
mask = 1 << width - 1
u64 &= ~(mask << offset)
u64 |= (unsigned(v) & mask) << offset
unsafe_store!(baseptr32, u64 & typemax(UInt32))
if straddle
unsafe_store!(baseptr32 + 4, u64 >> 32)
end
end
end

function Base.propertynames(x::ImGuiTestItemInfo, private::Bool = false)
(:ID, :DebugLabel, :Window, :NavLayer, :Depth, :TimestampMain, :TimestampStatus, :ParentID, :RectFull, :RectClipped, :ItemFlags, :StatusFlags, if private
fieldnames(typeof(x))
else
()
end...)
end

struct ImVector_ImGuiTestItemInfo
Size::Cint
Expand Down Expand Up @@ -439,7 +475,7 @@ struct ImGuiTestGenericItemStatus
DeactivatedAfterEdit::Cint
end

struct ImGuiTestGenericVars
mutable struct ImGuiTestGenericVars
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this and other structs now mutable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's Clang.jl-generated...

Step::Cint
Count::Cint
DockId::Cuint
Expand Down Expand Up @@ -488,10 +524,34 @@ struct ImVector_ImGuiTestRunTask
end

struct ImGuiTestInfoTask
ID::Cuint
FrameCount::Cint
DebugName::NTuple{64, Cchar}
Result::ImGuiTestItemInfo
data::NTuple{168, UInt8}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

end

function Base.getproperty(x::Ptr{ImGuiTestInfoTask}, f::Symbol)
f === :ID && return Ptr{Cuint}(x + 0)
f === :FrameCount && return Ptr{Cint}(x + 4)
f === :DebugName && return Ptr{NTuple{64, Cchar}}(x + 8)
f === :Result && return Ptr{ImGuiTestItemInfo}(x + 72)
return getfield(x, f)
end

function Base.getproperty(x::ImGuiTestInfoTask, f::Symbol)
r = Ref{ImGuiTestInfoTask}(x)
ptr = Base.unsafe_convert(Ptr{ImGuiTestInfoTask}, r)
fptr = getproperty(ptr, f)
GC.@preserve r unsafe_load(fptr)
end

function Base.setproperty!(x::Ptr{ImGuiTestInfoTask}, f::Symbol, v)
unsafe_store!(getproperty(x, f), v)
end

function Base.propertynames(x::ImGuiTestInfoTask, private::Bool = false)
(:ID, :FrameCount, :DebugName, :Result, if private
fieldnames(typeof(x))
else
()
end...)
end

struct ImVector_ImGuiTestInfoTask_Ptr
Expand Down Expand Up @@ -783,40 +843,9 @@ end
end

struct ImGuiTestContext
GenericVars::ImGuiTestGenericVars
UserVars::Ptr{Cvoid}
UiContext::Ptr{ImGuiContext}
EngineIO::Ptr{ImGuiTestEngineIO}
Test::Ptr{ImGuiTest}
TestOutput::Ptr{ImGuiTestOutput}
OpFlags::Cint
PerfStressAmount::Cint
FrameCount::Cint
FirstTestFrameCount::Cint
FirstGuiFrame::Bool
HasDock::Bool
CaptureArgs::Ptr{ImGuiCaptureArgs}
Engine::Ptr{ImGuiTestEngine}
Inputs::Ptr{ImGuiTestInputs}
RunFlags::Cint
ActiveFunc::ImGuiTestActiveFunc
RunningTime::Cdouble
ActionDepth::Cint
CaptureCounter::Cint
ErrorCounter::Cint
Abort::Bool
PerfRefDt::Cdouble
PerfIterations::Cint
RefStr::NTuple{256, Cchar}
RefID::Cuint
RefWindowID::Cuint
InputMode::ImGuiInputSource
TempString::ImVector_char
Clipboard::ImVector_char
ForeignWindowsToHide::ImVector_ImGuiWindowPtr
DummyItemInfoNull::ImGuiTestItemInfo
CachedLinesPrintedToTTY::Bool
data::NTuple{1312, UInt8}
end

function Base.getproperty(x::Ptr{ImGuiTestContext}, f::Symbol)
f === :GenericVars && return Ptr{ImGuiTestGenericVars}(x + 0)
f === :UserVars && return Ptr{Ptr{Cvoid}}(x + 812)
Expand Down Expand Up @@ -850,14 +879,28 @@ function Base.getproperty(x::Ptr{ImGuiTestContext}, f::Symbol)
f === :Clipboard && return Ptr{ImVector_char}(x + 1188)
f === :ForeignWindowsToHide && return Ptr{ImVector_ImGuiWindowPtr}(x + 1200)
f === :DummyItemInfoNull && return Ptr{ImGuiTestItemInfo}(x + 1212)
f === :CachedLinesPrintedToTTY && return Ptr{Bool}(x + 1312)
f === :CachedLinesPrintedToTTY && return Ptr{Bool}(x + 1308)
return getfield(x, f)
end

function Base.getproperty(x::ImGuiTestContext, f::Symbol)
r = Ref{ImGuiTestContext}(x)
ptr = Base.unsafe_convert(Ptr{ImGuiTestContext}, r)
fptr = getproperty(ptr, f)
GC.@preserve r unsafe_load(fptr)
end

function Base.setproperty!(x::Ptr{ImGuiTestContext}, f::Symbol, v)
unsafe_store!(getproperty(x, f), v)
end

function Base.propertynames(x::ImGuiTestContext, private::Bool = false)
(:GenericVars, :UserVars, :UiContext, :EngineIO, :Test, :TestOutput, :OpFlags, :PerfStressAmount, :FrameCount, :FirstTestFrameCount, :FirstGuiFrame, :HasDock, :CaptureArgs, :Engine, :Inputs, :RunFlags, :ActiveFunc, :RunningTime, :ActionDepth, :CaptureCounter, :ErrorCounter, :Abort, :PerfRefDt, :PerfIterations, :RefStr, :RefID, :RefWindowID, :InputMode, :TempString, :Clipboard, :ForeignWindowsToHide, :DummyItemInfoNull, :CachedLinesPrintedToTTY, if private
fieldnames(typeof(x))
else
()
end...)
end

mutable struct ImBuildInfo
Type::Ptr{Cchar}
Expand Down
Loading
Loading