[vala] codewriter: Fix writing methods inside error domains



commit 335f64617ab79da63eeaf218c40a78837bea0e9f
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu May 26 13:50:11 2011 +0200

    codewriter: Fix writing methods inside error domains

 vala/valacodewriter.vala |   39 ++++++++++++++++++++++++++++-----------
 1 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 9da08e3..01cb8ef 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -676,20 +676,37 @@ public class Vala.CodeWriter : CodeVisitor {
 		write_identifier (edomain.name);
 		write_begin_block ();
 
-		edomain.accept_children (this);
-
-		write_end_block ();
-		write_newline ();
-	}
+		bool first = true;
+		foreach (ErrorCode ecode in edomain.get_codes ()) {
+			if (first) {
+				first = false;
+			} else {
+				write_string (",");
+				write_newline ();
+			}
 
-	public override void visit_error_code (ErrorCode ecode) {
-		if (ecode.get_cname () != ecode.get_default_cname ()) {
+			if (ecode.get_cname () != ecode.get_default_cname ()) {
+				write_indent ();
+				write_string ("[CCode (cname = \"%s\")]".printf (ecode.get_cname ()));
+			}
 			write_indent ();
-			write_string ("[CCode (cname = \"%s\")]".printf (ecode.get_cname ()));
+			write_identifier (ecode.name);
 		}
-		write_indent ();
-		write_identifier (ecode.name);
-		write_string (",");
+
+		if (!first) {
+			if (edomain.get_methods ().size > 0) {
+				write_string (";");
+			}
+			write_newline ();
+		}
+
+		current_scope = edomain.scope;
+		foreach (Method m in edomain.get_methods ()) {
+			m.accept (this);
+		}
+		current_scope = current_scope.parent_scope;
+
+		write_end_block ();
 		write_newline ();
 	}
 



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