From: Rico Tzschichholz Date: Mon, 2 Mar 2020 20:05:38 +0000 (+0100) Subject: codegen: Add more "low-level" includes of "glib.h" X-Git-Tag: 0.48.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d86da975c0fd96fc310a55ab46d05959ccdde068;p=thirdparty%2Fvala.git codegen: Add more "low-level" includes of "glib.h" --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 4336fb37f..7ca0d007f 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -3112,6 +3112,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { csizeof.add_argument (new CCodeIdentifier (get_ccode_name (value_type.type_symbol))); creation_call.add_argument (csizeof); } else { + cfile.add_include ("glib.h"); creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0")); creation_call.add_argument (new CCodeIdentifier (get_ccode_name (value_type.type_symbol))); creation_call.add_argument (new CCodeConstant ("1")); @@ -3278,6 +3279,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { cfile.add_include ("stdlib.h"); free_call = new CCodeFunctionCall (new CCodeIdentifier ("free")); } else { + cfile.add_include ("glib.h"); free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free")); } free_call.add_argument (new CCodeIdentifier ("self")); @@ -3355,6 +3357,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { return new CCodeIdentifier (get_ccode_free_function (type.type_symbol)); } } else if (type is ErrorType) { + cfile.add_include ("glib.h"); return new CCodeIdentifier ("g_error_free"); } else if (type.type_symbol != null) { string unref_function; @@ -3391,6 +3394,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { cfile.add_include ("stdlib.h"); unref_function = "free"; } else { + cfile.add_include ("glib.h"); unref_function = "g_free"; } } @@ -3439,6 +3443,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { cfile.add_include ("stdlib.h"); return new CCodeIdentifier ("free"); } else { + cfile.add_include ("glib.h"); return new CCodeIdentifier ("g_free"); } } else if (type is PointerType) { @@ -3446,6 +3451,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { cfile.add_include ("stdlib.h"); return new CCodeIdentifier ("free"); } else { + cfile.add_include ("glib.h"); return new CCodeIdentifier ("g_free"); } } else { diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 191a4fc7f..f49b5555f 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -732,6 +732,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { * have a body, e.g. Vala.Parser.parse_file () */ if (m.body != null) { if (current_method_inner_error) { + cfile.add_include ("glib.h"); /* always separate error parameter and inner_error local variable * as error may be set to NULL but we're always interested in inner errors */ diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala index 75baa8b5a..057e982ba 100644 --- a/codegen/valagerrormodule.vala +++ b/codegen/valagerrormodule.vala @@ -123,6 +123,8 @@ public class Vala.GErrorModule : CCodeDelegateModule { append_local_free (current_symbol); } + cfile.add_include ("glib.h"); + var ccritical = new CCodeFunctionCall (new CCodeIdentifier ("g_critical")); ccritical.add_argument (new CCodeConstant (unexpected ? "\"file %s: line %d: unexpected error: %s (%s, %d)\"" : "\"file %s: line %d: uncaught error: %s (%s, %d)\"")); ccritical.add_argument (new CCodeConstant ("__FILE__")); @@ -363,6 +365,7 @@ public class Vala.GErrorModule : CCodeDelegateModule { ccode.add_assignment (get_variable_cexpression (get_local_cname (clause.error_variable)), get_inner_error_cexpression ()); } else { // error object is not used within catch statement, clear it + cfile.add_include ("glib.h"); var cclear = new CCodeFunctionCall (new CCodeIdentifier ("g_clear_error")); cclear.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_inner_error_cexpression ())); ccode.add_expression (cclear);