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 flags registered as dynamic types #1271
Conversation
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
…ues to use EnumerationValuesStorages<E>/EnumerationValues<E> Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
30ac7f1
to
8d3ac91
Compare
impl<E: EnumerationValue<E>, const S: usize> EnumerationValuesStorage<E, S> { | ||
// rustdoc-stripper-ignore-next | ||
/// creates a new `EnumerationValuesStorage` with the given values and a final zero value. | ||
pub const fn new<const N: usize>(values: [E; N]) -> Self { |
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.
This fails compiling if N + 1 != S
, right?
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.
yes, e.g. if S = N = 3
, it fails with:
error[E0308]: mismatched types
...
= note: expected array `[FlagsValue; 4]`
found array `[FlagsValue; 3]`
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.
Looks good to me otherwise. Thanks!
@pbor @bilelmoussaoui what do you think?
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.
It is consistent with all that was already added by @fbrouille for enums etc, so I am good with getting this in
This PR aims to add support of flags 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
flags_dynamic
allows to register the flags that are part of a module or of a plugin (e.g. a shared library on linux). This helper macro 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 flags by explicitly setting the macro attributelazy_registration = true
.