[vala/0.10-parallel: 12/32] CodeWriter: Add CodeWriterType.FAST enum value



commit 009d5bbca9b5fc9a1371a13215633380c31ea9b3
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Aug 24 19:22:21 2010 +0200

    CodeWriter: Add CodeWriterType.FAST enum value
    
    Designed to emit .vapi files before the resolution stage has run.
    
    Includes 'using' in the output so that the resolver can figure it out
    later.
    
    Also includes the values of constants and enums so that headers are not
    required.

 vala/valacodewriter.vala |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index cd3a6a8..7889687 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -89,6 +89,12 @@ public class Vala.CodeWriter : CodeVisitor {
 		stream = null;
 	}
 
+	public override void visit_using_directive (UsingDirective ns) {
+		if (type == CodeWriterType.FAST) {
+			write_string ("using %s;\n".printf (ns.namespace_symbol.name));
+		}
+	}
+
 	public override void visit_namespace (Namespace ns) {
 		if (ns.external_package) {
 			return;
@@ -211,7 +217,7 @@ public class Vala.CodeWriter : CodeVisitor {
 		
 		write_string ("[CCode (");
 
-		if (cl.is_reference_counting ()) {
+		if (cl.is_reference_counting () && type != CodeWriterType.FAST) {
 			if (cl.base_class == null || cl.base_class.get_ref_function () == null || cl.base_class.get_ref_function () != cl.get_ref_function ()) {
 				write_string ("ref_function = \"%s\", ".printf (cl.get_ref_function ()));
 				if (cl.ref_function_void) {
@@ -555,6 +561,11 @@ public class Vala.CodeWriter : CodeVisitor {
 			}
 			write_indent ();
 			write_identifier (ev.name);
+
+			if (type == CodeWriterType.FAST && ev.value != null) {
+				write_string(" = ");
+				ev.value.accept (this);
+			}
 		}
 
 		if (!first) {
@@ -653,6 +664,10 @@ public class Vala.CodeWriter : CodeVisitor {
 			
 		write_string (" ");
 		write_identifier (c.name);
+		if (type == CodeWriterType.FAST && c.value != null) {
+			write_string(" = ");
+			c.value.accept (this);
+		}
 		write_string (";");
 		write_newline ();
 	}
@@ -1897,6 +1912,7 @@ public class Vala.CodeWriter : CodeVisitor {
 			       sym.access == SymbolAccessibility.PROTECTED;
 
 		case CodeWriterType.INTERNAL:
+		case CodeWriterType.FAST:
 			return sym.access == SymbolAccessibility.INTERNAL ||
 			       sym.access == SymbolAccessibility.PUBLIC ||
 			       sym.access == SymbolAccessibility.PROTECTED;
@@ -1959,5 +1975,6 @@ public class Vala.CodeWriter : CodeVisitor {
 public enum CodeWriterType {
 	EXTERNAL,
 	INTERNAL,
+	FAST,
 	DUMP
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]