]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use real_get/set_* functions as helpers for NoAccessorMethod props
authorLuca Bruno <lucabru@src.gnome.org>
Thu, 1 Sep 2011 14:59:52 +0000 (16:59 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 30 Nov 2011 13:17:40 +0000 (14:17 +0100)
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.

codegen/valagobjectmodule.vala

index a22a8b2c51550e6ca4686166de546ed74e3fb5a9..6c70119fe0c84edf4af99f2403c9bed80b8b4273 100644 (file)
@@ -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 ();