mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 15:45:38 +00:00
2004-01-27 Mike Kestner <mkestner@ximian.com>
* glib/TypeConverter.cs : lookup GTypes for boxed value types. * glib/Value.cs : fix boxed type handling in object ctor. [Fixes #51043] svn path=/trunk/gtk-sharp/; revision=22555
This commit is contained in:
parent
1742a837c1
commit
fc42fa2c04
|
@ -1,3 +1,9 @@
|
||||||
|
2004-01-27 Mike Kestner <mkestner@ximian.com>
|
||||||
|
|
||||||
|
* glib/TypeConverter.cs : lookup GTypes for boxed value types.
|
||||||
|
* glib/Value.cs : fix boxed type handling in object ctor.
|
||||||
|
[Fixes #51043]
|
||||||
|
|
||||||
2004-01-27 Mike Kestner <mkestner@ximian.com>
|
2004-01-27 Mike Kestner <mkestner@ximian.com>
|
||||||
|
|
||||||
* generator/BoxedGen.cs : gen a Value to Boxed explicit cast op.
|
* generator/BoxedGen.cs : gen a Value to Boxed explicit cast op.
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
namespace GLibSharp {
|
namespace GLibSharp {
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
using GLib;
|
using GLib;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -36,13 +37,16 @@ namespace GLibSharp {
|
||||||
return GType.Char;
|
return GType.Char;
|
||||||
if (type.Equals (typeof (uint)))
|
if (type.Equals (typeof (uint)))
|
||||||
return GType.UInt;
|
return GType.UInt;
|
||||||
if (type.IsValueType)
|
|
||||||
return GType.Pointer;
|
|
||||||
if (type.IsSubclassOf (typeof (GLib.Object)))
|
if (type.IsSubclassOf (typeof (GLib.Object)))
|
||||||
return GType.Object;
|
return GType.Object;
|
||||||
else if (type.IsSubclassOf (typeof (GLib.Boxed)))
|
if (type.IsValueType) {
|
||||||
return GType.Boxed;
|
PropertyInfo pi = type.GetProperty ("GType");
|
||||||
|
if (pi == null)
|
||||||
|
return GType.Pointer;
|
||||||
else
|
else
|
||||||
|
return (GType) pi.GetValue (null, null);
|
||||||
|
}
|
||||||
|
|
||||||
return GType.None;
|
return GType.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,6 +317,9 @@ namespace GLib {
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
static extern void g_value_set_boxed_take_ownership (IntPtr val, IntPtr data);
|
static extern void g_value_set_boxed_take_ownership (IntPtr val, IntPtr data);
|
||||||
|
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
static extern bool g_type_is_a (IntPtr type, IntPtr is_a_type);
|
||||||
|
|
||||||
IntPtr buf = IntPtr.Zero;
|
IntPtr buf = IntPtr.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -361,6 +364,10 @@ namespace GLib {
|
||||||
buf = Marshal.AllocHGlobal (Marshal.SizeOf (obj.GetType()));
|
buf = Marshal.AllocHGlobal (Marshal.SizeOf (obj.GetType()));
|
||||||
Marshal.StructureToPtr (obj, buf, false);
|
Marshal.StructureToPtr (obj, buf, false);
|
||||||
g_value_set_pointer (_val, buf);
|
g_value_set_pointer (_val, buf);
|
||||||
|
} else if (g_type_is_a (type.Val, GLib.GType.Boxed.Val)) {
|
||||||
|
buf = Marshal.AllocHGlobal (Marshal.SizeOf (obj.GetType()));
|
||||||
|
Marshal.StructureToPtr (obj, buf, false);
|
||||||
|
g_value_set_boxed (_val, buf);
|
||||||
} else
|
} else
|
||||||
throw new Exception ("Unknown type");
|
throw new Exception ("Unknown type");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue