vala r1392 - in trunk: . vala vapigen



Author: juergbi
Date: Fri May 16 21:45:07 2008
New Revision: 1392
URL: http://svn.gnome.org/viewvc/vala?rev=1392&view=rev

Log:
2008-05-16  Juerg Billeter  <j bitron ch>

	* vala/valaconstant.vala:
	* vala/valainterfacewriter.vala:
	* vapigen/valagidlparser.vala:

	Allow hiding constants in the metadata file for vapigen,
	based on patch by Ali Sabil


Modified:
   trunk/ChangeLog
   trunk/vala/valaconstant.vala
   trunk/vala/valainterfacewriter.vala
   trunk/vapigen/valagidlparser.vala

Modified: trunk/vala/valaconstant.vala
==============================================================================
--- trunk/vala/valaconstant.vala	(original)
+++ trunk/vala/valaconstant.vala	Fri May 16 21:45:07 2008
@@ -85,16 +85,26 @@
 	 */
 	public string get_cname () {
 		if (cname == null) {
-			if (parent_symbol == null) {
-				// global constant
-				cname = name;
-			} else {
-				cname = "%s%s".printf (parent_symbol.get_lower_case_cprefix ().up (), name);
-			}
+			cname = get_default_cname ();
 		}
 		return cname;
 	}
-	
+
+	/**
+	 * Returns the default name of this constant as it is used in C
+	 * code.
+	 *
+	 * @return the name to be used in C code by default
+	 */
+	public string get_default_cname () {
+		if (parent_symbol == null) {
+			// global constant
+			return name;
+		} else {
+			return "%s%s".printf (parent_symbol.get_lower_case_cprefix ().up (), name);
+		}
+	}
+
 	public bool get_lock_used () {
 		return lock_used;
 	}

Modified: trunk/vala/valainterfacewriter.vala
==============================================================================
--- trunk/vala/valainterfacewriter.vala	(original)
+++ trunk/vala/valainterfacewriter.vala	Fri May 16 21:45:07 2008
@@ -431,6 +431,11 @@
 			return;
 		}
 
+		if (c.get_cname () != c.get_default_cname ()) {
+			write_indent ();
+			write_string ("[CCode (cname = \"%s\")]".printf (c.get_cname ()));
+		}
+
 		write_indent ();
 		write_accessibility (c);
 		write_string ("const ");

Modified: trunk/vapigen/valagidlparser.vala
==============================================================================
--- trunk/vapigen/valagidlparser.vala	(original)
+++ trunk/vapigen/valagidlparser.vala	Fri May 16 21:45:07 2008
@@ -265,9 +265,11 @@
 				parse_interface ((IdlNodeInterface) node, ns, module);
 			} else if (node.type == IdlNodeTypeId.CONSTANT) {
 				var c = parse_constant ((IdlNodeConstant) node);
-				c.name = fix_const_name (c.name, ns);
-				ns.add_constant (c);
-				current_source_file.add_node (c);
+				if (c != null) {
+					c.name = fix_const_name (c.name, ns);
+					ns.add_constant (c);
+					current_source_file.add_node (c);
+				}
 			} else if (node.type == IdlNodeTypeId.FUNCTION) {
 				var m = parse_function ((IdlNodeFunction) node);
 				if (m != null) {
@@ -1565,7 +1567,19 @@
 		if (type == null) {
 			return null;
 		}
-		
+
+		string[] attributes = get_attributes (node.name);
+		if (attributes != null) {
+			foreach (string attr in attributes) {
+				var nv = attr.split ("=", 2);
+				if (nv[0] == "hidden") {
+					if (eval (nv[1]) == "1") {
+						return null;
+					}
+				}
+			}
+		}
+
 		var c = new Constant (node.name, type, null, current_source_reference);
 		c.access = SymbolAccessibility.PUBLIC;
 		



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