[mono/gtk-sharp] [5 commits] b13d51a3: generator: simplify bool logic in Method class

"Bertrand Lorentz ([email protected])" <[email protected]>
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <00000141e1c53be0-c3c433a5-6c95-4f6f-853b-55f3a179b31a-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/gtk-sharp
  Compare: https://github.com/mono/gtk-sharp/compare/a4c42994e8af...bd9cde5e61bb

   Commit: b13d51a32d6f96a8065183a2a94dfd46b5939dcc
   Author: Andrés G. Aragoneses <[email protected]> (knocte)
     Date: 2013-10-21 15:09:40 GMT
      URL: https://github.com/mono/gtk-sharp/commit/b13d51a32d6f96a8065183a2a94dfd46b5939dcc

generator: simplify bool logic in Method class

There are two elements repeated in this expression:

(( ((A) || (B)) || (B)) && C)

We can simplify "(A || B) || B" to simply "A || B",
so the result is a bit more readable this way:

(A || B) && C

Changed paths:
  M generator/Method.cs

Modified: generator/Method.cs
===================================================================
@@ -90,7 +90,7 @@ public override bool Validate (LogWriter log)
 			}
 
 			Parameters parms = Parameters;
-			is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
+			is_get = ((parms.IsAccessor && 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) + ")";

   Commit: fcc775d6583155d9ee48c7e5d80c3aef372f9467
   Author: Andrés G. Aragoneses <[email protected]> (knocte)
     Date: 2013-10-21 15:10:11 GMT
      URL: https://github.com/mono/gtk-sharp/commit/fcc775d6583155d9ee48c7e5d80c3aef372f9467

generator: drop unneeded parameter in WriteLine() call

Changed paths:
  M generator/InterfaceGen.cs

Modified: generator/InterfaceGen.cs
===================================================================
@@ -160,7 +160,7 @@ void GenerateCallbacks (StreamWriter sw)
 		void GenerateCtors (StreamWriter sw)
 		{
 			// Native GObjects do not implement the *Implementor interfaces
-			sw.WriteLine ("\t\tGLib.Object implementor;", Name);
+			sw.WriteLine ("\t\tGLib.Object implementor;");
 			sw.WriteLine ();
 
 			if (!IsConsumeOnly) {

   Commit: 516fc1d9f07b44551317a6dea56eef9e55b28a0c
   Author: Andrés G. Aragoneses <[email protected]> (knocte)
     Date: 2013-10-21 15:13:31 GMT
      URL: https://github.com/mono/gtk-sharp/commit/516fc1d9f07b44551317a6dea56eef9e55b28a0c

generator: leverage framework's String.IsNullOrEmpty() call

This makes the code a bit more readable and it is a
micro-optimization.

Changed paths:
  M generator/ReturnValue.cs

Modified: generator/ReturnValue.cs
===================================================================
@@ -87,7 +87,7 @@ public ReturnValue (XmlElement elem)
 
 		public string DefaultValue {
 			get {
-				if (default_value != null && default_value.Length > 0)
+				if (!String.IsNullOrEmpty (default_value))
 					return default_value;
 				if (IGen == null)
 					return String.Empty;

   Commit: 8eca15e8bdcace5ce7ce15f01b4b60a570ee2f6b
   Author: Andrés G. Aragoneses <[email protected]> (knocte)
     Date: 2013-10-22 12:06:12 GMT
      URL: https://github.com/mono/gtk-sharp/commit/8eca15e8bdcace5ce7ce15f01b4b60a570ee2f6b

glib: fix warning

`t` was not being used.

Changed paths:
  M glib/Value.cs

Modified: glib/Value.cs
===================================================================
@@ -552,7 +552,6 @@ public object Val
 
 		internal void Update (object val)
 		{
-			Type t = GType.LookupType (type);
 			if (GType.Is (type, GType.Boxed) && !(val is IWrapper)) {
 				MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance);
 				IntPtr boxed_ptr = g_value_get_boxed (ref this);

   Commit: bd9cde5e61bb31b75c818ebad14cb43453d36cdf
   Author: Bertrand Lorentz <[email protected]> (bl8)
     Date: 2013-10-22 19:52:08 GMT
      URL: https://github.com/mono/gtk-sharp/commit/bd9cde5e61bb31b75c818ebad14cb43453d36cdf

Merge pull request #82 from knocte/cleanup

Various small cleanups in generator and glib

Changed paths:
  M generator/InterfaceGen.cs
  M generator/Method.cs
  M generator/ReturnValue.cs
  M glib/Value.cs

Modified: generator/InterfaceGen.cs
===================================================================
@@ -160,7 +160,7 @@ void GenerateCallbacks (StreamWriter sw)
 		void GenerateCtors (StreamWriter sw)
 		{
 			// Native GObjects do not implement the *Implementor interfaces
-			sw.WriteLine ("\t\tGLib.Object implementor;", Name);
+			sw.WriteLine ("\t\tGLib.Object implementor;");
 			sw.WriteLine ();
 
 			if (!IsConsumeOnly) {

Modified: generator/Method.cs
===================================================================
@@ -90,7 +90,7 @@ public override bool Validate (LogWriter log)
 			}
 
 			Parameters parms = Parameters;
-			is_get = ((((parms.IsAccessor && retval.IsVoid) || (parms.Count == 0 && !retval.IsVoid)) || (parms.Count == 0 && !retval.IsVoid)) && HasGetterName);
+			is_get = ((parms.IsAccessor && 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) + ")";

Modified: generator/ReturnValue.cs
===================================================================
@@ -87,7 +87,7 @@ public ReturnValue (XmlElement elem)
 
 		public string DefaultValue {
 			get {
-				if (default_value != null && default_value.Length > 0)
+				if (!String.IsNullOrEmpty (default_value))
 					return default_value;
 				if (IGen == null)
 					return String.Empty;

Modified: glib/Value.cs
===================================================================
@@ -552,7 +552,6 @@ public object Val
 
 		internal void Update (object val)
 		{
-			Type t = GType.LookupType (type);
 			if (GType.Is (type, GType.Boxed) && !(val is IWrapper)) {
 				MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance);
 				IntPtr boxed_ptr = g_value_get_boxed (ref this);
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.