[vala] codegen: Allow usage of gtype structs inheriting non-gtype struct
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Allow usage of gtype structs inheriting non-gtype struct
- Date: Fri, 10 Feb 2012 10:39:12 +0000 (UTC)
commit a658220f9e8ce3f2226d3f3e445f2103ab5ef556
Author: Luca Bruno <lucabru src gnome org>
Date: Fri Feb 10 11:13:22 2012 +0100
codegen: Allow usage of gtype structs inheriting non-gtype 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.
Fixes bug 669604.
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]