From: Raffaele Sandrini Date: Thu, 22 Mar 2007 09:57:14 +0000 (+0000) Subject: fix generation of unresolvable 'memset' for classes without strings. X-Git-Tag: VALA_0_0_8~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a35823589249880233d22af0b6801d60717510f8;p=thirdparty%2Fvala.git fix generation of unresolvable 'memset' for classes without strings. 2007-03-22 Raffaele Sandrini * vala/valacodegenerator.vala: fix generation of unresolvable 'memset' for classes without strings. svn path=/trunk/; revision=262 --- diff --git a/vala/ChangeLog b/vala/ChangeLog index 4ab151d04..fbf361d0f 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,8 @@ +2007-03-22 Raffaele Sandrini + + * vala/valacodegenerator.vala: fix generation of unresolvable 'memset' + for classes without strings. + 2007-03-21 Raffaele Sandrini * vapi/pango.vala: add Pango.Cairo and Pango.CairoFontMap diff --git a/vala/vala/valacodegenerator.vala b/vala/vala/valacodegenerator.vala index 3cbdf02c5..841e3779c 100644 --- a/vala/vala/valacodegenerator.vala +++ b/vala/vala/valacodegenerator.vala @@ -94,6 +94,8 @@ public class Vala.CodeGenerator : CodeVisitor { private bool in_plugin = false; private string module_init_param_name; + + private bool string_h_needed; public CodeGenerator (bool manage_memory = true) { memory_management = manage_memory; @@ -225,6 +227,8 @@ public class Vala.CodeGenerator : CodeVisitor { next_temp_var_id = 0; + string_h_needed = false; + header_begin.append (new CCodeIncludeDirective ("glib.h")); header_begin.append (new CCodeIncludeDirective ("glib-object.h")); source_include_directives.append (new CCodeIncludeDirective (source_file.get_cheader_filename (), true)); @@ -308,6 +312,10 @@ public class Vala.CodeGenerator : CodeVisitor { public override void visit_end_source_file (SourceFile! source_file) { var header_define = get_define_for_filename (source_file.get_cheader_filename ()); + if (string_h_needed) { + source_include_directives.append (new CCodeIncludeDirective ("string.h")); + } + CCodeComment comment = null; if (source_file.comment != null) { comment = new CCodeComment (source_file.comment); @@ -2030,6 +2038,9 @@ public class Vala.CodeGenerator : CodeVisitor { if (decl.initializer == null && decl.type_reference.data_type is Struct) { var st = (Struct) decl.type_reference.data_type; if (!st.is_reference_type () && st.get_fields ().length () > 0) { + /* memset needs string.h */ + string_h_needed = true; + var czero = new CCodeFunctionCall (new CCodeIdentifier ("memset")); czero.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (decl.name))); czero.add_argument (new CCodeConstant ("0"));