After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663054 - 64bit enums and flags
64bit enums and flags
Status: RESOLVED DUPLICATE of bug 686662
Product: glib
Classification: Platform
Component: gobject
2.31.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-10-30 16:03 UTC by Aleksander Morgado
Modified: 2013-06-13 11:37 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Aleksander Morgado 2011-10-30 16:03:32 UTC
GEnumValue and GFlagsValue rely on gint and guint respectively, and therefore they are not able to hold 64bit enumerations. 64-bit enums is probably a pretty rare case, but 64-bit flags is not; needing more than 32 bitflags can be quite common.

Therefore, it would be great to have 64bit enums and flags in GLib/GObject, e.g. 'GEnum64Value' and 'GFlags64Value', with their own GParamSpecs, their own to/from GValue, and such.

I can spend some time preparing a patch for this, but better get comments on whether it's a good idea or not.
Comment 1 Tim Janik 2011-11-01 13:05:09 UTC
I think this'll be a bit more involved, i.e. you most probably need to add two new fundamental types for this, as TYPE_ENUM/FLAGS can be hardcoded to fit into gint in many locations (also user code).
Then again, *adding* fundamental types hasn't been done since GType was initially written, there may be some significant fallout in third party code, i.e. all code that currently does things like switch (G_TYPE_FUNDAMENTAL (id)) will need adaption.
Are 64bit enums worth the hassle? Depending on your use case, you might be able to get away with 2 32bit flags fields as well. I'll leave the call up to the current GLib maintainers, as I most probably won't have the time to review this in details, but I'm around for the occasional hand if someone really wants to go through the excercise of adding a new fundamental type. ;)
Comment 2 Aleksander Morgado 2011-11-01 15:14:48 UTC

> Are 64bit enums worth the hassle? Depending on your use case, you might be able
> to get away with 2 32bit flags fields as well.

In the use case I have, I shouldn't have many problems to split the flags into 2 32bit sets, but it may end up being not very clean.

My impression is that if the language allows having 64bit values in enums, GLib sooner or later should also allow it.

> I'll leave the call up to the
> current GLib maintainers, as I most probably won't have the time to review this
> in details, but I'm around for the occasional hand if someone really wants to
> go through the excercise of adding a new fundamental type. ;)

Thanks :-)
Comment 3 Colin Walters 2013-06-13 11:37:46 UTC
While 686662 is newer, it has a slightly different design that I think we'd need to take.

*** This bug has been marked as a duplicate of bug 686662 ***