2004-05-18 Mike Kestner <mkestner@ximian.com>

* glib/MissingIntPtrCtorException.cs : new exception to throw if
	unable to access an IntPtr ctor on a GLib.Object subclass.  We need
	an IntPtr ctor to be able to wrap arbitrary object handles.
	* glib/Object.cs : have NativeType call LookupGType.
	* glib/ObjectManager.cs : throw the new exception in a try/catch.

svn path=/trunk/gtk-sharp/; revision=27563
This commit is contained in:
Mike Kestner 2004-05-18 05:06:10 +00:00
parent bfc77b2230
commit 0d052516f1
5 changed files with 37 additions and 5 deletions

View File

@ -1,3 +1,11 @@
2004-05-18 Mike Kestner <mkestner@ximian.com>
* glib/MissingIntPtrCtorException.cs : new exception to throw if
unable to access an IntPtr ctor on a GLib.Object subclass. We need
an IntPtr ctor to be able to wrap arbitrary object handles.
* glib/Object.cs : have NativeType call LookupGType.
* glib/ObjectManager.cs : throw the new exception in a try/catch.
2004-05-17 Mike Kestner <mkestner@ximian.com>
* generator/ObjectGen.cs : Generate a .cctor that calls the assembly's

View File

@ -26,6 +26,7 @@ sources = \
ManagedValue.cs \
Markup.cs \
Marshaller.cs \
MissingIntPtrCtorException.cs \
Object.cs \
ObjectManager.cs \
Opaque.cs \

View File

@ -0,0 +1,20 @@
// MissingIntPtrCtorException.cs : Exception for missing IntPtr ctors
//
// Authors: Mike Kestner <mkestner@ximian.com>
//
// Copyright (c) 2004 Novell, Inc.
namespace GLib {
using System;
using System.Runtime.InteropServices;
public class MissingIntPtrCtorException : Exception
{
public MissingIntPtrCtorException (string msg) : base (msg)
{
}
}
}

View File

@ -207,10 +207,7 @@ namespace GLib {
internal GLib.GType NativeType {
get {
if (_obj == IntPtr.Zero)
return GType.Invalid;
return new GLib.GType (gtksharp_get_type_id (_obj));
return LookupGType ();
}
}

View File

@ -40,7 +40,13 @@ namespace GtkSharp {
return null;
}
return (GLib.Object) Activator.CreateInstance (t, new object[] {raw});
GLib.Object obj;
try {
obj = (GLib.Object) Activator.CreateInstance (t, new object[] {raw});
} catch (MissingMethodException) {
throw new GLib.MissingIntPtrCtorException ("All GLib.Object subclasses must provide a protected or public IntPtr ctor to support wrapping of native object handles.");
}
return obj;
}
public static void RegisterType (string native_name, string managed_name, string assembly)