]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add required headers for ctor/dtor of compact classes and structs
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 21 Nov 2018 16:14:03 +0000 (17:14 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 21 Nov 2018 18:15:42 +0000 (19:15 +0100)
codegen/valaccodemethodmodule.vala
codegen/valaccodestructmodule.vala
codegen/valagtypemodule.vala

index 6bf75b3a953674150123fb6ff6ee7baa5f002117..19d03dce0169b6cce3992caf9b3dd510b9c3b9e3 100644 (file)
@@ -651,6 +651,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 
                                                if (!((CreationMethod) m).chain_up) {
                                                        // TODO implicitly chain up to base class as in add_object_creation
+                                                       // g_slice_new0 needs glib.h
+                                                       cfile.add_include ("glib.h");
                                                        var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_new0"));
                                                        ccall.add_argument (new CCodeIdentifier (get_ccode_name (cl)));
                                                        ccode.add_assignment (get_this_cexpression (), ccall);
index cfa9ef906c24e2b59ee6bd4b7ab4badd0ebc2fae..0e155f74d3f85a2ccc7037ad59d9338a86119d75 100644 (file)
@@ -215,11 +215,15 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                ccode.add_declaration (get_ccode_name (st) + "*", new CCodeVariableDeclarator ("dup"));
 
                if (context.profile == Profile.GOBJECT) {
+                       // g_new0 needs glib.h
+                       cfile.add_include ("glib.h");
                        var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
                        creation_call.add_argument (new CCodeConstant (get_ccode_name (st)));
                        creation_call.add_argument (new CCodeConstant ("1"));
                        ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
                } else if (context.profile == Profile.POSIX) {
+                       // calloc needs stdlib.h
+                       cfile.add_include ("stdlib.h");
                        var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
                        creation_call.add_argument (new CCodeConstant ("1"));
                        creation_call.add_argument (new CCodeIdentifier ("sizeof (%s*)".printf (get_ccode_name (st))));
@@ -270,10 +274,14 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
                }
 
                if (context.profile == Profile.GOBJECT) {
+                       // g_free needs glib.h
+                       cfile.add_include ("glib.h");
                        var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
                        free_call.add_argument (new CCodeIdentifier ("self"));
                        ccode.add_expression (free_call);
                } else if (context.profile == Profile.POSIX) {
+                       // free needs stdlib.h
+                       cfile.add_include ("stdlib.h");
                        var free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
                        free_call.add_argument (new CCodeIdentifier ("self"));
                        ccode.add_expression (free_call);
index 32e7bf07c5290a2ea7afe792657c645db78cdecf..3ce231702b42a041003edfc72fa252357d627656 100644 (file)
@@ -1854,6 +1854,8 @@ public class Vala.GTypeModule : GErrorModule {
                        cfile.add_function_declaration (instance_finalize_context.ccode);
                        cfile.add_function (instance_finalize_context.ccode);
                } else if (cl.base_class == null) {
+                       // g_slice_free needs glib.h
+                       cfile.add_include ("glib.h");
                        var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
                        ccall.add_argument (new CCodeIdentifier (get_ccode_name (cl)));
                        ccall.add_argument (new CCodeIdentifier ("self"));