fix using instance methods as delegates in the constructor
authorJuerg Billeter <j@bitron.ch>
Tue, 12 Feb 2008 17:39:06 +0000 (17:39 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 12 Feb 2008 17:39:06 +0000 (17:39 +0000)
2008-02-12  Juerg Billeter  <j@bitron.ch>

* gobject/valaccodegenerator.vala: fix using instance methods as
  delegates in the constructor

svn path=/trunk/; revision=1005

ChangeLog
gobject/valaccodegenerator.vala

index f1aeb33..bca8f25 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-02-12  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valaccodegenerator.vala: fix using instance methods as
+         delegates in the constructor
+
+2008-02-12  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaccodeassignmentbinding.vala: support signal handlers
          with struct parameters
 
index cdd643a..b2d49c1 100644 (file)
@@ -77,6 +77,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
        private int current_try_id = 0;
        private int next_try_id = 0;
        public bool in_creation_method = false;
+       private bool in_constructor = false;
        private bool current_method_inner_error = false;
 
        public DataType bool_type;
@@ -752,9 +753,12 @@ public class Vala.CCodeGenerator : CodeGenerator {
 
        public override void visit_constructor (Constructor! c) {
                current_method_inner_error = false;
+               in_constructor = true;
 
                c.accept_children (this);
 
+               in_constructor = false;
+
                var cl = (Class) c.parent_symbol;
        
                function = new CCodeFunction ("%s_constructor".printf (cl.get_lower_case_cname (null)), "GObject *");
@@ -2406,7 +2410,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
                        } else if (delegate_expr.symbol_reference is Method) {
                                var ma = (MemberAccess) delegate_expr;
                                if (ma.inner == null) {
-                                       if (current_method != null && current_method.instance) {
+                                       if ((current_method != null && current_method.instance) || in_constructor) {
                                                return new CCodeIdentifier ("self");
                                        } else {
                                                return new CCodeConstant ("NULL");