Stream: beginners

Topic: Help with programForHost


view this post on Zulip Luke Boswell (Dec 31 2023 at 04:51):

I'm looking for some assitance with this platform. Basically I am trying to revive the gui example and update it so that it uses glue and works as a standalone platform.

Brendan has provided a lot of assistance, but I'm still not quite there yet and I feel like I'm just spinning my wheels a bit and not making any progress. I'm asking here in the hope that someone is able to also assist me find the issue or get this platform working again.

I've converted the platform to use a Box Model and then represented this with a c_void in the rust host. I have added a script to generate glue and it compiles and runs the init function in Roc without issue. However when I call update or render and pass the model back in I think it segfaults.

I am pretty sure the issue is in my roc.rs where I am hand-rolling the programForHost implementation, and I don't think I am representing the BoxedModel correctly.

I have tried a few different things, but I don't know enough Roc or Rust to find where the issue is.

$ roc dev hello-gui.roc
🔨 Rebuilding platform...
[src/roc.rs:87] size = 0
[src/roc.rs:88] init_size = 0
[src/roc.rs:89] render_size = 0
[src/roc.rs:90] update_size = 0
[src/lib.rs:16] &roc_main = ProgramForHost {
    init: RocFunctionInit {
        closure_data: [],
    },
    render: RocFunctionRender {
        closure_data: [],
    },
    update: RocFunctionUpdate {
        closure_data: [],
    },
}
[hello-gui.roc:18] "INIT CALLED" = "INIT CALLED"

Last updated: Jul 05 2025 at 12:14 UTC