From b13d51a32d6f96a8065183a2a94dfd46b5939dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Mon, 21 Oct 2013 17:09:40 +0200 Subject: [PATCH 1/4] 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 --- generator/Method.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/Method.cs b/generator/Method.cs index 4e8e08161..14f0b65ec 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -90,7 +90,7 @@ namespace GtkSharp.Generation { } 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) + ")"; From fcc775d6583155d9ee48c7e5d80c3aef372f9467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Mon, 21 Oct 2013 17:10:11 +0200 Subject: [PATCH 2/4] generator: drop unneeded parameter in WriteLine() call --- generator/InterfaceGen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index c6cecdf16..7b66cc837 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -160,7 +160,7 @@ namespace GtkSharp.Generation { 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) { From 516fc1d9f07b44551317a6dea56eef9e55b28a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Mon, 21 Oct 2013 17:13:31 +0200 Subject: [PATCH 3/4] generator: leverage framework's String.IsNullOrEmpty() call This makes the code a bit more readable and it is a micro-optimization. --- generator/ReturnValue.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/ReturnValue.cs b/generator/ReturnValue.cs index 9815d0764..f700e668a 100644 --- a/generator/ReturnValue.cs +++ b/generator/ReturnValue.cs @@ -87,7 +87,7 @@ namespace GtkSharp.Generation { 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; From 8eca15e8bdcace5ce7ce15f01b4b60a570ee2f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20G=2E=20Aragoneses?= Date: Tue, 22 Oct 2013 14:06:12 +0200 Subject: [PATCH 4/4] glib: fix warning `t` was not being used. --- glib/Value.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/glib/Value.cs b/glib/Value.cs index c3a39d19d..cf653d6c7 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -552,7 +552,6 @@ namespace GLib { 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);