GNOME Bugzilla – Bug 769903
Incorrect FlagsValue definition
Last modified: 2016-09-15 07:11:15 UTC
Created attachment 333306 [details] [review] patch fixes behaviour There already is a bug https://bugzilla.gnome.org/show_bug.cgi?id=629011 and error in FlagsValue still persists (also, correct type is uint) With this patch following test passes 100% [Flags] public enum FlagsTest { AAAA, BBBB, CCCC, DDDD } public class MainClass { const FlagsTest[] arr = { FlagsTest.AAAA, FlagsTest.BBBB, FlagsTest.CCCC, FlagsTest.DDDD, FlagsTest.AAAA | FlagsTest.DDDD }; public static void main (string[] args) { FlagsClass flags_class = (FlagsClass) typeof(FlagsTest).class_ref(); stdout.printf("len=%i\n", flags_class.values.length); for (int i=0; i<flags_class.values.length; i++) stdout.printf ("%s\n", flags_class.values[i].value_nick); for (int i=0; i<arr.length; i++) { stdout.printf("get_first_value: name=%s,nick=%s,value=%lu\n", flags_class.get_first_value(arr[i]).value_name, flags_class.get_first_value(arr[i]).value_nick, flags_class.get_first_value(arr[i]).value); stdout.printf("get_value_by_name: name=%s,value=%lu\n", flags_class.get_value_by_name(flags_class.get_first_value(arr[i]).value_name).value_name, flags_class.get_value_by_name(flags_class.get_first_value(arr[i]).value_name).value); stdout.printf("get_value_by_nick: name=%s,value=%lu\n", flags_class.get_value_by_nick(flags_class.get_first_value(arr[i]).value_nick).value_name, flags_class.get_value_by_nick(flags_class.get_first_value(arr[i]).value_nick).value); } } }
Created attachment 333311 [details] testcase
Review of attachment 333306 [details] [review]: [Compact] doesn't apply to structs. If we want to use a struct instead of a class (which does seem correct) it should be removed. It would also be nice if you could use `git format-patch` so we get a commit message and, assuming you've configured git properly, correct author information (you don't seem to have a name associated with your bugzilla account).
Created attachment 334459 [details] [review] gobject-2.0: Fix and make FlagsValue a struct Based on patch by therebedragons111
Review of attachment 334459 [details] [review]: lgtm
Attachment 334459 [details] pushed as 950f081 - gobject-2.0: Fix and make FlagsValue a struct
(In reply to Evan Nemerson from comment #2) > Review of attachment 333306 [details] [review] [review]: > > [Compact] doesn't apply to structs. If we want to use a struct instead of a > class (which does seem correct) it should be removed. > > It would also be nice if you could use `git format-patch` so we get a commit > message and, assuming you've configured git properly, correct author > information (you don't seem to have a name associated with your bugzilla > account). sorry, my bad. in my own copy i used exact same thing as corrected patch (since i copied from enumvalue) when creating diff, i somehow forgot to copy paste that line as well. and no, i don't have name associated or plan to do that. as long as issue is solved i couldn't care less about credit thanks
*** This bug has been marked as a duplicate of bug 629011 ***