[vala] codegen: Fix the transformation of elseif cascades using ccode



commit 295ff27a469a1d093dc72e6e8c44383b98266491
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu May 5 17:18:32 2011 +0200

    codegen: Fix the transformation of elseif cascades using ccode

 codegen/valagdbusclientmodule.vala |   10 ++++++----
 codegen/valagdbusservermodule.vala |   20 ++++++++++++--------
 2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index e462d6d..75fea19 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -442,11 +442,13 @@ public class Vala.GDBusClientModule : GDBusModule {
 			ccheck.add_argument (new CCodeIdentifier ("signal_name"));
 			ccheck.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (sig))));
 
-			if (!firstif) {
-				ccode.add_else ();
+			var cond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0"));
+			if (firstif) {
+				ccode.open_if (cond);
+				firstif = false;
+			} else {
+				ccode.else_if (cond);
 			}
-			ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0")));
-			firstif = false;
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_dbus_signal_handler (sig, sym)));
 			ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("proxy"), sym.get_cname () + "*"));
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 78fd7d5..8c1507d 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -719,11 +719,13 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			ccheck.add_argument (new CCodeIdentifier ("property_name"));
 			ccheck.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (prop))));
 
-			if (!firstif) {
-				ccode.add_else ();
+			var cond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0"));
+			if (firstif) {
+				ccode.open_if (cond);
+				firstif = false;
+			} else {
+				ccode.else_if (cond);
 			}
-			ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0")));
-			firstif = false;
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_dbus_property_get_wrapper (prop, sym)));
 			ccall.add_argument (new CCodeIdentifier ("object"));
@@ -781,11 +783,13 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 			ccheck.add_argument (new CCodeIdentifier ("property_name"));
 			ccheck.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name_for_member (prop))));
 
-			if (!firstif) {
-				ccode.add_else ();
+			var cond = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0"));
+			if (firstif) {
+				ccode.open_if (cond);
+				firstif = false;
+			} else {
+				ccode.else_if (cond);
 			}
-			ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ccheck, new CCodeConstant ("0")));
-			firstif = false;
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_dbus_property_set_wrapper (prop, sym)));
 			ccall.add_argument (new CCodeIdentifier ("object"));



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