Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading Guide: 1.79 to 1.82 #96

Open
Gnimuc opened this issue Sep 23, 2023 · 0 comments
Open

Upgrading Guide: 1.79 to 1.82 #96

Gnimuc opened this issue Sep 23, 2023 · 0 comments
Labels

Comments

@Gnimuc
Copy link
Member

Gnimuc commented Sep 23, 2023

Functions that return an object in 1.79 will return Ptr type in 1.82, please use unsafe_load to explicitly copy the object in your old code base.

For example, igGetIO() returns a pointer of type Ptr{ImGuiIO} in 1.82.

With this field access method in 1.79, say we have io::Ptr{ImGuiIO}=igGetIO(), then we can run ds = io.DisplaySize to get an object ds of type ImVec2.

The new field access method generated by Clang.jl now returns a pointer(in the above example, Ptr{ImVec2}) instead of an object(in the above example, ImVec2).

We are making this change because we want a small memory footprint and chaining support:

io.DisplaySize.x will now return a pointer and we can explicitly write unsafe_load(io.DisplaySize.x) to copy the value. In this case, only the value x is copied from C to Julia, not the whole object io.DisplaySize.

In 1.82, it will be a lot easier to read/load/copy a single value from a big nested struct without copying the whole struct object from C to Julia.

@Gnimuc Gnimuc pinned this issue Sep 23, 2023
@Gnimuc Gnimuc added the doc label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant