From 086cd345e8d3e78901b963a8fdc0c5d74efc3a7a Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 19 May 2020 14:29:06 +0200 Subject: [PATCH] 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 --- codegen/valagirwriter.vala | 13 +++++++++---- tests/girwriter/GirTest-1.0.gir-expected | 5 +++++ tests/girwriter/girtest.vala | 6 ++++++ tests/girwriter/girtest.vapi-expected | 6 ++++++ 4 files changed, 26 insertions(+), 4 deletions(-) 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, -- 2.47.2