diff --git a/ChangeLog b/ChangeLog index efff921a9..d3922a0f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-01 Mike Kestner + + * generator/InterfaceGen.cs: support "generic" interface + implementations like those exposed by gio. This is specifically for + libraries which return GTypes which are not exposed by the library + but which implement GInterfaces which are exposed by the library. + 2008-03-28 Andres G. Aragoneses * atk/Object.custom: custom properties for overriding class methods. diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index 4629064aa..bbc79342d 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -172,6 +172,11 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t\tthis.implementor = implementor;"); sw.WriteLine ("\t\t}"); sw.WriteLine (); + sw.WriteLine ("\t\tpublic " + Name + "Adapter (IntPtr handle)"); + sw.WriteLine ("\t\t{"); + sw.WriteLine ("\t\t\tthis.handle = handle;"); + sw.WriteLine ("\t\t}"); + sw.WriteLine (); } void GenerateGType (StreamWriter sw) @@ -188,8 +193,11 @@ namespace GtkSharp.Generation { void GenerateHandleProp (StreamWriter sw) { + sw.WriteLine ("\t\tIntPtr handle;"); sw.WriteLine ("\t\tpublic override IntPtr Handle {"); sw.WriteLine ("\t\t\tget {"); + sw.WriteLine ("\t\t\t\tif (handle != IntPtr.Zero)"); + sw.WriteLine ("\t\t\t\t\treturn handle;"); sw.WriteLine ("\t\t\t\treturn implementor == null ? IntPtr.Zero : implementor.Handle;"); sw.WriteLine ("\t\t\t}"); sw.WriteLine ("\t\t}"); @@ -203,6 +211,8 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t\tGLib.Object obj = GLib.Object.GetObject (handle, owned);"); sw.WriteLine ("\t\t\tif (obj is " + Name + "Implementor)"); sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj as {0}Implementor);", Name); + sw.WriteLine ("\t\t\telse if (obj as " + Name + " == null)"); + sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj.Handle);", Name); sw.WriteLine ("\t\t\telse"); sw.WriteLine ("\t\t\t\treturn obj as {0};", Name); sw.WriteLine ("\t\t}");