[vala] Support virtual interface properties



commit 810f2926d7884aa3887bd72e9f96dece07bc6e2c
Author: JÃrg Billeter <j bitron ch>
Date:   Mon Aug 13 15:44:46 2012 +0200

    Support virtual interface properties
    
    Fixes bug 681671.

 codegen/valagobjectmodule.vala |    5 +++++
 codegen/valagtypemodule.vala   |   13 +++++++++++++
 vala/valaproperty.vala         |    2 +-
 3 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index baa4256..d2e81e3 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 487918f..ab29c58 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 4a70f57..82cfff1 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;



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