]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add member `begin' to coroutines
authorJürg Billeter <j@bitron.ch>
Sun, 2 Nov 2008 13:00:19 +0000 (13:00 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 2 Nov 2008 13:00:19 +0000 (13:00 +0000)
2008-11-02  Jürg Billeter  <j@bitron.ch>

* vala/valamethodtype.vala:
* gobject/valaccodegenerator.vala:

Add member `begin' to coroutines

svn path=/trunk/; revision=1951

ChangeLog
gobject/valaccodegenerator.vala
vala/valamethodtype.vala

index ee7f2313d5becc79d1a8f605869c4253778901d1..0fd58f2153ae974e2ef7866278f7891ea2c07171 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-11-02  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valamethodtype.vala:
+       * gobject/valaccodegenerator.vala:
+
+       Add member `begin' to coroutines
+
 2008-11-02  Jürg Billeter  <j@bitron.ch>
 
        * vala/Makefile.am:
index 4523739378c0eeb228c0119524be27d6ad7d20f7..04ce826b1d50b1175a604c306793781f855c9dbf 100644 (file)
@@ -2685,18 +2685,16 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        var cfrag = new CCodeFragment ();
                        stmt.ccodenode = cfrag;
 
-                       if (current_method.coroutine) {
-                               var idle_call = new CCodeFunctionCall (new CCodeIdentifier ("g_idle_add"));
-                               idle_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (current_method.get_real_cname ()), "GSourceFunc"));
-                               idle_call.add_argument (new CCodeIdentifier ("data"));
+                       var idle_call = new CCodeFunctionCall (new CCodeIdentifier ("g_idle_add"));
+                       idle_call.add_argument (new CCodeCastExpression (new CCodeIdentifier (current_method.get_real_cname ()), "GSourceFunc"));
+                       idle_call.add_argument (new CCodeIdentifier ("data"));
 
-                               int state = next_coroutine_state++;
+                       int state = next_coroutine_state++;
 
-                               cfrag.append (new CCodeExpressionStatement (idle_call));
-                               cfrag.append (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "state"), new CCodeConstant (state.to_string ()))));
-                               cfrag.append (new CCodeReturnStatement (new CCodeConstant ("FALSE")));
-                               cfrag.append (new CCodeCaseStatement (new CCodeConstant (state.to_string ())));
-                       }
+                       cfrag.append (new CCodeExpressionStatement (idle_call));
+                       cfrag.append (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "state"), new CCodeConstant (state.to_string ()))));
+                       cfrag.append (new CCodeReturnStatement (new CCodeConstant ("FALSE")));
+                       cfrag.append (new CCodeCaseStatement (new CCodeConstant (state.to_string ())));
 
                        return;
                }
index 6ef17c5c0d8f210e0cb831237460f4687f564b90..aa272128754273dd3c6a48601642c1a4d0549252 100644 (file)
@@ -66,4 +66,11 @@ public class Vala.MethodType : DataType {
        public override string? get_cname () {
                return "gpointer";
        }
+
+       public override Symbol? get_member (string member_name) {
+               if (method_symbol.coroutine && member_name == "begin") {
+                       return method_symbol;
+               }
+               return null;
+       }
 }