]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add required includes or generate used symbols (POSIX)
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 19 Oct 2019 13:12:55 +0000 (15:12 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 19 Oct 2019 13:13:31 +0000 (15:13 +0200)
codegen/valaccodearraymodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala

index f8228b8cd711fd3d2a8ef502e9518e5315a4a63d..607deda3c201b1d9da037e08a60d84e4c32cebb1 100644 (file)
@@ -245,6 +245,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
                CCodeFunctionCall carrfree;
                if (context.profile == Profile.POSIX) {
+                       cfile.add_include ("stdlib.h");
                        carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
                } else {
                        carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
@@ -281,6 +282,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
        public override void append_vala_array_free () {
                // _vala_array_destroy only frees elements but not the array itself
+               generate_type_declaration (delegate_target_destroy_type, cfile);
 
                var fun = new CCodeFunction ("_vala_array_destroy", "void");
                fun.modifiers = CCodeModifiers.STATIC;
@@ -323,6 +325,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
                CCodeFunctionCall carrfree;
                if (context.profile == Profile.POSIX) {
+                       cfile.add_include ("stdlib.h");
                        carrfree = new CCodeFunctionCall (new CCodeIdentifier ("free"));
                } else {
                        carrfree = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
@@ -476,6 +479,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        }
 
                        requires_array_free = true;
+                       generate_type_declaration (delegate_target_destroy_type, cfile);
 
                        var ccall = new CCodeFunctionCall (get_destroy_func_expression (type));
 
@@ -561,6 +565,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
                        if (context.profile == Profile.POSIX) {
                                cfile.add_include ("stdlib.h");
+                               cfile.add_include ("string.h");
+
                                var alloc = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
                                alloc.add_argument (length_expr);
                                alloc.add_argument (sizeof_call);
index a80dfaf6f879e99311743fd7e06c37d17498b73a..849e3ac2b39f815daaa3c28267deee5b75e5eb98 100644 (file)
@@ -3212,6 +3212,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        CCodeFunctionCall free_call;
                        if (context.profile == Profile.POSIX) {
+                               cfile.add_include ("stdlib.h");
                                free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
                        } else {
                                free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
@@ -3324,6 +3325,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                        unref_function = generate_free_func_wrapper (type);
                                                } else {
                                                        if (context.profile == Profile.POSIX) {
+                                                               cfile.add_include ("stdlib.h");
                                                                unref_function = "free";
                                                        } else {
                                                                unref_function = "g_free";
@@ -3371,12 +3373,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        }
                } else if (type is ArrayType) {
                        if (context.profile == Profile.POSIX) {
+                               cfile.add_include ("stdlib.h");
                                return new CCodeIdentifier ("free");
                        } else {
                                return new CCodeIdentifier ("g_free");
                        }
                } else if (type is PointerType) {
                        if (context.profile == Profile.POSIX) {
+                               cfile.add_include ("stdlib.h");
                                return new CCodeIdentifier ("free");
                        } else {
                                return new CCodeIdentifier ("g_free");
@@ -3664,6 +3668,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                ccall.add_argument (csizeexpr);
                                        } else {
                                                requires_array_free = true;
+                                               generate_type_declaration (delegate_target_destroy_type, cfile);
+
                                                ccall.call = new CCodeIdentifier ("_vala_array_free");
                                                ccall.add_argument (csizeexpr);
                                                ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (array_type.element_type), get_ccode_name (delegate_target_destroy_type)));
index 5d28ee36561397deaa4f0aa4160d45b9206e98a9..1fa3aebb2308d0ff3cb6718e3fd51ef394ce8979 100644 (file)
@@ -991,6 +991,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
                ccode.add_expression (va_start);
 
+               if (context.profile == Profile.POSIX) {
+                       cfile.add_include ("stdio.h");
+               }
+
                var vsnprintf = new CCodeFunctionCall (new CCodeIdentifier ("vsnprintf"));
                vsnprintf.add_argument (new CCodeConstant ("NULL"));
                vsnprintf.add_argument (new CCodeConstant ("0"));