[vala] valac: Add --use-header command-line option
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] valac: Add --use-header command-line option
- Date: Fri, 9 Oct 2009 18:41:31 +0000 (UTC)
commit 931b465053c2f335feec73096030fb6110bca92f
Author: Jürg Billeter <j bitron ch>
Date: Fri Oct 9 20:40:03 2009 +0200
valac: Add --use-header command-line option
codegen/valaccodebasemodule.vala | 4 +++-
codegen/valaccodedeclarationspace.vala | 6 ++++--
codegen/valagtypemodule.vala | 2 +-
compiler/valacompiler.vala | 3 +++
vala/valacodecontext.vala | 2 ++
vala/valapropertyaccessor.vala | 4 ++++
6 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d5e60bf..457c404 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 696b0a4..175236e 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<string> declarations = new HashSet<string> (str_hash, str_equal);
Set<string> includes = new HashSet<string> (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 aa431d0..105e6dc 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 2b32f9d..f2b0234 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 3a1cbba..e6d9db3 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 2a21201..4d9340f 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<string> get_cheader_filenames () {
+ return parent_symbol.get_cheader_filenames ();
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]