[valadoc] driver/0.13: Add support for attributes



commit af142a9f2de1ddc118a0adcc59229b4e8b5e585e
Author: Florian Brosch <flo brosch gmail com>
Date:   Thu Aug 11 02:03:51 2011 +0200

    driver/0.13: Add support for attributes

 src/driver/0.13.x/treebuilder.vala |   65 +++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 1 deletions(-)
---
diff --git a/src/driver/0.13.x/treebuilder.vala b/src/driver/0.13.x/treebuilder.vala
index bb57e99..8b309e1 100644
--- a/src/driver/0.13.x/treebuilder.vala
+++ b/src/driver/0.13.x/treebuilder.vala
@@ -182,6 +182,55 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 	// Translation helpers:
 	//
 
+	private void process_attributes (Api.Symbol parent, GLib.List<Vala.Attribute> lst) {
+		// attributes wihtout arguments:
+		string[] attributes = {
+				"ReturnsModifiedPointer",
+				"DestroysInstance",
+				"NoAccessorMethod",
+				"NoArrayLength",
+				"Experimental",
+				"Diagnostics",
+				"PrintfFormat",
+				"PointerType",
+				"ScanfFormat",
+				"ThreadLocal",
+				"SimpleType",
+				"HasEmitter",
+				"ModuleInit",
+				"NoWrapper",
+				"Immutable",
+				"ErrorBase",
+				"NoReturn",
+				"NoThrow",
+				"Assert",
+				"Flags"
+			};
+
+		string? tmp = "";
+
+		foreach (Vala.Attribute att in lst) {
+			if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") {
+				Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
+				new_attribute.add_boolean ("has_target", false, att);
+				parent.add_attribute (new_attribute);
+			} else if (att.name == "Deprecated") {
+				Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
+				parent.add_attribute (new_attribute);
+				if ((tmp = att.args.get ("since")) != null) {
+					new_attribute.add_string ("since", tmp, att);
+				}
+
+				if ((tmp = att.args.get ("replacement")) != null) {
+					new_attribute.add_string ("replacement", tmp, att);
+				}
+			} else if (att.name in attributes) {
+				Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att);
+				parent.add_attribute (new_attribute);
+			}
+		}
+	}
+
 	private string get_ccode_type_id (Vala.Class node) {
 #if VALA_0_13_X
 		return Vala.CCodeBaseModule.get_ccode_type_id (node);
@@ -766,7 +815,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 	// Valadoc tree creation:
 	//
 
-	private void process_children (Api.Node node, Vala.Symbol element) {
+	private void process_children (Api.Node node, Vala.CodeNode element) {
 		Api.Node old_node = current_node;
 		current_node = node;
 		element.accept_children (this);
@@ -817,6 +866,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 			}
 		}
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 
 		// save GLib.Error
@@ -847,6 +897,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 			}
 		}
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -870,6 +921,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 			node.base_type = create_type_reference (basetype, node);
 		}
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -886,6 +938,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -913,6 +966,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 			node.setter = new PropertyAccessor (node, file, element.name, get_access_modifier(element), get_cname (element), get_property_accessor_type (accessor), get_property_ownership (accessor), accessor);
 		}
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -929,6 +983,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -945,6 +1000,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -961,6 +1017,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -977,6 +1034,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -992,6 +1050,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -1007,6 +1066,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -1023,6 +1083,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -1038,6 +1099,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 
@@ -1053,6 +1115,7 @@ public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor {
 		symbol_map.set (element, node);
 		parent.add_child (node);
 
+		process_attributes (node, element.attributes);
 		process_children (node, element);
 	}
 



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