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 769903 - Incorrect FlagsValue definition
Incorrect FlagsValue definition
Status: RESOLVED DUPLICATE of bug 629011
Product: vala
Classification: Core
Component: Bindings: GLib
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-08-14 23:44 UTC by therebedragons111
Modified: 2016-09-15 07:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch fixes behaviour (506 bytes, patch)
2016-08-14 23:44 UTC, therebedragons111
rejected Details | Review
testcase (1.32 KB, text/x-vala)
2016-08-15 06:04 UTC, therebedragons111
  Details
gobject-2.0: Fix and make FlagsValue a struct (1.39 KB, patch)
2016-08-30 16:39 UTC, Rico Tzschichholz
committed Details | Review

Description therebedragons111 2016-08-14 23:44:05 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);
		}
	}
}
Comment 1 therebedragons111 2016-08-15 06:04:23 UTC
Created attachment 333311 [details]
testcase
Comment 2 Evan Nemerson 2016-08-26 18:40:50 UTC
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).
Comment 3 Rico Tzschichholz 2016-08-30 16:39:10 UTC
Created attachment 334459 [details] [review]
gobject-2.0: Fix and make FlagsValue a struct

Based on patch by therebedragons111
Comment 4 Evan Nemerson 2016-08-30 17:37:47 UTC
Review of attachment 334459 [details] [review]:

lgtm
Comment 5 Rico Tzschichholz 2016-08-30 20:20:20 UTC
Attachment 334459 [details] pushed as 950f081 - gobject-2.0: Fix and make FlagsValue a struct
Comment 6 therebedragons111 2016-09-03 21:07:52 UTC
(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
Comment 7 Rico Tzschichholz 2016-09-15 07:11:15 UTC

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