]> 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>
Tue, 6 Apr 2021 11:00:16 +0000 (13:00 +0200)
codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valagtypemodule.vala
codegen/valagvariantmodule.vala

index 8eb995f20fd40083f54f0d316e49dbba2c09f638..7d23b8143388b2c351c161961f81f268b42b395d 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"));
@@ -650,7 +650,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        }
 
                        ccode.close ();
-                       ccode.add_return (new CCodeIdentifier ("NULL"));
+                       ccode.add_return (new CCodeConstant ("NULL"));
                }
 
                // append to file
index 2df631adcf1520b17f9bece8d1cec8b89968e16d..fc25b327f5f4639013ecda002eea8839afd25614 100644 (file)
@@ -785,7 +785,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                ccode.add_else ();
 
-               ccode.add_assignment (new CCodeIdentifier ("new_mem"), new CCodeIdentifier ("NULL"));
+               ccode.add_assignment (new CCodeIdentifier ("new_mem"), new CCodeConstant ("NULL"));
 
                ccode.close ();
 
@@ -1283,7 +1283,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"));
                                                        }
                                                }
                                        }
@@ -6061,7 +6061,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 dd8e149ae189abcd293587aab7dd479d9b9dc190..d60fcf0a3cb9e9916fdd684abbe56ca2e826cef4 100644 (file)
@@ -443,7 +443,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 daab41f5d42c75fa6f583573891f0b51fd5362fb..1a0e0d1b31f1994e8f6758c886808d4a3d3e76c6 100644 (file)
@@ -1011,7 +1011,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"));
@@ -1190,7 +1190,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);
@@ -2347,8 +2347,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 91a66881a3dab1a5989a5f09b48aec266c6f328c..2e4c4956ed039f6a62881b0748afa1d080c29ee2 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);
@@ -505,7 +505,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)) {
@@ -515,7 +515,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);