mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-03-01 00:27:06 +00:00
2009-04-16 Christian Hoff <christian_hoff@gmx.net>
* glib/Value.cs: Support for additional fundamental GTypes. Invoke constructor of corresponding managed type to convert a GValue into its managed representation and a SetGValue method to do that vice versa. Patch contributed by Sebastian Dröge. svn path=/trunk/gtk-sharp/; revision=131931
This commit is contained in:
parent
005731b75c
commit
8fda284c32
|
@ -1,3 +1,10 @@
|
||||||
|
2009-04-16 Christian Hoff <christian_hoff@gmx.net>
|
||||||
|
|
||||||
|
* glib/Value.cs: Support for additional fundamental GTypes. Invoke
|
||||||
|
constructor of corresponding managed type to convert a GValue into
|
||||||
|
its managed representation and a SetGValue method to do that vice
|
||||||
|
versa. Patch contributed by Sebastian Dröge.
|
||||||
|
|
||||||
2009-04-15 Andrés G. Aragoneses <aaragoneses@novell.com>
|
2009-04-15 Andrés G. Aragoneses <aaragoneses@novell.com>
|
||||||
|
|
||||||
* atk/Makefile.am
|
* atk/Makefile.am
|
||||||
|
|
|
@ -338,6 +338,47 @@ namespace GLib {
|
||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object ToRegisteredType () {
|
||||||
|
Type t = GLib.GType.LookupType (type);
|
||||||
|
ConstructorInfo ci = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
while (ci == null && t != null) {
|
||||||
|
if (!t.IsAbstract)
|
||||||
|
ci = t.GetConstructor (new Type[] { typeof (GLib.Value) });
|
||||||
|
t = t.BaseType;
|
||||||
|
}
|
||||||
|
} catch (Exception) {
|
||||||
|
ci = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ci == null)
|
||||||
|
throw new Exception ("Unknown type " + new GType (type).ToString ());
|
||||||
|
|
||||||
|
return ci.Invoke (new object[] {this});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FromRegisteredType (object val) {
|
||||||
|
Type t = GLib.GType.LookupType (type);
|
||||||
|
MethodInfo mi = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
while (mi == null && t != null) {
|
||||||
|
mi = t.GetMethod ("SetGValue", new Type[] { typeof (GLib.Value) });
|
||||||
|
if (mi.IsAbstract)
|
||||||
|
mi = null;
|
||||||
|
t = t.BaseType;
|
||||||
|
}
|
||||||
|
} catch (Exception) {
|
||||||
|
mi = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mi == null)
|
||||||
|
throw new Exception ("Unknown type " + new GType (type).ToString ());
|
||||||
|
|
||||||
|
mi.Invoke (val, new object[] { this });
|
||||||
|
}
|
||||||
|
|
||||||
object ToBoxed ()
|
object ToBoxed ()
|
||||||
{
|
{
|
||||||
IntPtr boxed_ptr = g_value_get_boxed (ref this);
|
IntPtr boxed_ptr = g_value_get_boxed (ref this);
|
||||||
|
@ -390,6 +431,8 @@ namespace GLib {
|
||||||
return (GLib.Object) this;
|
return (GLib.Object) this;
|
||||||
else if (GType.Is (type, GType.Boxed))
|
else if (GType.Is (type, GType.Boxed))
|
||||||
return ToBoxed ();
|
return ToBoxed ();
|
||||||
|
else if (GType.LookupType (type) != null)
|
||||||
|
return ToRegisteredType ();
|
||||||
else if (type == IntPtr.Zero)
|
else if (type == IntPtr.Zero)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
@ -452,6 +495,8 @@ namespace GLib {
|
||||||
IntPtr buf = Marshaller.StructureToPtrAlloc (value);
|
IntPtr buf = Marshaller.StructureToPtrAlloc (value);
|
||||||
g_value_set_boxed (ref this, buf);
|
g_value_set_boxed (ref this, buf);
|
||||||
Marshal.FreeHGlobal (buf);
|
Marshal.FreeHGlobal (buf);
|
||||||
|
} else if (GLib.GType.LookupType (type) != null) {
|
||||||
|
FromRegisteredType (value);
|
||||||
} else
|
} else
|
||||||
throw new Exception ("Unknown type " + new GType (type).ToString ());
|
throw new Exception ("Unknown type " + new GType (type).ToString ());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue