Branch: refs/heads/master
Home: https://github.com/mono/gtk-sharp
Compare: https://github.com/mono/gtk-sharp/compare/ea0708295204...b15f2eede1ec
Commit: b15f2eede1ec7db63eb60589851e1560cef3d98f
Author: Andrés G. Aragoneses <[email protected]> (knocte)
Committer: Bertrand Lorentz <[email protected]> (bl8)
Date: 2013-10-13 15:45:09 GMT
URL: https://github.com/mono/gtk-sharp/commit/b15f2eede1ec7db63eb60589851e1560cef3d98f
generator: provide a GType static property for adapters
In the same way all GLib.Object-derived classes provided by the
generator have a GType static property (i.e. Gtk.Widget), we need
the same for the *Adapter classes, to access their GType without having
an instance of it. (The first use case would be GStreamerSharp's
Gst.Bin.IterateAllByInterface ().)
For this, we cannot simply add the property to all adapter classes
and be done, because it would clash with a property which is already
there, but is non-static, that has the same name and same value
(this property is needed for complying GInterfaceAdapter abstract
class), so we rename this property to GInterfaceGType because
using this name for the static one would not be consistent with the
rest of the classes generated which already provide the static one
with the name "GType".
Changed paths:
M generator/InterfaceGen.cs
M glib/GInterfaceAdapter.cs
M glib/Object.cs
M glib/Value.cs
Modified: generator/InterfaceGen.cs
===================================================================
@@ -197,11 +197,22 @@ void GenerateGType (StreamWriter sw)
m.GenerateImport (sw);
sw.WriteLine ("\t\tprivate static GLib.GType _gtype = new GLib.GType ({0} ());", m.CName);
sw.WriteLine ();
- sw.WriteLine ("\t\tpublic override GLib.GType GType {");
+
+ // by convention, all GTypes generated have a static GType property
+ sw.WriteLine ("\t\tpublic static GLib.GType GType {");
+ sw.WriteLine ("\t\t\tget {");
+ sw.WriteLine ("\t\t\t\treturn _gtype;");
+ sw.WriteLine ("\t\t\t}");
+ sw.WriteLine ("\t\t}");
+ sw.WriteLine ();
+
+ // we need same property but non-static, because it is being accessed via a GInterfaceAdapter instance
+ sw.WriteLine ("\t\tpublic override GLib.GType GInterfaceGType {");
sw.WriteLine ("\t\t\tget {");
sw.WriteLine ("\t\t\t\treturn _gtype;");
sw.WriteLine ("\t\t\t}");
sw.WriteLine ("\t\t}");
+
sw.WriteLine ();
}
Modified: glib/GInterfaceAdapter.cs
===================================================================
@@ -50,7 +50,7 @@ protected GInterfaceAdapter ()
}
}
- public abstract GType GType { get; }
+ public abstract GType GInterfaceGType { get; }
public abstract IntPtr Handle { get; }
Modified: glib/Object.cs
===================================================================
@@ -225,7 +225,7 @@ private void AddGInterfaces ()
if (!iface.IsAssignableFrom (Type.BaseType)) {
GInterfaceInfo info = adapter.Info;
info.Data = gtype.Val;
- g_type_add_interface_static (gtype.Val, adapter.GType.Val, ref info);
+ g_type_add_interface_static (gtype.Val, adapter.GInterfaceGType.Val, ref info);
adapters.Add (adapter);
}
}
@@ -341,7 +341,7 @@ void AddInterfaceProperties ()
PropertyInfo declared_prop = Type.GetProperty (p.Name, BindingFlags.Public | BindingFlags.Instance);
if (declared_prop == null)
continue;
- IntPtr param_spec = FindInterfaceProperty (adapter.GType, property_attr.Name);
+ IntPtr param_spec = FindInterfaceProperty (adapter.GInterfaceGType, property_attr.Name);
Dictionary<IntPtr, PropertyInfo> props;
if (!Properties.TryGetValue (Type, out props)) {
Modified: glib/Value.cs
===================================================================
@@ -134,7 +134,7 @@ public Value (GLib.Object val) : this (val == null ? GType.Object : val.NativeTy
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
- public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GType)
+ public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GInterfaceGType)
{
g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle);
}
_______________________________________________
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.