[vala] GIR writer: Generate enum values and c:identifer attributes



commit 4b936d9f35fabd83b263ab7c586c3852b7aa25fb
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Fri Mar 20 20:40:17 2009 +0100

    GIR writer: Generate enum values and c:identifer attributes
    
    Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
---
 gobject/valagirwriter.vala |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/gobject/valagirwriter.vala b/gobject/valagirwriter.vala
index c6bad7a..c32b87a 100644
--- a/gobject/valagirwriter.vala
+++ b/gobject/valagirwriter.vala
@@ -303,6 +303,7 @@ public class Vala.GIRWriter : CodeVisitor {
 		stream.printf (">\n");
 		indent++;
 
+		enum_value = 0;
 		en.accept_children (this);
 
 		indent--;
@@ -310,9 +311,18 @@ public class Vala.GIRWriter : CodeVisitor {
 		stream.printf ("</enumeration>\n");
 	}
 
+	private int enum_value;
+
 	public override void visit_enum_value (EnumValue ev) {
 		write_indent ();
-		stream.printf ("<member name=\"%s\"/>\n", string.joinv ("-", ev.name.down ().split ("_")));
+		stream.printf ("<member name=\"%s\" c:identifier=\"%s\"", ev.name.down (), ev.get_cname ());
+		if (ev.value != null) {
+			string value = literal_expression_to_value_string (ev.value);
+			stream.printf (" value=\"%s\"", value);
+		} else {
+			stream.printf (" value=\"%d\"", enum_value++);
+		}
+		stream.printf ("/>\n");
 	}
 
 	public override void visit_error_domain (ErrorDomain edomain) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]