From: Jürg Billeter Date: Mon, 13 Aug 2012 13:44:46 +0000 (+0200) Subject: Support virtual interface properties X-Git-Tag: 0.17.5~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=810f2926d7884aa3887bd72e9f96dece07bc6e2c;p=thirdparty%2Fvala.git Support virtual interface properties Fixes bug 681671. --- diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala index baa42560d..d2e81e35e 100644 --- a/codegen/valagobjectmodule.vala +++ b/codegen/valagobjectmodule.vala @@ -709,6 +709,11 @@ public class Vala.GObjectModule : GTypeModule { return false; } + if (type_sym is Interface && prop.is_virtual) { + // GObject does not support virtual interface properties + return false; + } + if (type_sym is Interface && type_sym.get_attribute ("DBus") != null) { // GObject properties not currently supported in D-Bus interfaces return false; diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 487918f59..ab29c5846 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -2147,6 +2147,19 @@ public class Vala.GTypeModule : GErrorModule { } } + foreach (Property prop in iface.get_properties ()) { + if (prop.is_virtual) { + if (prop.get_accessor != null) { + string cname = CCodeBaseModule.get_ccode_real_name (prop.get_accessor); + ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "get_%s".printf (prop.name)), new CCodeIdentifier (cname)); + } + if (prop.set_accessor != null) { + string cname = CCodeBaseModule.get_ccode_real_name (prop.set_accessor); + ccode.add_assignment (new CCodeMemberAccess.pointer (ciface, "set_%s".printf (prop.name)), new CCodeIdentifier (cname)); + } + } + } + ccode.close (); pop_context (); diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index 4a70f5730..82cfff125 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -298,7 +298,7 @@ public class Vala.Property : Symbol, Lockable { var sym = type.data_type.scope.lookup (name); if (sym is Property) { var base_property = (Property) sym; - if (base_property.is_abstract) { + if (base_property.is_abstract || base_property.is_virtual) { string invalid_match; if (!compatible (base_property, out invalid_match)) { error = true;