Modified conditional compilation syntax
authorKornél Pál <kornelpal@gmail.com>
Fri, 20 May 2005 15:14:01 +0000 (15:14 -0000)
committerKornél Pál <kornelpal@gmail.com>
Fri, 20 May 2005 15:14:01 +0000 (15:14 -0000)
svn path=/trunk/mcs/; revision=44821

mcs/class/System.Drawing/System.Drawing/ChangeLog
mcs/class/System.Drawing/System.Drawing/ComIStreamMarshaler.cs
mcs/class/System.Drawing/System.Drawing/ComIStreamWrapper.cs
mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs

index edb3d90c55af241e21c7a0adb8199d85c769b452..25a70aaacbea42f790514d48ff67d471b7c6408e 100644 (file)
@@ -1,7 +1,13 @@
+2005-05-16 Kornél Pál <kornelpal@hotmail.com>
+
+       * gdipFunctions.cs: Modified conditional compilation syntax
+       * ComIStreamWrapper.cs: Modified conditional compilation syntax
+       * ComIStreamMarshaler.cs: Modified conditional compilation syntax
+
 2005-05-18  Marek Safar  <marek.safar@seznam.cz>
 
        * Bitmap.cs: Add null check into ctor.
-\r
+
 2005-05-16 Jordi Mas i Hernandez <jordi@ximian.com> <kornelpal@hotmail.com>
 
        * gdipFunctions.cs: Kornél Pál's IStream bug fixing
index 194fa318fecada68cd3113f89950fc724a7fb1c8..3a350e6818e2cd6e436aec37f5ccdbca9bbaebb6 100644 (file)
@@ -3,6 +3,10 @@
 //
 // Author:
 //   Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2005 Kornél Pál
+//
+
 //
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
@@ -39,6 +43,8 @@ using System.Runtime.InteropServices;
 #if NET_2_0
 using System.Runtime.InteropServices.ComTypes;
 using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
 #endif
 
 namespace System.Drawing
@@ -58,13 +64,7 @@ namespace System.Drawing
                private delegate int WriteDelegate(IntPtr @this, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pv, int cb, IntPtr pcbWritten);
                private delegate int SeekDelegate(IntPtr @this, long dlibMove, int dwOrigin, IntPtr plibNewPosition);
                private delegate int SetSizeDelegate(IntPtr @this, long libNewSize);
-               private delegate int CopyToDelegate(IntPtr @this, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))]
-#if NET_2_0
-                       IStream
-#else
-                       UCOMIStream
-#endif
-                       pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten);
+               private delegate int CopyToDelegate(IntPtr @this, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten);
                private delegate int CommitDelegate(IntPtr @this, int grfCommitFlags);
                private delegate int RevertDelegate(IntPtr @this);
                private delegate int LockRegionDelegate(IntPtr @this, long libOffset, long cb, int dwLockType);
@@ -126,13 +126,7 @@ namespace System.Drawing
                        private static readonly IntPtr comVtable;
                        private static readonly VtableDestructor vtableDestructor;
 
-                       private readonly
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               managedInterface;
+                       private readonly IStream managedInterface;
                        private readonly IntPtr comInterface;
                        // Keeps the object alive when it has no managed references
                        private readonly GCHandle gcHandle;
@@ -164,13 +158,7 @@ namespace System.Drawing
                                vtableDestructor = new VtableDestructor();
                        }
 
-                       private ManagedToNativeWrapper(
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               managedInterface)
+                       private ManagedToNativeWrapper(IStream managedInterface)
                        {
                                IStreamInterface newInterface;
 
@@ -196,23 +184,11 @@ namespace System.Drawing
                                GC.SuppressFinalize(this);
                        }
 
-                       internal static
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               GetUnderlyingInterface(IntPtr comInterface, bool outParam)
+                       internal static IStream GetUnderlyingInterface(IntPtr comInterface, bool outParam)
                        {
                                if (Marshal.ReadIntPtr(comInterface) == comVtable)
                                {
-
-#if NET_2_0
-                                       IStream
-#else
-                                       UCOMIStream
-#endif
-                                               managedInterface = GetObject(comInterface).managedInterface;
+                                       IStream managedInterface = GetObject(comInterface).managedInterface;
 
                                        if (outParam)
                                                Release(comInterface);
@@ -223,13 +199,7 @@ namespace System.Drawing
                                        return null;
                        }
 
-                       internal static IntPtr CreateInterface(
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               managedInterface)
+                       internal static IntPtr CreateInterface(IStream managedInterface)
                        {
                                IntPtr comInterface;
 
@@ -409,13 +379,7 @@ namespace System.Drawing
 #endif
                        }
 
-                       private static int CopyTo(IntPtr @this,
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+                       private static int CopyTo(IntPtr @this, IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
                        {
 #if MAP_EX_TO_HR
                                try
@@ -524,12 +488,7 @@ namespace System.Drawing
                                try
                                {
 #endif
-#if NET_2_0
-                                       IStream
-#else
-                                       UCOMIStream
-#endif
-                                               newInterface;
+                                       IStream newInterface;
                                        IntPtr newWrapper;
 
                                        ppstm = IntPtr.Zero;
@@ -551,12 +510,7 @@ namespace System.Drawing
                }
 
                // Managed Runtime Callable Wrapper implementation
-               private sealed class NativeToManagedWrapper :
-#if NET_2_0
-                       IStream
-#else
-                       UCOMIStream
-#endif
+               private sealed class NativeToManagedWrapper : IStream
                {
                        private readonly IntPtr comInterface;
                        private readonly IStreamVtbl managedVtable;
@@ -582,13 +536,7 @@ namespace System.Drawing
                                GC.SuppressFinalize(this);
                        }
 
-                       internal static IntPtr GetUnderlyingInterface(
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               managedInterface)
+                       internal static IntPtr GetUnderlyingInterface(IStream managedInterface)
                        {
                                if (managedInterface is NativeToManagedWrapper)
                                {
@@ -601,44 +549,21 @@ namespace System.Drawing
                                        return IntPtr.Zero;
                        }
 
-                       internal static
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               CreateInterface(IntPtr comInterface, bool outParam)
+                       internal static IStream CreateInterface(IntPtr comInterface, bool outParam)
                        {
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                                       managedInterface;
+                               IStream managedInterface;
 
                                if (comInterface == IntPtr.Zero)
                                        return null;
 #if !RECURSIVE_WRAPPING
                                else if ((managedInterface = ManagedToNativeWrapper.GetUnderlyingInterface(comInterface, outParam)) == null)
 #endif
-                                       managedInterface = (
-#if NET_2_0
-                                               IStream
-#else
-                                               UCOMIStream
-#endif
-                                               )new NativeToManagedWrapper(comInterface, outParam);
+                                       managedInterface = (IStream)new NativeToManagedWrapper(comInterface, outParam);
 
                                return managedInterface;
                        }
 
-                       internal static void DisposeInterface(
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               managedInterface)
+                       internal static void DisposeInterface(IStream managedInterface)
                        {
                                if (managedInterface != null && managedInterface is NativeToManagedWrapper)
                                        ((NativeToManagedWrapper)managedInterface).Dispose();
@@ -671,13 +596,7 @@ namespace System.Drawing
                                CheckHResult(managedVtable.SetSize(comInterface, libNewSize));
                        }
 
-                       public void CopyTo(
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+                       public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
                        {
                                CheckHResult(managedVtable.CopyTo(comInterface, pstm, cb, pcbRead, pcbWritten));
                        }
@@ -707,13 +626,7 @@ namespace System.Drawing
                                CheckHResult(managedVtable.Stat(comInterface, out pstatstg, grfStatFlag));
                        }
 
-                       public void Clone(out
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               ppstm)
+                       public void Clone(out IStream ppstm)
                        {
                                IntPtr newInterface;
 
@@ -736,21 +649,9 @@ namespace System.Drawing
                public IntPtr MarshalManagedToNative(object managedObj)
                {
 #if RECURSIVE_WRAPPING
-                       managedObj = NativeToManagedWrapper.CreateInterface(ManagedToNativeWrapper.CreateInterface((
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
+                       managedObj = NativeToManagedWrapper.CreateInterface(ManagedToNativeWrapper.CreateInterface((IStream)managedObj), true);
 #endif
-                               )managedObj), true);
-#endif
-                       return ManagedToNativeWrapper.CreateInterface((
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               )managedObj);
+                       return ManagedToNativeWrapper.CreateInterface((IStream)managedObj);
                }
 
                public void CleanUpNativeData(IntPtr pNativeData)
@@ -768,13 +669,7 @@ namespace System.Drawing
 
                public void CleanUpManagedData(object managedObj)
                {
-                       NativeToManagedWrapper.DisposeInterface((
-#if NET_2_0
-                               IStream
-#else
-                               UCOMIStream
-#endif
-                               )managedObj);
+                       NativeToManagedWrapper.DisposeInterface((IStream)managedObj);
                }
 
                public int GetNativeDataSize()
index 56b3aad1fc0a06a9f76d2549caeca9c9c9815e53..d9bfa13fde876b07923bd9d5e93e31b2afe99b02 100644 (file)
@@ -3,6 +3,10 @@
 //
 // Author:
 //   Kornél Pál <http://www.kornelpal.hu/>
+//
+// Copyright (C) 2005 Kornél Pál
+//
+
 //
 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
 //
@@ -33,17 +37,14 @@ using System.Runtime.InteropServices;
 #if NET_2_0
 using System.Runtime.InteropServices.ComTypes;
 using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
 #endif
 
 namespace System.Drawing
 {
        // Stream to IStream wrapper for COM interop
-       internal sealed class ComIStreamWrapper :
-#if NET_2_0
-               IStream
-#else
-               UCOMIStream
-#endif
+       internal sealed class ComIStreamWrapper : IStream
        {
                private const int STG_E_INVALIDFUNCTION = unchecked((int)0x80030001);
 
@@ -140,13 +141,7 @@ namespace System.Drawing
                        baseStream.SetLength(libNewSize);
                }
 
-               public void CopyTo(
-#if NET_2_0
-                       IStream
-#else
-                       UCOMIStream
-#endif
-                       pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
+               public void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten)
                {
                        byte[] buffer = new byte[4096];
                        long written = 0;
@@ -201,13 +196,7 @@ namespace System.Drawing
                        pstatstg.cbSize = baseStream.Length;
                }
 
-               public void Clone(out
-#if NET_2_0
-                       IStream
-#else
-                       UCOMIStream
-#endif
-                       ppstm)
+               public void Clone(out IStream ppstm)
                {
                        ppstm = null;
                        throw new ExternalException(null, STG_E_INVALIDFUNCTION);
index 217a001bf90c778b0e1d9ad13b5b34163ae3b819..80210e3a1cc6a632756f05f7fae1e8d16bd9eba8 100644 (file)
 using System;
 using System.IO;
 using System.Runtime.InteropServices;
-#if NET_2_0
-using System.Runtime.InteropServices.ComTypes;
-#endif
 using System.Text;
 using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
 using System.Drawing.Text;
+#if NET_2_0
+using System.Runtime.InteropServices.ComTypes;
+#else
+using IStream = System.Runtime.InteropServices.UCOMIStream;
+#endif
 
 namespace System.Drawing
 {
@@ -914,22 +916,10 @@ namespace System.Drawing
                
                // Stream functions for Win32 (original Win32 ones)
                [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
-               internal static extern Status GdipLoadImageFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))]
-               #if NET_2_0
-               IStream
-               #else
-               UCOMIStream
-               #endif
-               stream, out IntPtr image);
+               internal static extern Status GdipLoadImageFromStream([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, out IntPtr image);
                
                [DllImport("gdiplus.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
-               internal static extern Status GdipSaveImageToStream(HandleRef image, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))]
-               #if NET_2_0
-               IStream
-               #else
-               UCOMIStream
-               #endif
-               stream, [In()] ref Guid clsidEncoder, HandleRef encoderParams);
+               internal static extern Status GdipSaveImageToStream(HandleRef image, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ComIStreamMarshaler))] IStream stream, [In()] ref Guid clsidEncoder, HandleRef encoderParams);
                
                                
                [DllImport("gdiplus.dll")]