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

Mutable struct build #22

Closed
wants to merge 1 commit into from
Closed

Mutable struct build #22

wants to merge 1 commit into from

Conversation

JFronny
Copy link
Contributor

@JFronny JFronny commented Dec 12, 2022

While attempting to implement #20, I noticed that the java-gtk implementation for this updates callbacks in existing fields.
In java-gi, it seems like a Build instance is required to mutate these, which is why this PR allows creating a Build instance of an existing object.
Another problem I came across is the fact that callbacks are represented as raw MemoryAddress instances instead of lambda types, but I don't know how to fix that.

@jwharm
Copy link
Owner

jwharm commented Dec 12, 2022

Those callbacks don’t work with lambdas because a user_data field is required for lambdas. I’m currently working on a fix in a separate branch, but that will take some more time.

@jwharm
Copy link
Owner

jwharm commented Dec 12, 2022

I think the best way to update callback fields, is to generate a field$set() method for callback-fields. Just remove this check from Record.java around line 79:

        // Don't try to generate a setter for callbacks
        if (type.isCallback()) {
            return;
        }

The Build class is meant as a construction mechanism (the builder pattern) and it works quite well to quickly instantiate GObjects with properties. However, I went a bit overboard and also added a builder to set struct fields. In hindsight, that was not the best idea. You can merge the PR but I'm not sure the struct builder should stay anyway.

@jwharm
Copy link
Owner

jwharm commented Dec 12, 2022

Regarding #20, that one will be a lot easier to implement once I finish the new implementation of callback handling (#15).

@JFronny JFronny closed this Dec 16, 2022
@JFronny JFronny deleted the mutable-struct-build branch December 16, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants