[vala/staging: 7/9] codegen: Add required headers for ctor/dtor of compact classes and structs
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 7/9] codegen: Add required headers for ctor/dtor of compact classes and structs
- Date: Wed, 21 Nov 2018 16:51:36 +0000 (UTC)
commit dea1e95e6f8424aa449ed83a723c0c1b5c30b910
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Nov 21 17:14:03 2018 +0100
codegen: Add required headers for ctor/dtor of compact classes and structs
codegen/valaccodemethodmodule.vala | 2 ++
codegen/valaccodestructmodule.vala | 8 ++++++++
codegen/valagtypemodule.vala | 2 ++
3 files changed, 12 insertions(+)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 6bf75b3a9..19d03dce0 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -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);
diff --git a/codegen/valaccodestructmodule.vala b/codegen/valaccodestructmodule.vala
index cfa9ef906..0e155f74d 100644
--- a/codegen/valaccodestructmodule.vala
+++ b/codegen/valaccodestructmodule.vala
@@ -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);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 32e7bf07c..3ce231702 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -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"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]