From: Luca Bruno Date: Thu, 1 Sep 2011 14:59:52 +0000 (+0200) Subject: codegen: Use real_get/set_* functions as helpers for NoAccessorMethod props X-Git-Tag: 0.14.1~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d280ea94caeb9eefd0400c440e1bd5b16a0773f9;p=thirdparty%2Fvala.git codegen: Use real_get/set_* functions as helpers for NoAccessorMethod props If the base property has no accessors the class->vfunc are not defined so we can only use our accessors. With this commit we exploit the already defined real_get and real_set functions. Fixes bug 658006. --- diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala index a22a8b2c5..6c70119fe 100644 --- a/codegen/valagobjectmodule.vala +++ b/codegen/valagobjectmodule.vala @@ -215,6 +215,14 @@ public class Vala.GObjectModule : GTypeModule { generate_property_accessor_declaration (prop.base_interface_property.get_accessor, cfile); } + CCodeExpression cfunc; + if (!get_ccode_no_accessor_method (base_prop)) { + cfunc = new CCodeIdentifier (get_ccode_name (base_prop.get_accessor)); + } else { + // use the static real function as helper + cfunc = new CCodeIdentifier (get_ccode_real_name (prop.get_accessor)); + } + ccode.add_case (new CCodeIdentifier (get_ccode_upper_case_name (prop))); if (prop.property_type.is_real_struct_type ()) { var st = prop.property_type.data_type as Struct; @@ -222,7 +230,7 @@ public class Vala.GObjectModule : GTypeModule { ccode.open_block (); ccode.add_declaration (get_ccode_name (st), new CCodeVariableDeclarator ("boxed")); - ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.get_accessor))); + ccall = new CCodeFunctionCall (cfunc); ccall.add_argument (cself); var boxed_addr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("boxed")); ccall.add_argument (boxed_addr); @@ -239,7 +247,7 @@ public class Vala.GObjectModule : GTypeModule { } ccode.close (); } else { - ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.get_accessor))); + ccall = new CCodeFunctionCall (cfunc); ccall.add_argument (cself); var array_type = prop.property_type as ArrayType; if (array_type != null && array_type.element_type.data_type == string_type.data_type) { @@ -314,8 +322,16 @@ public class Vala.GObjectModule : GTypeModule { generate_property_accessor_declaration (prop.base_interface_property.set_accessor, cfile); } + CCodeExpression cfunc; + if (!get_ccode_no_accessor_method (base_prop)) { + cfunc = new CCodeIdentifier (get_ccode_name (base_prop.set_accessor)); + } else { + // use the static real function as helper + cfunc = new CCodeIdentifier (get_ccode_real_name (prop.set_accessor)); + } + ccode.add_case (new CCodeIdentifier (get_ccode_upper_case_name (prop))); - ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (base_prop.set_accessor))); + ccall = new CCodeFunctionCall (cfunc); ccall.add_argument (cself); if (prop.property_type is ArrayType && ((ArrayType)prop.property_type).element_type.data_type == string_type.data_type) { ccode.open_block ();