[vala/staging] codegen: Fix usage of gtype structs inheriting non-gboxed struct



commit b8a5a1dc9ab327ba67f7c58bd57c45cdcd6d495e
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Feb 10 11:13:22 2012 +0100

    codegen: Fix usage of gtype structs inheriting non-gboxed struct
    
    The behavior of type_id is different, but get/set/take/marshaller aren't
    as specific as type_id. Therefore this patch enhances without breaking.

 codegen/valaccodeattribute.vala |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala
index f076a65..d019ce7 100644
--- a/codegen/valaccodeattribute.vala
+++ b/codegen/valaccodeattribute.vala
@@ -928,8 +928,12 @@ public class Vala.CCodeAttribute : AttributeCache {
 			} else if (sym is Struct) {
 				var st = (Struct) sym;
 				var base_st = st.base_struct;
-				if (base_st != null) {
-					return CCodeBaseModule.get_ccode_marshaller_type_name (base_st);
+				while (base_st != null) {
+					if (CCodeBaseModule.get_ccode_has_type_id (base_st)) {
+						return CCodeBaseModule.get_ccode_marshaller_type_name (base_st);
+					} else {
+						base_st = base_st.base_struct;
+					}
 				}
 				if (st.is_simple_type ()) {
 					Report.error (st.source_reference, "The type `%s` doesn't declare a marshaller type name".printf (st.get_full_name ()));
@@ -1004,8 +1008,12 @@ public class Vala.CCodeAttribute : AttributeCache {
 		} else if (sym is Struct) {
 			var st = (Struct) sym;
 			var base_st = st.base_struct;
-			if (base_st != null) {
-				return CCodeBaseModule.get_ccode_get_value_function (base_st);
+			while (base_st != null) {
+				if (CCodeBaseModule.get_ccode_has_type_id (base_st)) {
+					return CCodeBaseModule.get_ccode_get_value_function (base_st);
+				} else {
+					base_st = base_st.base_struct;
+				}
 			}
 			if (st.is_simple_type ()) {
 				Report.error (st.source_reference, "The type `%s` doesn't declare a GValue get function".printf (st.get_full_name ()));
@@ -1058,8 +1066,12 @@ public class Vala.CCodeAttribute : AttributeCache {
 		} else if (sym is Struct) {
 			var st = (Struct) sym;
 			var base_st = st.base_struct;
-			if (base_st != null) {
-				return CCodeBaseModule.get_ccode_set_value_function (base_st);
+			while (base_st != null) {
+				if (CCodeBaseModule.get_ccode_has_type_id (base_st)) {
+					return CCodeBaseModule.get_ccode_set_value_function (base_st);
+				} else {
+					base_st = base_st.base_struct;
+				}
 			}
 			if (st.is_simple_type ()) {
 				Report.error (st.source_reference, "The type `%s` doesn't declare a GValue set function".printf (st.get_full_name ()));
@@ -1112,8 +1124,12 @@ public class Vala.CCodeAttribute : AttributeCache {
 		} else if (sym is Struct) {
 			var st = (Struct) sym;
 			var base_st = st.base_struct;
-			if (base_st != null) {
-				return CCodeBaseModule.get_ccode_take_value_function (base_st);
+			while (base_st != null) {
+				if (CCodeBaseModule.get_ccode_has_type_id (base_st)) {
+					return CCodeBaseModule.get_ccode_take_value_function (base_st);
+				} else {
+					base_st = base_st.base_struct;
+				}
 			}
 			if (st.is_simple_type ()) {
 				Report.error (st.source_reference, "The type `%s` doesn't declare a GValue take function".printf (st.get_full_name ()));



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