[vala/staging] codegen: Fix vfunc signature of delegate-typed property in interface



commit a91ac04b641e6238566c672c8ab9e7d2735124a2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 14 17:28:08 2019 +0100

    codegen: Fix vfunc signature of delegate-typed property in interface

 codegen/valagtypemodule.vala                   |  4 ++++
 tests/Makefile.am                              |  1 +
 tests/objects/interface-property-delegate.vala | 29 ++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index f1c775264..00ebe26c4 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -2173,6 +2173,8 @@ public class Vala.GTypeModule : GErrorModule {
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                        vdeclarator.add_parameter (new CCodeParameter 
(get_array_length_cname ("result", dim), length_ctype));
                                                }
+                                       } else if ((prop.property_type is DelegateType) && 
get_ccode_delegate_target (prop) && ((DelegateType) prop.property_type).delegate_symbol.has_target) {
+                                               vdeclarator.add_parameter (new CCodeParameter 
(get_delegate_target_cname ("result"), "gpointer*"));
                                        }
 
                                        var vdecl = new CCodeDeclaration (get_ccode_name (creturn_type));
@@ -2196,6 +2198,8 @@ public class Vala.GTypeModule : GErrorModule {
                                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                                        vdeclarator.add_parameter (new CCodeParameter 
(get_array_length_cname ("value", dim), length_ctype));
                                                }
+                                       } else if ((prop.property_type is DelegateType) && 
get_ccode_delegate_target (prop) && ((DelegateType) prop.property_type).delegate_symbol.has_target) {
+                                               vdeclarator.add_parameter (new CCodeParameter 
(get_delegate_target_cname ("value"), "gpointer"));
                                        }
 
                                        var vdecl = new CCodeDeclaration ("void");
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc79845a7..24331e437 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -341,6 +341,7 @@ TESTS = \
        objects/interfaces.vala \
        objects/interface-generics.vala \
        objects/interface-property-base-access.vala \
+       objects/interface-property-delegate.vala \
        objects/interface-virtual-override.vala \
        objects/methods.vala \
        objects/paramspec.vala \
diff --git a/tests/objects/interface-property-delegate.vala b/tests/objects/interface-property-delegate.vala
new file mode 100644
index 000000000..485f12516
--- /dev/null
+++ b/tests/objects/interface-property-delegate.vala
@@ -0,0 +1,29 @@
+delegate void FooFunc ();
+
+interface IFoo {
+       public abstract unowned FooFunc prop { get; set; }
+}
+
+class Foo : IFoo {
+       public unowned FooFunc prop { get; set; }
+}
+
+class Bar {
+       public bool reached;
+
+       public Bar () {
+               var foo = new Foo ();
+               foo.prop = bar;
+
+               foo.prop ();
+       }
+
+       void bar () {
+               reached = true;
+       }
+}
+
+void main () {
+       var bar = new Bar ();
+       assert (bar.reached);
+}


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