Author: rolf
Date: 2007-06-18 12:59:04 -0400 (Mon, 18 Jun 2007)
New Revision: 80021

Modified:
   trunk/olive/class/agclr/System.Windows/ChangeLog
   trunk/olive/class/agclr/System.Windows/DependencyObject.cs
   trunk/olive/class/agclr/System.Windows/Duration.cs
Log:
* Duration.cs: Add an internal constructor and properties used by the
  marshaller.
* DependencyObject.cs: Fix Duration marshalling, the naive approach of
  using Marshal.PtrToStructure/StructureToPtr doesn't work because
  the managed structure layout isn't fixed. Also implement TimeSpan
  marshalling.

Modified: trunk/olive/class/agclr/System.Windows/ChangeLog
===================================================================
--- trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-18 16:38:51 UTC 
(rev 80020)
+++ trunk/olive/class/agclr/System.Windows/ChangeLog    2007-06-18 16:59:04 UTC 
(rev 80021)
@@ -1,5 +1,14 @@
 2007-06-18  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
 
+       * Duration.cs: Add an internal constructor and properties used by the
+         marshaller.
+       * DependencyObject.cs: Fix Duration marshalling, the naive approach of
+         using Marshal.PtrToStructure/StructureToPtr doesn't work because
+         the managed structure layout isn't fixed. Also implement TimeSpan
+         marshalling.
+
+2007-06-18  Rolf Bjarne Kvinge <[EMAIL PROTECTED]> 
+
        * Downloader.cs: Don't request events if we don't have a native object.
        * Inlines.cs: Construction implemented.
        * FontWeights.cs: Added.

Modified: trunk/olive/class/agclr/System.Windows/DependencyObject.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/DependencyObject.cs  2007-06-18 
16:38:51 UTC (rev 80020)
+++ trunk/olive/class/agclr/System.Windows/DependencyObject.cs  2007-06-18 
16:59:04 UTC (rev 80021)
@@ -285,7 +285,7 @@
                        IntPtr x = NativeMethods.dependency_object_get_value 
(native, property.native);
                        if (x == IntPtr.Zero){
                                if (!property.type.IsSubclassOf (typeof 
(Nullable)))
-                               Console.WriteLine ("Found null for object {0}, 
with property {1}");
+                                       Console.WriteLine ("Found null for 
object {0}, with property {1}", GetType ().FullName, "?");
                                
                                return null;
                        }
@@ -313,8 +313,14 @@
                                        return *((ulong *) px);
                                        
                                case Kind.INT64:
-                                       return *((long *) px);
-                                       
+                                       long v = *((long *) px); 
+                                       if (property.type == typeof (TimeSpan)) 
{
+                                               return new TimeSpan (v);
+                                       } else if (property.type == typeof 
(Nullable <TimeSpan>)) {
+                                               return  new Nullable <TimeSpan> 
(new TimeSpan (v));
+                                       } else {
+                                               return v;                       
                
+                                       }       
                                case Kind.INT32:
                                        return *((int *) px);
 
@@ -386,7 +392,10 @@
                                        if (vptr == IntPtr.Zero)
                                                return Duration.Automatic;
                                        
-                                       return (Duration) 
Marshal.PtrToStructure (vptr, typeof (Duration));                               
      
+                                       int kind = Marshal.ReadInt32 (vptr);
+                                       long ticks = Marshal.ReadInt64 
((IntPtr) ((byte*) vptr + 4));
+
+                                       return new Duration (kind, new TimeSpan 
(ticks));                                       
                                }
                                case Kind.REPEATBEHAVIOR:
                                {
@@ -458,6 +467,10 @@
                                } else if (v is long){
                                        value.k = Kind.INT64;
                                        *((long *) p) = (long) v;
+                               } else if (v is TimeSpan) {
+                                       TimeSpan ts = (TimeSpan) v;
+                                       value.k = Kind.INT64;
+                                       *((long *) p) = ts.Ticks;
                                } else if (v is ulong){
                                        value.k = Kind.UINT64;
                                        *((ulong *) p) = (ulong) v;
@@ -526,7 +539,8 @@
                                        Duration d = (Duration) v;
                                        value.k = Kind.DURATION;
                                        IntPtr result = Marshal.AllocHGlobal 
(sizeof (Duration));
-                                       Marshal.StructureToPtr (d, result, 
false);
+                                       Marshal.WriteInt32 (result, 
d.KindInternal);
+                                       Marshal.WriteInt64 ((IntPtr) ((byte*) 
result + 4), d.TimeSpanInternal.Ticks);
                                        *((IntPtr *) p) = result;
                                } else if (v is RepeatBehavior) {
                                        RepeatBehavior d = (RepeatBehavior) v;

Modified: trunk/olive/class/agclr/System.Windows/Duration.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/Duration.cs  2007-06-18 16:38:51 UTC 
(rev 80020)
+++ trunk/olive/class/agclr/System.Windows/Duration.cs  2007-06-18 16:59:04 UTC 
(rev 80021)
@@ -43,12 +43,26 @@
                static Duration automatic = new Duration (AUTOMATIC);
                static Duration forever = new Duration (FOREVER);
                
+               internal int KindInternal {
+                       get { return kind; }
+               }
+               
+               internal TimeSpan TimeSpanInternal {
+                       get { return time_span; }
+               }
+               
                internal Duration (int k)
                {
                        kind = k;
                        time_span = new TimeSpan (0);
                }
                
+               internal Duration (int k, TimeSpan ts)
+               {
+                       kind = k;
+                       time_span = ts;
+               }
+               
                public Duration (TimeSpan timeSpan)
                {
                        time_span = timeSpan;

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

Reply via email to