Author: miguel
Date: 2007-06-19 13:28:49 -0400 (Tue, 19 Jun 2007)
New Revision: 80206

Modified:
   trunk/olive/class/agclr/ChangeLog
   trunk/olive/class/agclr/Internal.cs
   trunk/olive/class/agclr/Mono/NativeMethods.cs
Log:
i2007-06-19  Miguel de Icaza  <[EMAIL PROTECTED]>

        * Internal.cs: Implement collection iterators, the object version
        for now.



Modified: trunk/olive/class/agclr/ChangeLog
===================================================================
--- trunk/olive/class/agclr/ChangeLog   2007-06-19 17:12:46 UTC (rev 80205)
+++ trunk/olive/class/agclr/ChangeLog   2007-06-19 17:28:49 UTC (rev 80206)
@@ -1,3 +1,8 @@
+2007-06-19  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * Internal.cs: Implement collection iterators, the object version
+       for now.
+
 2007-06-19  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
        * agclr.dll.sources: Updated.

Modified: trunk/olive/class/agclr/Internal.cs
===================================================================
--- trunk/olive/class/agclr/Internal.cs 2007-06-19 17:12:46 UTC (rev 80205)
+++ trunk/olive/class/agclr/Internal.cs 2007-06-19 17:28:49 UTC (rev 80206)
@@ -28,6 +28,7 @@
 using Mono;
 using System;
 using System.Windows;
+using System.Collections;
 
 namespace MS.Internal {
        //
@@ -74,5 +75,49 @@
                {
                        return Kind.COLLECTION;
                }
+
+               public class CollectionIterator : IEnumerator {
+                       IntPtr native_iter;
+                       Kind   kind;
+                       
+                       public CollectionIterator(IntPtr native_iter, Kind k)
+                       {
+                               this.native_iter = native_iter;
+                               kind = k;
+                       }
+                       
+                       public bool MoveNext ()
+                       {
+                               return 
NativeMethods.collection_iterator_move_next (native_iter);
+                       }
+                       
+                       public void Reset ()
+                       {
+                               NativeMethods.collection_iterator_reset 
(native_iter);
+                       }
+
+                       public object Current {
+                               get {
+                                       IntPtr o = 
NativeMethods.collection_iterator_get_current (native_iter);
+
+                                       if (o == IntPtr.Zero)
+                                               return null;
+
+                                       return DependencyObject.Lookup (kind, 
o);
+                               }
+                       }
+
+                       ~CollectionIterator ()
+                       {
+                               // This is safe, as it only does a "delete" in 
the C++ side
+                               NativeMethods.collection_iterator_destroy 
(native_iter);
+                       }
+               }
+               
+               public IEnumerator GetEnumerator ()
+               {
+                       return new CollectionIterator 
(NativeMethods.collection_get_iterator (native),
+                                                      
NativeMethods.collection_get_element_type (native));
+               }
        }
 }

Modified: trunk/olive/class/agclr/Mono/NativeMethods.cs
===================================================================
--- trunk/olive/class/agclr/Mono/NativeMethods.cs       2007-06-19 17:12:46 UTC 
(rev 80205)
+++ trunk/olive/class/agclr/Mono/NativeMethods.cs       2007-06-19 17:28:49 UTC 
(rev 80206)
@@ -171,8 +171,26 @@
 
                [DllImport("moon")]
                internal extern static void collection_remove (IntPtr 
collection, IntPtr value);
+
+               [DllImport("moon")]
+               internal extern static IntPtr collection_get_iterator (IntPtr 
collection);
+
+               [DllImport("moon")]
+               internal extern static Kind collection_get_element_type (IntPtr 
collection);
                
                [DllImport("moon")]
+               internal extern static bool collection_iterator_move_next 
(IntPtr iterator);
+
+               [DllImport("moon")]
+               internal extern static void collection_iterator_reset (IntPtr 
iterator);
+
+               [DllImport("moon")]
+               internal extern static IntPtr collection_iterator_get_current 
(IntPtr iterator);
+
+               [DllImport("moon")]
+               internal extern static void collection_iterator_destroy (IntPtr 
iterator);
+               
+               [DllImport("moon")]
                internal extern static IntPtr resource_collection_new ();
                
                [DllImport("moon")]

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

Reply via email to