vala r948 - in trunk: . gobject vala



Author: juergbi
Date: Sat Feb  2 12:21:04 2008
New Revision: 948
URL: http://svn.gnome.org/viewvc/vala?rev=948&view=rev

Log:
2008-02-02  Juerg Billeter  <j bitron ch>

	* vala/valaproperty.vala, gobject/valaccodegeneratorinterface.vala:
	  support [Description (nick = "foo", blurb = "bar")] attribute,
	  based on patch by Juan Carlos Girardi, fixes part of bug 437434


Modified:
   trunk/ChangeLog
   trunk/gobject/valaccodegeneratorinterface.vala
   trunk/vala/valaproperty.vala

Modified: trunk/gobject/valaccodegeneratorinterface.vala
==============================================================================
--- trunk/gobject/valaccodegeneratorinterface.vala	(original)
+++ trunk/gobject/valaccodegeneratorinterface.vala	Sat Feb  2 12:21:04 2008
@@ -96,8 +96,8 @@
 	private CCodeFunctionCall! get_param_spec (Property! prop) {
 		var cspec = new CCodeFunctionCall ();
 		cspec.add_argument (prop.get_canonical_cconstant ());
-		cspec.add_argument (prop.get_canonical_cconstant ());
-		cspec.add_argument (prop.get_canonical_cconstant ());
+		cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick)));
+		cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
 		if ((prop.type_reference.data_type is Class && ((Class) prop.type_reference.data_type).is_subtype_of (gobject_type)) || prop.type_reference.data_type is Interface) {
 			cspec.call = new CCodeIdentifier ("g_param_spec_object");
 			cspec.add_argument (new CCodeIdentifier (prop.type_reference.data_type.get_upper_case_cname ("TYPE_")));

Modified: trunk/vala/valaproperty.vala
==============================================================================
--- trunk/vala/valaproperty.vala	(original)
+++ trunk/vala/valaproperty.vala	Sat Feb  2 12:21:04 2008
@@ -109,12 +109,39 @@
 	 * Specifies the abstract interface property this property implements.
 	 */
 	public Property base_interface_property { get; set; }
-	
+
+	/**
+	 * Nickname of this property.
+	 */
+	public string nick {
+		get {
+			if (_nick == null) {
+				_nick = get_canonical_name ();
+			}
+		}
+		set { _nick = value; }
+	}
+
+	/**
+	 * The long description of this property.
+	 */
+	public string blurb {
+		get {
+			if (_blurb == null) {
+				_blurb = get_canonical_name ();
+			}
+		}
+		set { _blurb = value; }
+	}
+
 	private bool lock_used = false;
 
 	private DataType _data_type;
 	private bool _instance = true;
 
+	private string? _nick;
+	private string? _blurb;
+
 	/**
 	 * Creates a new property.
 	 *
@@ -167,7 +194,11 @@
 	 * @return string literal to be used in C code
 	 */
 	public CCodeConstant! get_canonical_cconstant () {
-		var str = new String ("\"");
+		return new CCodeConstant ("\"%s\"".printf (get_canonical_name ()));
+	}
+
+	private string get_canonical_name () {
+		var str = new String ();
 		
 		string i = name;
 		
@@ -182,9 +213,7 @@
 			i = i.next_char ();
 		}
 		
-		str.append_c ('"');
-		
-		return new CCodeConstant (str.str);
+		return str.str;
 	}
 	
 	/**
@@ -196,7 +225,14 @@
 				notify = true;
 			} else if (a.name == "NoAccessorMethod") {
 				no_accessor_method = true;
-			}
+			} else if (a.name == "Description") {
+				if (a.has_argument ("nick")) {
+					nick = a.get_string ("nick");
+				}
+				if (a.has_argument ("blurb")) {
+					blurb = a.get_string ("blurb");
+				}
+			}			
 		}
 	}
 	



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