[vala/wip/attributes: 88/121] Move gir_name out of the code tree



commit eff0cf901efe56d099d6abc6fbe4b820f1a39774
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Jul 2 09:15:50 2011 +0200

    Move gir_name out of the code tree

 codegen/valagirwriter.vala |   36 +++++++++++++++++++++++++++++++++---
 vala/valaclass.vala        |    8 --------
 vala/valastruct.vala       |    8 --------
 vala/valasymbol.vala       |   40 ----------------------------------------
 4 files changed, 33 insertions(+), 59 deletions(-)
---
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index c7d7524..74be656 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -510,7 +510,11 @@ public class Vala.GIRWriter : CodeVisitor {
 				break;
 			}
 
-			gir_name = cur_sym.gir_name.concat (gir_name);
+			var cur_name = cur_sym.get_attribute_string ("GIR", "name");
+			if (cur_name == null) {
+				cur_name = cur_sym.name;
+			}
+			gir_name = cur_name.concat (gir_name);
 		}
 
 		return gir_name;
@@ -1134,17 +1138,43 @@ public class Vala.GIRWriter : CodeVisitor {
 		}
 	}
 
+	private string? get_full_gir_name (TypeSymbol sym) {
+		var gir_name = sym.get_attribute_string ("GIR", "name") ?? sym.name;
+		if (sym.parent_symbol == null) {
+			return gir_name;
+		}
+
+		if (sym.name == null) {
+			return get_full_gir_name (parent_symbol);
+		}
+
+		string parent_gir_name = get_full_gir_name (parent_symbol);
+		if (parent_gir_name == null) {
+			return gir_name;
+		}
+
+		string parent_gir_name = parent_symbol.get_full_gir_name ();
+		string self_gir_name = gir_name.has_prefix (".") ? gir_name.substring (1) : gir_name;
+		if ("." in parent_gir_name) {
+			return "%s%s".printf (parent_gir_name, self_gir_name);
+		} else {
+			return "%s.%s".printf (parent_gir_name, self_gir_name);
+		}
+	}
+
 	private string gi_type_name (TypeSymbol type_symbol) {
 		Symbol parent = type_symbol.parent_symbol;
 		if (parent is Namespace) {
 			Namespace ns = parent as Namespace;
-			if (ns.gir_name != null) {
+			var ns_gir_name = ns.get_attribute_string ("GIR", "name") ?? ns.name;
+			if (ns_gir_name != null) {
 				if (type_symbol.source_reference.file.gir_namespace != null) {
 					GIRNamespace external = GIRNamespace (type_symbol.source_reference.file.gir_namespace, type_symbol.source_reference.file.gir_version);
 					if (!externals.contains (external)) {
 						externals.add (external);
 					}
-					return "%s.%s".printf (type_symbol.source_reference.file.gir_namespace, type_symbol.gir_name);
+					var type_name = type_symbol.get_attribute_string ("GIR", "name") ?? type_symbol.name;
+					return "%s.%s".printf (type_symbol.source_reference.file.gir_namespace, type_name);
 				} else {
 					unannotated_namespaces.add(ns);
 				}
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index dbeae26..c44cf53 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -539,12 +539,6 @@ public class Vala.Class : ObjectTypeSymbol {
 		return true;
 	}
 
-	private void process_gir_attribute (Attribute a) {
-		if (a.has_argument ("name")) {
-			gir_name = a.get_string ("name");
-		}
-	}
-
 	/**
 	 * Process all associated attributes.
 	 */
@@ -556,8 +550,6 @@ public class Vala.Class : ObjectTypeSymbol {
 				is_immutable = true;
 			} else if (a.name == "Deprecated") {
 				process_deprecated_attribute (a);
-			} else if (a.name == "GIR") {
-				process_gir_attribute (a);
 			} else if (a.name == "Experimental") {
 				process_experimental_attribute (a);
 			}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 6b48328..e633db3 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -344,12 +344,6 @@ public class Vala.Struct : TypeSymbol {
 		}
 	}
 
-	private void process_gir_attribute (Attribute a) {
-		if (a.has_argument ("name")) {
-			gir_name = a.get_string ("name");
-		}
-	}
-
 	private void process_integer_type_attribute (Attribute a) {
 		if (a.has_argument ("width")) {
 			width = a.get_integer ("width");
@@ -381,8 +375,6 @@ public class Vala.Struct : TypeSymbol {
 				is_immutable = true;
 			} else if (a.name == "Deprecated") {
 				process_deprecated_attribute (a);
-			} else if (a.name == "GIR") {
-				process_gir_attribute (a);
 			} else if (a.name == "Experimental") {
 				process_experimental_attribute (a);
 			}
diff --git a/vala/valasymbol.vala b/vala/valasymbol.vala
index 7b40b9c..e91fc77 100644
--- a/vala/valasymbol.vala
+++ b/vala/valasymbol.vala
@@ -53,18 +53,6 @@ public abstract class Vala.Symbol : CodeNode {
 	}
 
 	/**
-	 * The GIR name.
-	 */
-	public string? gir_name {
-		get {
-			return _gir_name == null ? name : _gir_name;
-		}
-		set {
-			_gir_name = value;
-		}
-	}
-
-	/**
 	 * The symbol name.
 	 */
 	public string? name { get; set; }
@@ -191,7 +179,6 @@ public abstract class Vala.Symbol : CodeNode {
 
 	private weak Scope _owner;
 	private Scope _scope;
-	private string? _gir_name = null;
 
 	public Symbol (string? name, SourceReference? source_reference, Comment? comment = null) {
 		this.name = name;
@@ -199,34 +186,7 @@ public abstract class Vala.Symbol : CodeNode {
 		this.comment = comment;
 		_scope = new Scope (this);
 	}
-	
-	/**
-	 * Returns the fully expanded GIR name of this symbol
-	 *
-	 * @return full GIR name
-	 */
-	public string get_full_gir_name () {
-		if (parent_symbol == null) {
-			return gir_name;
-		}
-		
-		if (name == null) {
-			return parent_symbol.get_full_gir_name ();
-		}
 
-		if (parent_symbol.get_full_gir_name () == null) {
-			return gir_name;
-		}
-
-		string parent_gir_name = parent_symbol.get_full_gir_name ();
-		string self_gir_name = gir_name.has_prefix (".") ? gir_name.substring (1) : gir_name;
-		if ("." in parent_gir_name) {
-			return "%s%s".printf (parent_gir_name, self_gir_name);
-		} else {
-			return "%s.%s".printf (parent_gir_name, self_gir_name);
-		}
-	}
-	
 	/**
 	 * Returns the fully expanded name of this symbol for use in
 	 * human-readable messages.



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