]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't check boolean values for (in)equality in GTask API
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 5 Jan 2019 17:11:30 +0000 (18:11 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 5 Jan 2019 17:54:49 +0000 (18:54 +0100)
This resolves any value but 0 to true as it is suppose to be.

  /* invalid */
  if (condition == TRUE)
    do_foo ();

  /* valid */
  if (another_condition)
    do_bar ();

See https://gitlab.gnome.org/GNOME/glib/issues/1636

codegen/valaccodemethodmodule.vala

index 19d03dce0169b6cce3992caf9b3dd510b9c3b9e3..8d75c5dd6b26da46535edc4e0f66ecd1440ad023 100644 (file)
@@ -140,15 +140,15 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                var state_is_not_zero = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, state, zero);
                ccode.open_if (state_is_not_zero);
 
-               CCodeBinaryExpression task_is_complete;
+               CCodeExpression task_is_complete;
 
                if (context.require_glib_version (2, 44)) {
                        var task_complete = new CCodeFunctionCall (new CCodeIdentifier ("g_task_get_completed"));
                        task_complete.add_argument (async_result_expr);
-                       task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, task_complete, new CCodeConstant ("TRUE"));
+                       task_is_complete = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, task_complete);
                } else {
                        var task_complete = new CCodeMemberAccess.pointer (data_var, "_task_complete_");
-                       task_is_complete = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, task_complete, new CCodeConstant ("TRUE"));
+                       task_is_complete = new CCodeUnaryExpression (CCodeUnaryOperator.LOGICAL_NEGATION, task_complete);
                }
 
                ccode.open_while (task_is_complete);