]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support virtual interface properties
authorJürg Billeter <j@bitron.ch>
Mon, 13 Aug 2012 13:44:46 +0000 (15:44 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 13 Aug 2012 13:50:31 +0000 (15:50 +0200)
Fixes bug 681671.

codegen/valagobjectmodule.vala
codegen/valagtypemodule.vala
vala/valaproperty.vala

index baa42560dd4b4a56561d530e7fb2b5f8675f2e9f..d2e81e35ef6b8017238521f6ab7d82ee80ec7fe5 100644 (file)
@@ -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;
index 487918f592e393d211fd24a39fe37ed6e7439556..ab29c5846ee6132015934ee89e605626d29ce5bb 100644 (file)
@@ -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 ();
index 4a70f5730fa8a55de03dc6f527609675a888f312..82cfff125033cf556c5ee6a6caa0981adc185576 100644 (file)
@@ -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;