]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Allow usage of gtype structs inheriting non-gtype struct
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 10 Feb 2012 10:13:22 +0000 (11:13 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 10 Feb 2012 10:36:58 +0000 (11:36 +0100)
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.

Fixes bug 669604.

codegen/valaccodeattribute.vala

index f076a657037f009d0ff64a58a7181bb28bf3e450..d019ce71dcf7284dd24820880e1222aa4d91ac17 100644 (file)
@@ -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 ()));