[vala/parallel] Add --fast-internal-vapi= commandline option
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/parallel] Add --fast-internal-vapi= commandline option
- Date: Wed, 18 Aug 2010 16:34:43 +0000 (UTC)
commit c9256352473f3732b4b351a89b227e2ae2cade8f
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Aug 18 12:28:28 2010 -0400
Add --fast-internal-vapi= commandline option
This emits a .vapi file without performing symbol resolution.
The 'using' directives are included directly into the vapi.
compiler/valacompiler.vala | 9 +++++++++
vala/valacodewriter.vala | 19 +++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala
index 6570d81..1885464 100644
--- a/compiler/valacompiler.vala
+++ b/compiler/valacompiler.vala
@@ -45,6 +45,7 @@ class Vala.Compiler {
static bool use_header;
static string internal_header_filename;
static string internal_vapi_filename;
+ static string fast_internal_vapi_filename;
static string symbols_filename;
static string includedir;
static bool compile_only;
@@ -95,6 +96,7 @@ class Vala.Compiler {
{ "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" },
+ { "fast-internal-vapi", 0, 0, OptionArg.STRING, ref fast_internal_vapi_filename, "Output vapi without performing symbol resolution", null },
{ "symbols", 0, 0, OptionArg.FILENAME, ref symbols_filename, "Output symbols file", "FILE" },
{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
{ "output", 'o', 0, OptionArg.FILENAME, ref output, "Place output in file FILE", "FILE" },
@@ -403,6 +405,13 @@ class Vala.Compiler {
if (context.report.get_errors () > 0) {
return quit ();
}
+
+ if (fast_internal_vapi_filename != null) {
+ var interface_writer = new CodeWriter (false, true);
+ interface_writer.set_emit_using (true);
+ interface_writer.write_file (context, fast_internal_vapi_filename);
+ return quit ();
+ }
var resolver = new SymbolResolver ();
resolver.resolve (context);
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 5b8ada0..08c8133 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -39,6 +39,7 @@ public class Vala.CodeWriter : CodeVisitor {
bool dump_tree;
bool emit_internal;
+ bool emit_using;
string? override_header = null;
string? header_to_override = null;
@@ -60,6 +61,14 @@ public class Vala.CodeWriter : CodeVisitor {
}
/**
+ * Allows emitting 'using' into the output
+ * @param enabled if using should be emitted
+ */
+ public void set_emit_using (bool enabled) {
+ emit_using = enabled;
+ }
+
+ /**
* Writes the public interface of the specified code context into the
* specified file.
*
@@ -91,6 +100,16 @@ public class Vala.CodeWriter : CodeVisitor {
stream = null;
}
+ public override void visit_using_directive (UsingDirective ns) {
+ if (emit_using) {
+ var symbol_name = ns.namespace_symbol.name;
+
+ if (symbol_name != "GLib") {
+ write_string ("using %s;\n".printf (symbol_name));
+ }
+ }
+ }
+
public override void visit_namespace (Namespace ns) {
if (ns.external_package) {
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]