Author: mkestner
Date: 2007-07-19 11:35:28 -0400 (Thu, 19 Jul 2007)
New Revision: 82293

Modified:
   trunk/gtk-sharp/ChangeLog
   trunk/gtk-sharp/generator/OpaqueGen.cs
   trunk/gtk-sharp/glib/Opaque.cs
Log:

2007-07-19  Mike Kestner  <[EMAIL PROTECTED]>

        * generator/OpaqueGen.cs : override the new Copy vm if a Copy method
        exists for the type.
        * glib/Opaque.cs : add a virtual method to allow subclasses with
        Copy methods to override.  Use the method in GetOpaque for unowned
        instantiations to try to obtain an owned instance. [Fixes #82037]


Modified: trunk/gtk-sharp/ChangeLog
===================================================================
--- trunk/gtk-sharp/ChangeLog   2007-07-19 15:30:33 UTC (rev 82292)
+++ trunk/gtk-sharp/ChangeLog   2007-07-19 15:35:28 UTC (rev 82293)
@@ -1,3 +1,11 @@
+2007-07-19  Mike Kestner  <[EMAIL PROTECTED]>
+
+       * generator/OpaqueGen.cs : override the new Copy vm if a Copy method
+       exists for the type.
+       * glib/Opaque.cs : add a virtual method to allow subclasses with
+       Copy methods to override.  Use the method in GetOpaque for unowned
+       instantiations to try to obtain an owned instance. [Fixes #82037]
+       
 2007-07-18  Mike Kestner  <[EMAIL PROTECTED]>
 
        * gdk/EventExpose.cs : return a pointer from the get_area glue

Modified: trunk/gtk-sharp/generator/OpaqueGen.cs
===================================================================
--- trunk/gtk-sharp/generator/OpaqueGen.cs      2007-07-19 15:30:33 UTC (rev 
82292)
+++ trunk/gtk-sharp/generator/OpaqueGen.cs      2007-07-19 15:35:28 UTC (rev 
82293)
@@ -129,6 +129,16 @@
                                }       
                        }
 
+                       Method copy = Methods ["Copy"] as Method;
+                       if (copy != null) {
+                               sw.WriteLine ("\t\tprotected override 
GLib.Opaque Copy (IntPtr raw)");
+                               sw.WriteLine ("\t\t{");
+                               sw.WriteLine ("\t\t\tGLib.Opaque result = new " 
+ QualifiedName + " (" + copy.CName + " (raw));");
+                               sw.WriteLine ("\t\t\tresult.Owned = true;");
+                               sw.WriteLine ("\t\t\treturn result;");
+                               sw.WriteLine ("\t\t}");
+                               sw.WriteLine ();
+                       }
                        sw.WriteLine ("#endregion");
                        
                        AppendCustom(sw, gen_info.CustomDir);

Modified: trunk/gtk-sharp/glib/Opaque.cs
===================================================================
--- trunk/gtk-sharp/glib/Opaque.cs      2007-07-19 15:30:33 UTC (rev 82292)
+++ trunk/gtk-sharp/glib/Opaque.cs      2007-07-19 15:35:28 UTC (rev 82293)
@@ -51,7 +51,9 @@
                                        opaque.Unref (o);
                                }
                                opaque.owned = true;
-                       }
+                       } else 
+                               opaque = opaque.Copy (o);
+
                        return opaque;
                }
   
@@ -100,6 +102,10 @@
                protected virtual void Ref (IntPtr raw) {}
                protected virtual void Unref (IntPtr raw) {}
                protected virtual void Free (IntPtr raw) {}
+               protected virtual Opaque Copy (IntPtr raw) 
+               {
+                       return this;
+               }
 
                public IntPtr Handle {
                        get {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to