From: Rob Taylor Date: Tue, 7 Apr 2009 15:17:50 +0000 (+0100) Subject: Add support for saving out the internal api as a vapi X-Git-Tag: 0.7.1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=097b3eb67e29fb68d6f4e06c5b0f311b984a1e63;p=thirdparty%2Fvala.git Add support for saving out the internal api as a vapi --- diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 0506388ba..50153e0ba 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -42,6 +42,7 @@ class Vala.Compiler { static bool ccode_only; static string header_filename; static string internal_header_filename; + static string internal_vapi_filename; static bool compile_only; static string output; static bool debug; @@ -75,6 +76,7 @@ class Vala.Compiler { { "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" }, { "internal-header", 'h', 0, OptionArg.FILENAME, ref internal_header_filename, "Output internal C header file", "FILE" }, + { "internal-vapi", 0, 0, OptionArg.FILENAME, ref target_glib, "Output vapi with internal api", "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" }, { "debug", 'g', 0, OptionArg.NONE, ref debug, "Produce debug information", null }, @@ -336,6 +338,19 @@ class Vala.Compiler { library = null; } + if (internal_vapi_filename != null) { + var interface_writer = new CodeWriter (false, true); + string vapi_filename = "%s.vapi".printf (internal_vapi_filename); + + // put .vapi file in current directory unless -d has been explicitly specified + if (directory != null && !Path.is_absolute (vapi_filename)) { + vapi_filename = "%s%c%s".printf (context.directory, Path.DIR_SEPARATOR, vapi_filename); + } + + interface_writer.write_file (context, vapi_filename); + + internal_vapi_filename = null; + } if (!ccode_only) { var ccompiler = new CCodeCompiler (); diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index d44a77d86..4ceebe18e 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -39,9 +39,11 @@ public class Vala.CodeWriter : CodeVisitor { Scope current_scope; bool dump_tree; + bool emit_internal; - public CodeWriter (bool dump_tree = false) { + public CodeWriter (bool dump_tree = false, bool emit_internal = false) { this.dump_tree = dump_tree; + this.emit_internal = emit_internal; } /** @@ -1644,10 +1646,19 @@ public class Vala.CodeWriter : CodeVisitor { } private bool check_accessibility (Symbol sym) { - if (dump_tree || - sym.access == SymbolAccessibility.PUBLIC || - sym.access == SymbolAccessibility.PROTECTED) { + if (dump_tree) { return true; + } else { + if (!emit_internal && + ( sym.access == SymbolAccessibility.PUBLIC || + sym.access == SymbolAccessibility.PROTECTED)) { + return true; + } else if (emit_internal && + ( sym.access == SymbolAccessibility.INTERNAL || + sym.access == SymbolAccessibility.PUBLIC || + sym.access == SymbolAccessibility.PROTECTED)) { + return true; + } } return false;