From: Jürg Billeter Date: Sun, 14 Jun 2009 14:06:45 +0000 (+0200) Subject: Fix abstract and virtual array properties X-Git-Tag: 0.7.4~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6a3349f3d1ed55f0bf5d25854ac7fb9ac7a3df2;p=thirdparty%2Fvala.git Fix abstract and virtual array properties --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index c6c5ba9d7..d52a639d7 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -1296,12 +1296,31 @@ internal class Vala.CCodeBaseModule : CCodeModule { vcall.add_argument (new CCodeIdentifier ("value")); block.add_statement (new CCodeExpressionStatement (vcall)); } else { + if (acc.value_type is ArrayType) { + var array_type = (ArrayType) acc.value_type; + + for (int dim = 1; dim <= array_type.rank; dim++) { + var len_expr = new CCodeIdentifier (head.get_array_length_cname ("result", dim)); + vcall.add_argument (len_expr); + } + } + block.add_statement (new CCodeReturnStatement (vcall)); } } else { var vcall = new CCodeFunctionCall (new CCodeMemberAccess.pointer (vcast, "set_%s".printf (prop.name))); vcall.add_argument (new CCodeIdentifier ("self")); vcall.add_argument (new CCodeIdentifier ("value")); + + if (acc.value_type is ArrayType) { + var array_type = (ArrayType) acc.value_type; + + for (int dim = 1; dim <= array_type.rank; dim++) { + var len_expr = new CCodeIdentifier (head.get_array_length_cname ("value", dim)); + vcall.add_argument (len_expr); + } + } + block.add_statement (new CCodeExpressionStatement (vcall)); } diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala index dc198e4fa..6b3e7a190 100644 --- a/codegen/valagobjectmodule.vala +++ b/codegen/valagobjectmodule.vala @@ -144,6 +144,10 @@ internal class Vala.GObjectModule : GTypeModule { continue; } + if (prop.property_type is ArrayType) { + continue; + } + if (prop.overrides || prop.base_interface_property != null) { var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_override_property")); cinst.add_argument (ccall); @@ -215,6 +219,10 @@ internal class Vala.GObjectModule : GTypeModule { continue; } + if (prop.property_type is ArrayType) { + continue; + } + string prefix = cl.get_lower_case_cname (null); CCodeExpression cself = new CCodeIdentifier ("self"); if (prop.base_property != null) { @@ -295,6 +303,10 @@ internal class Vala.GObjectModule : GTypeModule { continue; } + if (prop.property_type is ArrayType) { + continue; + } + string prefix = cl.get_lower_case_cname (null); CCodeExpression cself = new CCodeIdentifier ("self"); if (prop.base_property != null) { diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index 468f35315..a38954cf8 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -235,6 +235,14 @@ internal class Vala.GTypeModule : GErrorModule { } else { creturn_type = prop.property_type.get_cname (); } + + var array_type = prop.property_type as ArrayType; + if (array_type != null) { + for (int dim = 1; dim <= array_type.rank; dim++) { + vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*")); + } + } + var vdecl = new CCodeDeclaration (creturn_type); vdecl.add_declarator (vdeclarator); type_struct.add_declaration (vdecl); @@ -243,6 +251,14 @@ internal class Vala.GTypeModule : GErrorModule { var vdeclarator = new CCodeFunctionDeclarator ("set_%s".printf (prop.name)); vdeclarator.add_parameter (cselfparam); vdeclarator.add_parameter (cvalueparam); + + var array_type = prop.property_type as ArrayType; + if (array_type != null) { + for (int dim = 1; dim <= array_type.rank; dim++) { + vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("value", dim), "int")); + } + } + var vdecl = new CCodeDeclaration ("void"); vdecl.add_declarator (vdeclarator); type_struct.add_declaration (vdecl); @@ -1692,6 +1708,14 @@ internal class Vala.GTypeModule : GErrorModule { } else { creturn_type = prop.get_accessor.value_type.get_cname (); } + + var array_type = prop.property_type as ArrayType; + if (array_type != null) { + for (int dim = 1; dim <= array_type.rank; dim++) { + vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("result", dim), "int*")); + } + } + var vdecl = new CCodeDeclaration (creturn_type); vdecl.add_declarator (vdeclarator); type_struct.add_declaration (vdecl); @@ -1706,6 +1730,14 @@ internal class Vala.GTypeModule : GErrorModule { var cvalueparam = new CCodeFormalParameter ("value", prop.set_accessor.value_type.get_cname ()); vdeclarator.add_parameter (cvalueparam); } + + var array_type = prop.property_type as ArrayType; + if (array_type != null) { + for (int dim = 1; dim <= array_type.rank; dim++) { + vdeclarator.add_parameter (new CCodeFormalParameter (head.get_array_length_cname ("value", dim), "int")); + } + } + var vdecl = new CCodeDeclaration ("void"); vdecl.add_declarator (vdeclarator); type_struct.add_declaration (vdecl); @@ -1767,6 +1799,11 @@ internal class Vala.GTypeModule : GErrorModule { var props = iface.get_properties (); foreach (Property prop in props) { if (prop.is_abstract) { + + if (prop.property_type is ArrayType) { + continue; + } + var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_interface_install_property")); cinst.add_argument (new CCodeIdentifier ("iface")); cinst.add_argument (head.get_param_spec (prop));