From: Jürg Billeter Date: Fri, 9 Oct 2009 18:40:03 +0000 (+0200) Subject: valac: Add --use-header command-line option X-Git-Tag: 0.7.8~70 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=931b465053c2f335feec73096030fb6110bca92f;p=thirdparty%2Fvala.git valac: Add --use-header command-line option --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index d5e60bf80..457c404d1 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -354,7 +354,9 @@ internal class Vala.CCodeBaseModule : CCodeModule { } header_declarations = new CCodeDeclarationSpace (); + header_declarations.is_header = true; internal_header_declarations = new CCodeDeclarationSpace (); + internal_header_declarations.is_header = true; /* we're only interested in non-pkg source files */ var source_files = context.get_source_files (); @@ -1306,7 +1308,7 @@ internal class Vala.CCodeBaseModule : CCodeModule { } public void generate_property_accessor_declaration (PropertyAccessor acc, CCodeDeclarationSpace decl_space) { - if (decl_space.add_symbol_declaration (acc.prop, acc.get_cname ())) { + if (decl_space.add_symbol_declaration (acc, acc.get_cname ())) { return; } diff --git a/codegen/valaccodedeclarationspace.vala b/codegen/valaccodedeclarationspace.vala index 696b0a4e0..175236ef6 100644 --- a/codegen/valaccodedeclarationspace.vala +++ b/codegen/valaccodedeclarationspace.vala @@ -23,6 +23,8 @@ using Gee; class Vala.CCodeDeclarationSpace { + public bool is_header { get; set; } + Set declarations = new HashSet (str_hash, str_equal); Set includes = new HashSet (str_hash, str_equal); internal CCodeFragment include_directives = new CCodeFragment (); @@ -43,10 +45,10 @@ class Vala.CCodeDeclarationSpace { if (add_declaration (name)) { return true; } - if (sym.external_package) { + if (sym.external_package || (!is_header && CodeContext.get ().use_header && !sym.is_internal_symbol ())) { // add appropriate include file foreach (string header_filename in sym.get_cheader_filenames ()) { - add_include (header_filename); + add_include (header_filename, !sym.external_package); } // declaration complete return true; diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala index aa431d06e..105e6dcb9 100644 --- a/codegen/valagtypemodule.vala +++ b/codegen/valagtypemodule.vala @@ -345,7 +345,7 @@ internal class Vala.GTypeModule : GErrorModule { } void generate_class_private_declaration (Class cl, CCodeDeclarationSpace decl_space) { - if (decl_space.add_symbol_declaration (cl, cl.get_cname () + "Private")) { + if (decl_space.add_declaration (cl.get_cname () + "Private")) { return; } diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 2b32f9dad..f2b023408 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -43,6 +43,7 @@ class Vala.Compiler { static bool ccode_only; static string header_filename; + static bool use_header; static string internal_header_filename; static string internal_vapi_filename; static string includedir; @@ -85,6 +86,7 @@ class Vala.Compiler { { "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null }, { "ccode", 'C', 0, OptionArg.NONE, ref ccode_only, "Output C code", null }, { "header", 'H', 0, OptionArg.FILENAME, ref header_filename, "Output C header file", "FILE" }, + { "use-header", 0, 0, OptionArg.NONE, ref use_header, "Use C header file", null }, { "includedir", 0, 0, OptionArg.FILENAME, ref includedir, "Directory used to include the C header file", "DIRECTORY" }, { "internal-header", 'h', 0, OptionArg.FILENAME, ref internal_header_filename, "Output internal C header file", "FILE" }, { "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" }, @@ -195,6 +197,7 @@ class Vala.Compiler { context.ccode_only = ccode_only; context.compile_only = compile_only; context.header_filename = header_filename; + context.use_header = use_header; context.internal_header_filename = internal_header_filename; context.includedir = includedir; context.output = output; diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index 3a1cbbaa4..e6d9db3f5 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -72,6 +72,8 @@ public class Vala.CodeContext { */ public string? internal_header_filename { get; set; } + public bool use_header { get; set; } + /** * Base directory used for header_filename in the VAPIs. */ diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala index 2a2120127..4d9340f63 100644 --- a/vala/valapropertyaccessor.vala +++ b/vala/valapropertyaccessor.vala @@ -219,4 +219,8 @@ public class Vala.PropertyAccessor : Symbol { value_type = new_type; } } + + public override Gee.List get_cheader_filenames () { + return parent_symbol.get_cheader_filenames (); + } }