Jeff Hardy avatar Jeff Hardy committed f71963c

Add docstrings.

Comments (0)

Files changed (3)

 using ComponentAce.Compression.Libs.ZLib;
 using IronPython.Runtime;
 using IronPython.Runtime.Operations;
+using Microsoft.Scripting.Runtime;
 
 namespace IronPython.Zlib
 {
             }
         }
 
+        [Documentation(@"compress(data) -- Return a string containing data compressed.
+
+After calling this function, some of the input data may still
+be stored in internal buffers for later processing.
+Call the flush() method to clear these buffers.")]
         public string compress(string data)
         {
             byte[] input = ZlibModule.Latin1.GetBytes(data);
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
+        [Documentation(@"flush( [mode] ) -- Return a string containing any remaining compressed data.
+
+mode can be one of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH; the
+default value used when mode is not specified is Z_FINISH.
+If mode == Z_FINISH, the compressor object can no longer be used after
+calling the flush() method.  Otherwise, more data can still be compressed.")]
         public string flush([DefaultParameterValue(Z_FINISH)]int mode)
         {
             byte[] output = new byte[ZlibModule.DEFAULTALLOC];
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
+        //[Documentation("copy() -- Return a copy of the compression object.")]
         //public Compress copy()
         //{
         //    throw new NotImplementedException();

src/Decompress.cs

 using ComponentAce.Compression.Libs.ZLib;
 using IronPython.Runtime;
 using IronPython.Runtime.Operations;
+using Microsoft.Scripting.Runtime;
 
 namespace IronPython.Zlib
 {
             return decompress(value, 0);
         }
 
+        [Documentation(@"decompress(data, max_length) -- Return a string containing the decompressed
+version of the data.
+
+After calling this function, some of the input data may still be stored in
+internal buffers for later processing.
+Call the flush() method to clear these buffers.
+If the max_length parameter is specified then the return value will be
+no longer than max_length.  Unconsumed input data will be stored in
+the unconsumed_tail attribute.")]
         public string decompress(string value, int max_length)
         {
             if(max_length < 0) throw new ArgumentException("max_length must be greater than zero");
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
+        [Documentation(@"flush( [length] ) -- Return a string containing any remaining
+decompressed data. length, if given, is the initial size of the
+output buffer.
+
+The decompressor object can no longer be used after this call.")]
         public string flush([DefaultParameterValue(ZlibModule.DEFAULTALLOC)]int length)
         {
             if(length < 1)
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
         }
 
+        //[Documentation("copy() -- Return a copy of the decompression object.")]
         //public Compress copy()
         //{
         //    throw new NotImplementedException();

src/ZlibModule.cs

 using IronPython.Runtime.Exceptions;
 using IronPython.Runtime.Operations;
 using IronPython.Runtime.Types;
+using Microsoft.Scripting.Runtime;
 
 [assembly: PythonModule("zlib", typeof(IronPython.Zlib.ZlibModule))]
 
 {
     public static class ZlibModule
     {
+        public const string __doc__ = @"The functions in this module allow compression and decompression using the
+zlib library, which is based on GNU zip.
+
+adler32(string[, start]) -- Compute an Adler-32 checksum.
+compress(string[, level]) -- Compress string, with compression level in 1-9.
+compressobj([level]) -- Return a compressor object.
+crc32(string[, start]) -- Compute a CRC-32 checksum.
+decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.
+decompressobj([wbits]) -- Return a decompressor object.
+
+'wbits' is window buffer size.
+Compressor objects support compress() and flush() methods; decompressor
+objects support decompress() and flush().";
+
         public const string ZLIB_VERSION = "1.2.3";     // just match the zlib version in Python 2.6
 
         internal const int Z_OK = (int)ZLibResultCode.Z_OK;
 
         internal const int DEFAULTALLOC = 16 * 1024;
 
-        #region adler32
+        [Documentation(@"adler32(string[, start]) -- Compute an Adler-32 checksum of string.
 
+An optional starting value can be specified.  The returned checksum is
+a signed integer.")]
         public static int adler32(string data, [DefaultParameterValue(1L)] long baseValue)
         {
             return adler32(Latin1.GetBytes(data), baseValue);
             return (int)Adler32.GetAdler32Checksum(baseValue, data, 0, data.Length);
         }
 
-        #endregion
+        [Documentation(@"crc32(string[, start]) -- Compute a CRC-32 checksum of string.
 
-        #region crc32
-
+An optional starting value can be specified.  The returned checksum is
+a signed integer.")]
         public static int crc32(string data, [DefaultParameterValue(0L)] long baseValue)
         {
             if(baseValue < int.MinValue || baseValue > uint.MaxValue)
                 return IronPython.Modules.PythonBinaryAscii.crc32(data, (int)baseValue);
         }
 
-        #endregion
 
         public static string compress(PythonBuffer data, 
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
             return compress(data.ToString(), level);
         }
 
+        [Documentation(@"compress(string[, level]) -- Returned compressed string.
+
+Optional arg level is the compression level, in 1-9.")]
         public static string compress(string data,
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level)
         {
                 throw zlib_error(zst, err, "while finishing compression");
         }
 
+        [Documentation(@"compressobj([level]) -- Return a compressor object.
+
+Optional arg level is the compression level, in 1-9.")]
         public static Compress compressobj(
             [DefaultParameterValue(Z_DEFAULT_COMPRESSION)]int level,
             [DefaultParameterValue(DEFLATED)]int method,
             return new Compress(level, method, wbits, memlevel, strategy);
         }
 
+        [Documentation(@"decompress(string[, wbits[, bufsize]]) -- Return decompressed string.
+
+Optional arg wbits is the window buffer size.  Optional arg bufsize is
+the initial output buffer size.")]
         public static string decompress(string data,
             [DefaultParameterValue(MAX_WBITS)]int wbits,
             [DefaultParameterValue(DEFAULTALLOC)]int bufsize)
             return Latin1.GetString(output, 0, outputOffset);
         }
 
+        [Documentation(@"decompressobj([wbits]) -- Return a decompressor object.
+
+Optional arg wbits is the window buffer size.")]
         public static Decompress decompressobj([DefaultParameterValue(MAX_WBITS)]int wbits)
         {
             return new Decompress(wbits);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.