]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Cast return values if [CCode (type)] is supplied
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 10 May 2013 19:47:19 +0000 (21:47 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 10 May 2013 19:47:19 +0000 (21:47 +0200)
Patch by avi.w.levy@gmail.com

Fixes bug 699956.

codegen/valaccodemethodcallmodule.vala

index 8cb1171407f860cefe4be8c32b06d1333258eb9d..6bc87cb841a5cf9bb675c2755c2e58939e687028 100644 (file)
@@ -714,6 +714,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        }
                }
 
+               if (get_ccode_type (m) != null && get_ccode_type (m) != get_ccode_name (m.return_type)) {
+                       // Bug 699956: Implement cast for method return type if [CCode type=] annotation is specified
+                       ccall_expr = new CCodeCastExpression (ccall_expr, get_ccode_name (m.return_type));
+               }
+
                if (m is ArrayResizeMethod) {
                        // FIXME: size expression must not be evaluated twice at runtime (potential side effects)
                        Iterator<Expression> arg_it = expr.get_argument_list ().iterator ();