From: Rico Tzschichholz Date: Tue, 19 May 2020 12:29:06 +0000 (+0200) Subject: girwriter: Evaluate and output non literal enum-value if it is a simple constant X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fwip%2Fissue%2F996;p=thirdparty%2Fvala.git girwriter: Evaluate and output non literal enum-value if it is a simple constant This avoids the output of "(null)" in the generated GIR for these cases. Fixes https://gitlab.gnome.org/GNOME/vala/issues/996 --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index 0198cc908..d00824d29 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -823,7 +823,7 @@ public class Vala.GIRWriter : CodeVisitor { var en = (Enum) hierarchy[0]; buffer.append_printf (" + + + + + diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala index e9b3d2ae1..e0756e5fb 100644 --- a/tests/girwriter/girtest.vala +++ b/tests/girwriter/girtest.vala @@ -306,4 +306,10 @@ namespace GirTest { public void method (K[] param) { } } + + public enum EnumTest2 { + VALUE1 = EnumTest.VALUE3, + VALUE2, + VALUE3 = 4711 + } } diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected index f92e00d05..b2deaad4e 100644 --- a/tests/girwriter/girtest.vapi-expected +++ b/tests/girwriter/girtest.vapi-expected @@ -143,6 +143,12 @@ namespace GirTest { VALUE3 } [CCode (cheader_filename = "girtest.h")] + public enum EnumTest2 { + VALUE1, + VALUE2, + VALUE3 + } + [CCode (cheader_filename = "girtest.h")] [Flags] public enum FlagsTest { VALUE1,