From: Luca Bruno Date: Sat, 27 Dec 2014 17:17:32 +0000 (+0100) Subject: girparser: Take in account base property for ConcreteAccessor X-Git-Tag: 0.27.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bcc61ce5536ed05bb59534ea8c0fd2e9a53aec0;p=thirdparty%2Fvala.git girparser: Take in account base property for ConcreteAccessor Property had NoAccessorMethod when the overridden interface property had ConcreteAccessor. Now we lookup the base interface property to fix ownership according to the base accessors and remove NoAccessorMethod. Fixes bug 742012 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 3dab72c1e..a9bd40fe1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -204,6 +204,7 @@ TESTS = \ dbus/bug602003.test \ gir/bug651773.test \ gir/bug667751.test \ + gir/bug742012.test \ $(NULL) check-TESTS: $(TESTS) diff --git a/tests/gir/bug742012.test b/tests/gir/bug742012.test new file mode 100644 index 000000000..5ce77a6b3 --- /dev/null +++ b/tests/gir/bug742012.test @@ -0,0 +1,95 @@ +GIR + +Input: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Output: + +[CCode (cheader_filename = "test.h", cname = "GcrCertificateRenderer", type_id = "gcr_certificate_renderer_get_type ()")] +public class CertificateRenderer : GLib.Object, Test.Renderer { + [CCode (has_construct_function = false)] + protected CertificateRenderer (); +} +[CCode (cheader_filename = "test.h", cname = "GcrRenderer", type_id = "gcr_renderer_get_type ()")] +public interface Renderer : GLib.Object { + [CCode (cname = "gcr_renderer_get_attributes")] + public unowned GLib.List get_attributes (); + [CCode (cname = "gcr_renderer_set_attributes")] + public void set_attributes (GLib.List? attrs); + [NoAccessorMethod] + public abstract GLib.List attributes { owned get; set; } +} diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index 9d8ef159c..46cdc7791 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -1027,6 +1027,29 @@ public class Vala.GirParser : CodeVisitor { } } + if (prop.get_attribute ("NoAccessorMethod") != null) { + if (!prop.overrides && parent.symbol is Class) { + // bug 742012 + // find base interface property with ConcreteAccessor and this overriding property with NoAccessorMethod + var base_prop_node = parser.base_interface_property (this); + if (base_prop_node != null) { + base_prop_node.process (parser); + + var base_property = (Property) base_prop_node.symbol; + if (base_property.get_attribute ("ConcreteAccessor") != null) { + prop.set_attribute ("NoAccessorMethod", false); + if (prop.get_accessor != null) { + prop.get_accessor.value_type.value_owned = base_property.get_accessor.value_type.value_owned; + } + if (prop.set_accessor != null) { + prop.set_accessor.value_type.value_owned = base_property.set_accessor.value_type.value_owned; + } + + } + } + } + } + if (prop.get_attribute ("NoAccessorMethod") != null) { // gobject defaults if (prop.get_accessor != null) { @@ -3915,4 +3938,34 @@ public class Vala.GirParser : CodeVisitor { } return true; } + + /* Helper methods */ + + Node? base_interface_property (Node prop_node) { + var cl = prop_node.parent.symbol as Class; + if (cl == null) { + return null; + } + + foreach (DataType type in cl.get_base_types ()) { + if (!(type is UnresolvedType)) { + continue; + } + + var base_node = resolve_node (prop_node.parent, ((UnresolvedType) type).unresolved_symbol); + if (base_node != null && base_node.symbol is Interface) { + var base_prop_node = base_node.lookup (prop_node.name); + if (base_prop_node != null && base_prop_node.symbol is Property) { + var base_property = (Property) base_prop_node.symbol; + if (base_property.is_abstract || base_property.is_virtual) { + // found + return base_prop_node; + } + } + } + } + + return null; + } + }