[vala/0.14] codegen: Use real_get/set_* functions as helpers for NoAccessorMethod props



commit d280ea94caeb9eefd0400c440e1bd5b16a0773f9
Author: Luca Bruno <lucabru src gnome org>
Date:   Thu Sep 1 16:59:52 2011 +0200

    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.

 codegen/valagobjectmodule.vala |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index a22a8b2..6c70119 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 ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]