gir icon indicating copy to clipboard operation
gir copied to clipboard

Panic on GIR not_bound mode for GModule

Open wash2 opened this issue 2 years ago • 4 comments

I'm working on generating bindings to GModule but it panics in not_bound work_mode. I added some debug statements to the point where it was unwrapping, and I've attached the output of each of the failing types:

[WARN  libgir::analysis::functions] Function g_module_symbol has unsupported outs
[WARN  libgir::analysis::functions] Function g_module_open_full has unsupported outs
[ERROR libgir::analysis::record] Missing memory management functions for GModule.Module
[src/library.rs:1091] &tid = TypeId {
    ns_id: 1,
    id: 0,
}
[src/library.rs:1092] &full_name = "GModule.Module"
[src/library.rs:1093] env.library.find_type(0, "GObject.Object") = None
[src/library.rs:1091] &tid = TypeId {
    ns_id: 1,
    id: 1,
}
[src/library.rs:1092] &full_name = "GModule.ModuleFlags"
[src/library.rs:1093] env.library.find_type(0, "GObject.Object") = None
[src/library.rs:1091] &tid = TypeId {
    ns_id: 1,
    id: 2,
}
[src/library.rs:1092] &full_name = "GModule.ModuleCheckInit"
[src/library.rs:1093] env.library.find_type(0, "GObject.Object") = None
[src/library.rs:1091] &tid = TypeId {
    ns_id: 1,
    id: 3,
}
[src/library.rs:1092] &full_name = "GModule.ModuleError"
[src/library.rs:1093] env.library.find_type(0, "GObject.Object") = None
[src/library.rs:1091] &tid = TypeId {
    ns_id: 1,
    id: 4,
}
[src/library.rs:1092] &full_name = "GModule.ModuleUnload"
[src/library.rs:1093] env.library.find_type(0, "GObject.Object") = None

Also, it seems like the generation is failing, partially bc of missing memory management functions and unsupported output.. Does this mean that the safe bindings would all have to be implemented manually, or is it maybe an issue with the GIR file?

[WARN  libgir::analysis::functions] Function g_module_symbol has unsupported outs
[WARN  libgir::analysis::functions] Function g_module_open_full has unsupported outs
[ERROR libgir::analysis::record] Missing memory management functions for GModule.Module
thread 'main' panicked at 'Record Module has record_boxed=true but don't have glib:get_type function', src/codegen/record.rs:31:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

wash2 avatar Dec 29 '21 15:12 wash2

That looks like a duplicate of #1236

bilelmoussaoui avatar Dec 29 '21 15:12 bilelmoussaoui

That looks like a duplicate of #1236

Ok thanks, do you know how difficult of a bug this might be to fix, or where to start working on it? I would be willing to give it a shot.

wash2 avatar Dec 29 '21 15:12 wash2

It shouldn't be hard, you need to modify the code in https://github.com/gtk-rs/gir/blob/master/src/codegen/record.rs#L17-L35 to allow passing a None for the get_type function, and modify this line https://github.com/gtk-rs/gir/blob/master/src/codegen/general.rs#L428 accordingly

bilelmoussaoui avatar Dec 29 '21 15:12 bilelmoussaoui

Alright, thanks!

wash2 avatar Dec 29 '21 15:12 wash2