mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2009-07-12 Mike Kestner <mkestner@novell.com>
* glib/GType.cs: add ResolveType event and TypeResolutionHandler delegate declarations. This mechanism supports the lazy registration of type mappings by bindings. Patch from Sebastian with minor naming tweek. [Fixes #497667] svn path=/trunk/gtk-sharp/; revision=137759
This commit is contained in:
parent
45c8f24cdf
commit
c339d40680
@ -1,3 +1,9 @@
|
|||||||
|
2009-07-12 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/GType.cs: add ResolveType event and TypeResolutionHandler delegate
|
||||||
|
declarations. This mechanism supports the lazy registration of type mappings
|
||||||
|
by bindings. Patch from Sebastian with minor naming tweek. [Fixes #497667]
|
||||||
|
|
||||||
2009-07-12 Mike Kestner <mkestner@novell.com>
|
2009-07-12 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/Parameters.cs: another owned parameter patch from Sebastian.
|
* generator/Parameters.cs: another owned parameter patch from Sebastian.
|
||||||
|
@ -29,6 +29,8 @@ namespace GLib {
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
public delegate System.Type TypeResolutionHandler (GLib.GType gtype, string gtype_name);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct GType {
|
public struct GType {
|
||||||
|
|
||||||
@ -175,12 +177,29 @@ namespace GLib {
|
|||||||
// cctor already calls g_type_init.
|
// cctor already calls g_type_init.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static event TypeResolutionHandler ResolveType;
|
||||||
|
|
||||||
public static Type LookupType (IntPtr typeid)
|
public static Type LookupType (IntPtr typeid)
|
||||||
{
|
{
|
||||||
if (types.Contains (typeid))
|
if (types.Contains (typeid))
|
||||||
return (Type)types[typeid];
|
return (Type)types[typeid];
|
||||||
|
|
||||||
string native_name = Marshaller.Utf8PtrToString (g_type_name (typeid));
|
string native_name = Marshaller.Utf8PtrToString (g_type_name (typeid));
|
||||||
|
|
||||||
|
if (ResolveType != null) {
|
||||||
|
GLib.GType gt = new GLib.GType (typeid);
|
||||||
|
|
||||||
|
Delegate[] invocation_list = ResolveType.GetInvocationList ();
|
||||||
|
foreach (Delegate d in invocation_list) {
|
||||||
|
TypeResolutionHandler handler = (TypeResolutionHandler) d;
|
||||||
|
System.Type tmp = handler (gt, native_name);
|
||||||
|
if (tmp != null) {
|
||||||
|
Register (gt, tmp);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string type_name = GetQualifiedName (native_name);
|
string type_name = GetQualifiedName (native_name);
|
||||||
if (type_name == null)
|
if (type_name == null)
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user