From 75d2981d8239674dfe697aba91d074be8888705a Mon Sep 17 00:00:00 2001
From: Mike Kestner <mkestner@gmail.com>
Date: Thu, 29 Nov 2007 20:01:28 +0000
Subject: [PATCH] 2007-11-29  Mike Kestner  <mkestner@novell.com>

	* generator/MethodBase.cs: move Name stuff from subclasses.
	Check for (G|S)et<UpperCaseLetter> in new Has props.
	* generator/Method.cs:
	* generator/VirtualMethod.cs: refactor out Name stuff. Use
	new Has(G|S)etterName props.
	* pango/Pango.metadata: workaround Has/Hash collision with
	the old broken getter check. [Fixes #344954]

svn path=/trunk/gtk-sharp/; revision=90458
---
 ChangeLog                  | 10 +++++++++
 generator/Method.cs        | 30 ++++---------------------
 generator/MethodBase.cs    | 45 ++++++++++++++++++++++++++++++++++++++
 generator/VirtualMethod.cs | 10 ++-------
 pango/Pango.metadata       |  1 +
 5 files changed, 62 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0e10ec49a..dfebee465 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-11-29  Mike Kestner  <mkestner@novell.com>
+
+	* generator/MethodBase.cs: move Name stuff from subclasses.
+	Check for (G|S)et<UpperCaseLetter> in new Has props.
+	* generator/Method.cs:
+	* generator/VirtualMethod.cs: refactor out Name stuff. Use
+	new Has(G|S)etterName props.
+	* pango/Pango.metadata: workaround Has/Hash collision with
+	the old broken getter check. [Fixes #344954]
+
 2007-11-29  Mike Kestner  <mkestner@novell.com>
 
 	* glib/Signal.cs: ignore GCHandles with null targets since
diff --git a/generator/Method.cs b/generator/Method.cs
index aa78adf0f..b5832f7af 100644
--- a/generator/Method.cs
+++ b/generator/Method.cs
@@ -32,7 +32,6 @@ namespace GtkSharp.Generation {
 		private ReturnValue retval;
 
 		private string call;
-		private string name;
 		private string protection = "public";
 		private bool is_get, is_set;
 		private bool deprecated = false;
@@ -42,9 +41,8 @@ namespace GtkSharp.Generation {
 			this.retval = new ReturnValue (elem["return-type"]);
 			if (!container_type.IsDeprecated && elem.HasAttribute ("deprecated"))
 				deprecated = elem.GetAttribute ("deprecated") == "1";
-			this.name = elem.GetAttribute("name");
-			if (name == "GetType")
-				name = "GetGType";
+			if (Name == "GetType")
+				Name = "GetGType";
 		}
 
 		public bool IsDeprecated {
@@ -65,15 +63,6 @@ namespace GtkSharp.Generation {
 			}
 		}
 
-		public string Name {
-			get {
-				return name;
-			}
-			set {
-				name = value;
-			}
-		}
-
 		public string Protection {
 			get {
 				return protection;
@@ -89,16 +78,6 @@ namespace GtkSharp.Generation {
 			}
 		}
 
-		string BaseName {
-			get {
-				string name = Name;
-				int idx = Name.LastIndexOf (".");
-				if (idx > 0)
-					name = Name.Substring (idx + 1);
-				return name;
-			}
-		}
-
 		public override bool Validate ()
 		{
 			if (!retval.Validate () || !base.Validate ()) {
@@ -106,10 +85,9 @@ namespace GtkSharp.Generation {
 				return false;
 			}
 
-			string name = BaseName;
 			Parameters parms = Parameters;
-			is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && name.Length > 3 && (name.StartsWith ("Get") || name.StartsWith ("Is") || name.StartsWith ("Has")));
-			is_set = ((parms.IsAccessor || (parms.VisibleCount == 1 && retval.IsVoid)) && (name.Length > 3 && name.Substring(0, 3) == "Set"));
+			is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
+			is_set = ((parms.IsAccessor || (parms.VisibleCount == 1 && retval.IsVoid)) && HasSetterName);
 
 			call = "(" + (IsStatic ? "" : container_type.CallByName () + (parms.Count > 0 ? ", " : "")) + Body.GetCallString (is_set) + ")";
 
diff --git a/generator/MethodBase.cs b/generator/MethodBase.cs
index cf359247b..7b24a9b71 100644
--- a/generator/MethodBase.cs
+++ b/generator/MethodBase.cs
@@ -32,17 +32,29 @@ namespace GtkSharp.Generation {
 		Parameters parms;
 		bool is_static = false;
 		string mods = String.Empty;
+		string name;
 
 		protected MethodBase (XmlElement elem, ClassBase container_type) 
 		{
 			this.elem = elem;
 			this.container_type = container_type;
+			this.name = elem.GetAttribute ("name");
 			parms = new Parameters (elem ["parameters"]);
 			IsStatic = elem.GetAttribute ("shared") == "true";
 			if (elem.HasAttribute ("new_flag"))
 				mods = "new ";
 		}
 
+		protected string BaseName {
+			get {
+				string name = Name;
+				int idx = Name.LastIndexOf (".");
+				if (idx > 0)
+					name = Name.Substring (idx + 1);
+				return name;
+			}
+		}
+
 		MethodBody body;
 		public MethodBody Body {
 			get {
@@ -58,6 +70,30 @@ namespace GtkSharp.Generation {
 			}
 		}
 
+		protected bool HasGetterName {
+			get {
+				string name = BaseName;
+				if (name.Length <= 3)
+					return false;
+				if (name.StartsWith ("Get") || name.StartsWith ("Has"))
+					return Char.IsUpper (name [3]);
+				else if (name.StartsWith ("Is"))
+					return Char.IsUpper (name [2]);
+				else
+					return false;
+			}
+		}
+
+		protected bool HasSetterName {
+			get {
+				string name = BaseName;
+				if (name.Length <= 3)
+					return false;
+
+				return name.StartsWith ("Set") && Char.IsUpper (name [3]);
+			}
+		}
+
 		public bool IsStatic {
 			get {
 				return is_static;
@@ -85,6 +121,15 @@ namespace GtkSharp.Generation {
 			}
 		}
 
+		public string Name {
+			get {
+				return name;
+			}
+			set {
+				name = value;
+			}
+		}
+
 		public Parameters Parameters {
 			get {
 				return parms;
diff --git a/generator/VirtualMethod.cs b/generator/VirtualMethod.cs
index 5ff690199..217f80100 100644
--- a/generator/VirtualMethod.cs
+++ b/generator/VirtualMethod.cs
@@ -42,13 +42,13 @@ namespace GtkSharp.Generation {
 
 		public bool IsGetter {
 			get {
-				return (Name.StartsWith ("Get") || Name.StartsWith ("Has")) && ((!retval.IsVoid && parms.Count == 1) || (retval.IsVoid && parms.Count == 2 && parms [1].PassAs == "out"));
+				return HasGetterName && ((!retval.IsVoid && parms.Count == 1) || (retval.IsVoid && parms.Count == 2 && parms [1].PassAs == "out"));
 			}
 		}
 	
 		public bool IsSetter {
 			get {
-				if (!Name.StartsWith ("Set") || !retval.IsVoid)
+				if (!HasSetterName || !retval.IsVoid)
 					return false;
 
 				if (parms.Count == 2 || (parms.Count == 4 && parms [1].Scope == "notified"))
@@ -64,12 +64,6 @@ namespace GtkSharp.Generation {
 			}
 		}
 
-		public string Name {
-			get {
-				return elem.GetAttribute("name");
-			}
-		}
-
 		public void GenerateCallback (StreamWriter sw)
 		{
 			if (!Validate ())
diff --git a/pango/Pango.metadata b/pango/Pango.metadata
index 6cf71636d..dad2ab664 100644
--- a/pango/Pango.metadata
+++ b/pango/Pango.metadata
@@ -8,6 +8,7 @@
   <attr path="/api/namespace/boxed[@cname='PangoFontDescription']/method[@name='CopyStatic']/return-type" name="owned">true</attr>
   <attr path="/api/namespace/boxed[@cname='PangoFontDescription']/method[@name='Free']" name="deprecated">1</attr>
   <attr path="/api/namespace/boxed[@cname='PangoFontDescription']/method[@name='FromString']/return-type" name="owned">true</attr>
+  <attr path="/api/namespace/boxed[@cname='PangoFontDescription']/method[@name='Hash']" name="name">GetHash</attr>
   <attr path="/api/namespace/boxed[@cname='PangoFontMetrics']/method[@name='Ref']" name="deprecated">1</attr>
   <attr path="/api/namespace/boxed[@cname='PangoFontMetrics']/method[@name='Unref']" name="deprecated">1</attr>
   <attr path="/api/namespace/boxed[@cname='PangoGlyphString']/field[@name='Glyphs']" name="hidden">1</attr>