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

Support for dynamic types #55

Closed
shutton opened this issue Mar 16, 2020 · 9 comments
Closed

Support for dynamic types #55

shutton opened this issue Mar 16, 2020 · 9 comments
Labels
enhancement New feature or request glib

Comments

@shutton
Copy link

shutton commented Mar 16, 2020

glib_wrapper! doesn't appear to have any support for dynamic types (types that become available after being loaded from a dynamic library)

https://developer.gnome.org/gobject/2.64/GTypeModule.html#G-DEFINE-DYNAMIC-TYPE:CAPS

@sdroege
Copy link
Member

sdroege commented Mar 16, 2020

What's your use-case? glib_wrapper should handle these just fine, but there's no subclassing support for dynamic types yet.

@shutton
Copy link
Author

shutton commented Mar 16, 2020

Subclassing 😔

In my particular case, things go sideways when you call g_type_get_plugin() on a instance of a subclass (in C land).

@sdroege
Copy link
Member

sdroege commented Mar 16, 2020

For usage with a specific library or ...?

But if you have any suggestions how that could look like API-wise that would be useful. I'm mostly worried about the safety aspects here (unloading code is unsafe), that needs some thinking.

Apart from that this should in theory only require adding bindings for GTypePlugin (probably can be at least partially autogenerated) and then a new register() function in src/subclass/types.rs that does the dynamic registration instead.

@sdroege
Copy link
Member

sdroege commented Mar 16, 2020

In my particular case, things go sideways when you call g_type_get_plugin() on a instance of a subclass (in C land).

That should only return NULL but otherwise should not cause any other problems. What happens?

@shutton
Copy link
Author

shutton commented Mar 16, 2020

It does return NULL. Alas, it's a part of a [proprietary] system that uses that object for further introspection on the loaded library (namely, plucking out some exported symbols). It's something that can be worked around, but full support obviously isn't quite there yet.

@sdroege
Copy link
Member

sdroege commented Mar 16, 2020

Apart from the safety aspects this shouldn't be too hard to implement in any case, see above if you're interested in working on that :)

@shutton
Copy link
Author

shutton commented Mar 16, 2020

Quite possibly, but I'm still a Rust novice, so it might be a bit 😉

@sdroege
Copy link
Member

sdroege commented Mar 16, 2020

Sure, feel free to ask here if you need some help :)

@sdroege sdroege transferred this issue from gtk-rs/glib Nov 9, 2020
elmarco referenced this issue in elmarco/gtk-rs Feb 10, 2021
@GuillaumeGomez GuillaumeGomez transferred this issue from gtk-rs/gtk3-rs May 14, 2021
@sdroege sdroege added enhancement New feature or request glib labels May 18, 2021
@sdroege
Copy link
Member

sdroege commented Oct 31, 2023

See #1169

@sdroege sdroege closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request glib
Projects
None yet
Development

No branches or pull requests

2 participants