-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add support of enums as dynamic types #1220
Conversation
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
naive question: why not a |
Do you mean like this ? #[derive(Debug, Copy, Clone, PartialEq, Eq, glib::Enum)]
#[enum_type(name = "MyEnum", dynamic = true, plugin_type = MyPlugin, lazy_registration = true)]
enum MyEnum{...} Goal is to have a clear distinction between "static" enums and "dynamic" ones. With separate helper attributes ( However I realize it might be even more clear: #[derive(Debug, Copy, Clone, PartialEq, Eq, glib::Enum)]
#[enum_type(name = "MyEnum")]
#[dynamic_enum(plugin_type = MyPlugin, lazy_registration = true)]
enum MyEnum{...} instead of: #[derive(Debug, Copy, Clone, PartialEq, Eq, glib::DynamicEnum)]
#[enum_type(name = "MyEnum", plugin_type = MyPlugin, lazy_registration = true)]
enum MyEnum{...} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a lot of code but I also don't see how to simplify that, right now :)
Can you also add the same for flags once we agreed on an API / implementation here?
@bilelmoussaoui What do you think about the API?
@bilelmoussaoui What do you think? |
Sorry for taking so long to review this! |
…amic_enum macro Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
I actually like that. The main concern then is that it's a bit inconsistent with dynamic GObjects and those should ideally be changed similarly. |
maybe should be
so that we follow the convention that we use the |
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
…egistered)" This reverts commit cd7ec87. Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for me. @bilelmoussaoui @pbor last chance :) I'll merge it during the weekend if there are no objections.
…ariables Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
one more thing... Using |
I won't be able to do it before this weekend. Maybe another PR to address it (and also dynamic objects, interfaces) ? |
Let's do that separately, yes. Unless you prefer to wait? Let me know. Otherwise I would merge now |
No, you can merge |
This PR aims to add support of enums registered as dynamic types. See https://docs.gtk.org/gobject/class.TypeModule.html and https://docs.gtk.org/gobject/iface.TypePlugin.html.
The new macro
dynamic_enum_derive
allows to register enums that are part of a module or of a plugin (e.g. a shared library on linux). The macro mimicenum_derive
but generates code that support registration when the plugin (TypePlugin
) is used, following the behavior defined in Glib doc. However it is possible to postpone the registration at first use of the enum (like withinenum_derive
) by explicitly setting the macro attributelazy_registration = true
.Some examples in glib-macros/tests/dynamic_enums.rs