]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always use CCodeConstant for NULL
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 6 Apr 2021 11:00:16 +0000 (13:00 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Apr 2021 06:34:18 +0000 (08:34 +0200)
codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valagtypemodule.vala
codegen/valagvariantmodule.vala

index 85177817189afbc5577240916e6c1a22a87a0163..9bfe9db5927941129645c8626d8beff074d54cbc 100644 (file)
@@ -606,7 +606,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        ccode.add_return (new CCodeIdentifier ("result"));
 
                        ccode.close ();
-                       ccode.add_return (new CCodeIdentifier ("NULL"));
+                       ccode.add_return (new CCodeConstant ("NULL"));
                } else {
                        // only dup if length > 0, this deals with negative lengths and returns NULL
                        var length_check = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, new CCodeIdentifier ("length"), new CCodeConstant ("0"));
@@ -644,7 +644,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        }
 
                        ccode.close ();
-                       ccode.add_return (new CCodeIdentifier ("NULL"));
+                       ccode.add_return (new CCodeConstant ("NULL"));
                }
 
                // append to file
index 4d44d0a7e6b5c9703eab5d584c1edb9160023d70..c9874ee7df7375e077e328c30ab8b2c9f12ce7e5 100644 (file)
@@ -1233,7 +1233,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                                                        ccode.add_assignment (get_delegate_target_cvalue (field_value), new CCodeIdentifier ("self"));
                                                        if (delegate_type.is_disposable ()) {
-                                                               ccode.add_assignment (get_delegate_target_destroy_notify_cvalue (field_value), new CCodeIdentifier ("NULL"));
+                                                               ccode.add_assignment (get_delegate_target_destroy_notify_cvalue (field_value), new CCodeConstant ("NULL"));
                                                        }
                                                }
                                        }
@@ -6011,7 +6011,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        if (sink_func != "") {
                                if (type.nullable) {
-                                       var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeIdentifier ("NULL"));
+                                       var is_not_null = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, result.cvalue, new CCodeConstant ("NULL"));
                                        ccode.open_if (is_not_null);
                                }
 
index 66f2d88185751836bc0f8ad8da60aed189d4007d..2d47f3ee416a1cc28fc9690dd8cc51d7fc5f5b03 100644 (file)
@@ -432,7 +432,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                                                        closure_new.add_argument (new CCodeCastExpression (cexpr, "GCallback"));
                                                                        closure_new.add_argument (delegate_target);
                                                                        closure_new.add_argument (new CCodeCastExpression (delegate_target_destroy_notify, "GClosureNotify"));
-                                                                       cexpr = new CCodeConditionalExpression (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cexpr, new CCodeIdentifier ("NULL")), new CCodeIdentifier ("NULL"), closure_new);
+                                                                       cexpr = new CCodeConditionalExpression (new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cexpr, new CCodeConstant ("NULL")), new CCodeConstant ("NULL"), closure_new);
                                                                } else {
                                                                        carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), delegate_target);
                                                                        if (deleg_type.is_disposable ()) {
index 699aca8df2d3c2982b5e42029e58f01a872327e8..ca9d63e7c5f2e891b774804a2cedc7d1ecc8f9a5 100644 (file)
@@ -1007,7 +1007,7 @@ public class Vala.GTypeModule : GErrorModule {
 
                var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail"));
                ccall.add_argument (subccall);
-               ccall.add_argument (new CCodeIdentifier ("NULL"));
+               ccall.add_argument (new CCodeConstant ("NULL"));
                ccode.add_expression (ccall);
 
                ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_param_spec_internal"));
@@ -1186,7 +1186,7 @@ public class Vala.GTypeModule : GErrorModule {
 
                var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_return_val_if_fail"));
                ccall.add_argument (ccall_typecheck);
-               ccall.add_argument (new CCodeIdentifier ("NULL"));
+               ccall.add_argument (new CCodeConstant ("NULL"));
                ccode.add_expression (ccall);
 
                ccode.add_return (vpointer);
@@ -2343,8 +2343,8 @@ public class Vala.GTypeModule : GErrorModule {
                        get_value.add_argument ((CCodeExpression) get_ccodenode (((MemberAccess) expr.call).inner));
 
                        ccode.add_assignment (get_variable_cexpression (temp_var.name), get_value);
-                       var is_null_value = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression (temp_var.name), new CCodeIdentifier ("NULL"));
-                       set_cvalue (expr, new CCodeConditionalExpression (is_null_value, new CCodeMemberAccess.pointer (get_variable_cexpression (temp_var.name), "value_name"), new CCodeIdentifier ("NULL")));
+                       var is_null_value = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_variable_cexpression (temp_var.name), new CCodeConstant ("NULL"));
+                       set_cvalue (expr, new CCodeConditionalExpression (is_null_value, new CCodeMemberAccess.pointer (get_variable_cexpression (temp_var.name), "value_name"), new CCodeConstant ("NULL")));
                }
                pop_line ();
        }
index d4719b9068339d9d2598490de4425b9b568cb2bc..fb28aa762efc94b2c5665321b6c0ed2ce0698f83 100644 (file)
@@ -345,7 +345,7 @@ public class Vala.GVariantModule : GValueModule {
                        // NULL terminate array
                        var length = new CCodeIdentifier (temp_name + "_length");
                        var element_access = new CCodeElementAccess (new CCodeIdentifier (temp_name), length);
-                       ccode.add_assignment (element_access, new CCodeIdentifier ("NULL"));
+                       ccode.add_assignment (element_access, new CCodeConstant ("NULL"));
                }
 
                return new CCodeIdentifier (temp_name);
@@ -499,7 +499,7 @@ public class Vala.GVariantModule : GValueModule {
                } else if (key_type.type_symbol.get_full_name () == "GLib.HashTable") {
                        hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify"));
                } else {
-                       hash_table_new.add_argument (new CCodeIdentifier ("NULL"));
+                       hash_table_new.add_argument (new CCodeConstant ("NULL"));
                }
 
                if (value_type.type_symbol.is_subtype_of (string_type.type_symbol)) {
@@ -509,7 +509,7 @@ public class Vala.GVariantModule : GValueModule {
                } else if (value_type.type_symbol.get_full_name () == "GLib.HashTable") {
                        hash_table_new.add_argument (new CCodeCastExpression (new CCodeIdentifier ("g_hash_table_unref"), "GDestroyNotify"));
                } else {
-                       hash_table_new.add_argument (new CCodeIdentifier ("NULL"));
+                       hash_table_new.add_argument (new CCodeConstant ("NULL"));
                }
                ccode.add_assignment (new CCodeIdentifier (temp_name), hash_table_new);