diff options
author | Jürg Billeter <j@bitron.ch> | 2012-08-13 15:44:46 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2012-08-13 15:50:31 +0200 |
commit | 810f2926d7884aa3887bd72e9f96dece07bc6e2c (patch) | |
tree | c54b4ae909d709605864efe5b2aa853930e5fc0e | |
parent | 28ddcc01c794429debff9b632b64da246cd8d027 (diff) | |
download | vala-810f2926d7884aa3887bd72e9f96dece07bc6e2c.tar.gz |
Support virtual interface properties
Fixes bug 681671.
-rw-r--r-- | codegen/valagobjectmodule.vala | 5 | ||||
-rw-r--r-- | codegen/valagtypemodule.vala | 13 | ||||
-rw-r--r-- | vala/valaproperty.vala | 2 |
3 files changed, 19 insertions, 1 deletions
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; |