Commits

Jeff Hardy committed 9c20db1

Use DefaultParameterValue instead of overloads.

Comments (0)

Files changed (3)

  * ***************************************************************************/
 
 using System;
+using System.Runtime.InteropServices;
 using ComponentAce.Compression.Libs.ZLib;
 using IronPython.Runtime;
 using IronPython.Runtime.Operations;
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
-        public string flush()
-        {
-            return flush(Z_FINISH);
-        }
-
-        public string flush(int mode)
+        public string flush([DefaultParameterValue(Z_FINISH)]int mode)
         {
             byte[] output = new byte[ZlibModule.DEFAULTALLOC];
 

src/Decompress.cs

  * ***************************************************************************/
 
 using System;
+using System.Runtime.InteropServices;
 using ComponentAce.Compression.Libs.ZLib;
 using IronPython.Runtime;
 using IronPython.Runtime.Operations;
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
-        public string flush()
-        {
-            return flush(ZlibModule.DEFAULTALLOC);
-        }
-
-        public string flush(int length)
+        public string flush([DefaultParameterValue(ZlibModule.DEFAULTALLOC)]int length)
         {
             if(length < 1)
                 throw PythonOps.ValueError("length must be greater than 0.");

src/ZlibModule.cs

 
         #endregion
 
-        #region compress
-
-        public static string compress(PythonBuffer data)
-        {
-            return compress(data, Z_DEFAULT_COMPRESSION);
-        }
-
-        public static string compress(PythonBuffer data, int level)
+        public static string compress(PythonBuffer data, 
+            [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
         {
             return compress(data.ToString(), level);
         }
 
-        public static string compress(string data)
-        {
-            return compress(data, Z_DEFAULT_COMPRESSION);
-        }
-
-        public static string compress(string data, int level)
+        public static string compress(string data,
+            [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
         {
             byte[] input = Latin1.GetBytes(data);
             byte[] output = new byte[input.Length + input.Length / 1000 + 12 + 1];
                 throw zlib_error(zst, err, "while finishing compression");
         }
 
-        #endregion
-
-        #region compressobj
-
-        public static Compress compressobj()
-        {
-            return compressobj(Z_DEFAULT_COMPRESSION, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
-        }
-
-        public static Compress compressobj(int level)
-        {
-            return new Compress(level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
-        }
-
-        public static Compress compressobj(int level, int method)
-        {
-            return new Compress(level, method, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
-        }
-
-        public static Compress compressobj(int level, int method, int wbits)
-        {
-            return new Compress(level, method, wbits, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);
-        }
-
-        public static Compress compressobj(int level, int method, int wbits, int memlevel)
-        {
-            return new Compress(level, method, wbits, memlevel, Z_DEFAULT_STRATEGY);
-        }
-
-        public static Compress compressobj(int level, int method, int wbits, int memlevel, int strategy)
+        public static Compress compressobj(
+            [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level,
+            [DefaultParameterValue(DEFLATED)]int method,
+            [DefaultParameterValue(MAX_WBITS)]int wbits,
+            [DefaultParameterValue(DEF_MEM_LEVEL)]int memlevel,
+            [DefaultParameterValue(Z_DEFAULT_STRATEGY)]int strategy)
         {
             return new Compress(level, method, wbits, memlevel, strategy);
         }
 
-        #endregion
-
-        #region decompress
-
-        public static string decompress(string data)
-        {
-            return decompress(data, MAX_WBITS, DEFAULTALLOC);
-        }
-
-        public static string decompress(string data, int wbits)
-        {
-            return decompress(data, wbits, DEFAULTALLOC);
-        }
-
-        public static string decompress(string data, int wbits, int bufsize)
+        public static string decompress(string data,
+            [DefaultParameterValue(MAX_WBITS)]int wbits,
+            [DefaultParameterValue(DEFAULTALLOC)]int bufsize)
         {
             byte[] input = Latin1.GetBytes(data);
 
             return Latin1.GetString(output, 0, outputOffset);
         }
 
-        #endregion
-
-        #region decompressobj
-
-        public static Decompress decompressobj()
-        {
-            return decompressobj(MAX_WBITS);
-        }
-
-        public static Decompress decompressobj(int wbits)
+        public static Decompress decompressobj([DefaultParameterValue(MAX_WBITS)]int wbits)
         {
             return new Decompress(wbits);
         }
 
-        #endregion
-
         [SpecialName]
         public static void PerformModuleReload(PythonContext context, PythonDictionary dict)
         {