2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>

* generator/InterfaceGen.cs: use the new GLib API to detect
	instances that don't implement GInterfaces.
	* glib/GType.cs: add new API for checking if an IntPtr instance
	implements a certain GType.
	[Fixes #448009]


svn path=/trunk/gtk-sharp/; revision=121990
This commit is contained in:
Andrés G. Aragoneses 2008-12-22 17:02:09 +00:00
parent 3a87d8d650
commit 8191911b26
3 changed files with 23 additions and 0 deletions

View file

@ -1,3 +1,11 @@
2008-12-22 Andrés G. Aragoneses <aaragoneses@novell.com>
* generator/InterfaceGen.cs: use the new GLib API to detect
instances that don't implement GInterfaces.
* glib/GType.cs: add new API for checking if an IntPtr instance
implements a certain GType.
[Fixes #448009]
2008-12-20 Stephane Delcroix <sdelcroix@novell.con>
* glib/Timeout.cs: map AddSeconds ().

View file

@ -177,6 +177,8 @@ namespace GtkSharp.Generation {
sw.WriteLine ();
sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)");
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tif (!GLib.GType.IsInstance (handle, _gtype))");
sw.WriteLine ("\t\t\t\tthrow new ArgumentException (\"The gobject doesn't implement the GInterface of this adapter\", \"handle\");");
sw.WriteLine ("\t\t\tthis.handle = handle;");
sw.WriteLine ("\t\t}");
sw.WriteLine ();

View file

@ -334,6 +334,16 @@ namespace GLib {
return Marshal.ReadIntPtr (klass);
}
internal static bool Is (IntPtr type, GType is_a_type)
{
return g_type_is_a (type, is_a_type.Val);
}
public static bool IsInstance (IntPtr raw, GType type)
{
return GType.Is (ValFromInstancePtr (raw), type);
}
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_type_class_peek (IntPtr gtype);
@ -354,5 +364,8 @@ namespace GLib {
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_type_register_static (IntPtr parent, IntPtr name, ref GTypeInfo info, int flags);
[DllImport("libgobject-2.0-0.dll")]
static extern bool g_type_is_a (IntPtr type, IntPtr is_a_type);
}
}