]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Support owned delegate parameter in set accessor 1e90d53dba0eff6ec2babd8292676099308dd4f6
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 9 Jun 2011 11:37:23 +0000 (13:37 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Thu, 9 Jun 2011 11:43:23 +0000 (13:43 +0200)
codegen/valaccodebasemodule.vala
tests/objects/properties.vala

index 5deaf959d2726b70b7697f0dd494e32460779c98..62a6d4584093c7d13e2f257ca00c6a2e08d63b17 100644 (file)
@@ -1343,6 +1343,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        }
                } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                        function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
+                       if (!acc.readable && acc.value_type.value_owned) {
+                               function.add_parameter (new CCodeParameter (get_delegate_target_destroy_notify_cname ("value"), "GDestroyNotify"));
+                       }
                }
 
                if (prop.is_private_symbol () || (!acc.readable && !acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
@@ -1439,6 +1442,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                }
                        } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                                function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
+                               if (!acc.readable && acc.value_type.value_owned) {
+                                       function.add_parameter (new CCodeParameter (get_delegate_target_destroy_notify_cname ("value"), "GDestroyNotify"));
+                               }
                        }
 
                        if (prop.is_private_symbol () || !(acc.readable || acc.writable) || acc.access == SymbolAccessibility.PRIVATE) {
@@ -1494,6 +1500,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        }
                                } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                                        vcall.add_argument (new CCodeIdentifier (get_delegate_target_cname ("value")));
+                                       if (!acc.readable && acc.value_type.value_owned) {
+                                               vcall.add_argument (new CCodeIdentifier (get_delegate_target_destroy_notify_cname ("value")));
+                                       }
                                }
 
                                ccode.add_expression (vcall);
@@ -1556,6 +1565,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                }
                        } else if ((acc.value_type is DelegateType) && ((DelegateType) acc.value_type).delegate_symbol.has_target) {
                                function.add_parameter (new CCodeParameter (get_delegate_target_cname (acc.readable ? "result" : "value"), acc.readable ? "gpointer*" : "gpointer"));
+                               if (!acc.readable && acc.value_type.value_owned) {
+                                       function.add_parameter (new CCodeParameter (get_delegate_target_destroy_notify_cname ("value"), "GDestroyNotify"));
+                               }
                        }
 
                        if (!is_virtual) {
@@ -5385,6 +5397,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        var delegate_type = (DelegateType) prop.property_type;
                        if (delegate_type.delegate_symbol.has_target) {
                                ccall.add_argument (get_delegate_target_cvalue (value));
+                               if (delegate_type.value_owned) {
+                                       ccall.add_argument (get_delegate_target_destroy_notify_cvalue (value));
+                               }
                        }
                }
 
index e66ecbeb3c796a61c202a9c06f92248da73f5140..78f17a7c9d88f52f03a0cd798b3541c35015d283 100644 (file)
@@ -1,8 +1,12 @@
 using GLib;
 
+public delegate void Delegate ();
+
 public class Sample : Object {
        private string automatic { get; set; }
 
+       public Delegate deleg { get; owned set; }
+
        private string _name;
        public string name {
                get { return _name; }
@@ -40,6 +44,8 @@ public class Sample : Object {
                stdout.printf("name: %s\n", name);
                stdout.printf("read_only: %s\n", read_only);
                stdout.printf("automatic: %s\n", automatic);
+
+               this.deleg = null;
         }
 
        public static int main () {