core/src/main/java/org/jruby/ext/zlib/RubyZlib.java
public static RubyModule createZlibModule(Ruby runtime) {
        RubyModule mZlib = runtime.defineModule("Zlib");
        mZlib.defineAnnotatedMethods(RubyZlib.class);

        RubyClass cStandardError = runtime.getStandardError();
        RubyClass cZlibError = mZlib.defineOrGetClassUnder("Error", cStandardError, cStandardError.getAllocator());
        mZlib.defineOrGetClassUnder("StreamEnd", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("StreamError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("BufError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("NeedDict", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("MemError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("VersionError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("DataError", cZlibError, cZlibError.getAllocator());

        RubyClass cGzFile = mZlib.defineOrGetClassUnder("GzipFile", runtime.getObject(), RubyGzipFile::new);
        cGzFile.defineAnnotatedMethods(RubyGzipFile.class);

        cGzFile.defineOrGetClassUnder("Error", cZlibError, cZlibError.getAllocator());
        RubyClass cGzError = cGzFile.defineOrGetClassUnder("Error", cZlibError, cZlibError.getAllocator());
        cGzError.addReadAttribute(runtime.getCurrentContext(), "input");
        cGzFile.defineOrGetClassUnder("CRCError", cGzError, cGzError.getAllocator());
        cGzFile.defineOrGetClassUnder("NoFooter", cGzError, cGzError.getAllocator());
        cGzFile.defineOrGetClassUnder("LengthError", cGzError, cGzError.getAllocator());

        RubyClass cGzReader = mZlib.defineOrGetClassUnder("GzipReader", cGzFile, JZlibRubyGzipReader::new);
        cGzReader.includeModule(runtime.getEnumerable());
        cGzReader.defineAnnotatedMethods(JZlibRubyGzipReader.class);

        RubyClass cGzWriter = mZlib.defineOrGetClassUnder("GzipWriter", cGzFile, JZlibRubyGzipWriter::new);
        cGzWriter.defineAnnotatedMethods(JZlibRubyGzipWriter.class);

        mZlib.defineConstant("ZLIB_VERSION", runtime.newString(ZLIB_VERSION));
        mZlib.defineConstant("VERSION", runtime.newString(VERSION));

        mZlib.defineConstant("BINARY", runtime.newFixnum(Z_BINARY));
        mZlib.defineConstant("ASCII", runtime.newFixnum(Z_ASCII));
        mZlib.defineConstant("UNKNOWN", runtime.newFixnum(Z_UNKNOWN));

        mZlib.defineConstant("DEF_MEM_LEVEL", runtime.newFixnum(8));
        mZlib.defineConstant("MAX_MEM_LEVEL", runtime.newFixnum(9));

        mZlib.defineConstant("OS_UNIX", runtime.newFixnum(OS_UNIX));
        mZlib.defineConstant("OS_UNKNOWN", runtime.newFixnum(OS_UNKNOWN));
        mZlib.defineConstant("OS_CODE", runtime.newFixnum(OS_CODE));
        mZlib.defineConstant("OS_ZSYSTEM", runtime.newFixnum(OS_ZSYSTEM));
        mZlib.defineConstant("OS_VMCMS", runtime.newFixnum(OS_VMCMS));
        mZlib.defineConstant("OS_VMS", runtime.newFixnum(OS_VMS));
        mZlib.defineConstant("OS_RISCOS", runtime.newFixnum(OS_RISCOS));
        mZlib.defineConstant("OS_MACOS", runtime.newFixnum(OS_MACOS));
        mZlib.defineConstant("OS_OS2", runtime.newFixnum(OS_OS2));
        mZlib.defineConstant("OS_AMIGA", runtime.newFixnum(OS_AMIGA));
        mZlib.defineConstant("OS_QDOS", runtime.newFixnum(OS_QDOS));
        mZlib.defineConstant("OS_WIN32", runtime.newFixnum(OS_WIN32));
        mZlib.defineConstant("OS_ATARI", runtime.newFixnum(OS_ATARI));
        mZlib.defineConstant("OS_MSDOS", runtime.newFixnum(OS_MSDOS));
        mZlib.defineConstant("OS_CPM", runtime.newFixnum(OS_CPM));
        mZlib.defineConstant("OS_TOPS20", runtime.newFixnum(OS_TOPS20));

        mZlib.defineConstant("DEFAULT_STRATEGY", runtime.newFixnum(JZlib.Z_DEFAULT_STRATEGY));
        mZlib.defineConstant("FILTERED", runtime.newFixnum(JZlib.Z_FILTERED));
        mZlib.defineConstant("HUFFMAN_ONLY", runtime.newFixnum(JZlib.Z_HUFFMAN_ONLY));

        mZlib.defineConstant("NO_FLUSH", runtime.newFixnum(JZlib.Z_NO_FLUSH));
        mZlib.defineConstant("SYNC_FLUSH", runtime.newFixnum(JZlib.Z_SYNC_FLUSH));
        mZlib.defineConstant("FULL_FLUSH", runtime.newFixnum(JZlib.Z_FULL_FLUSH));
        mZlib.defineConstant("FINISH", runtime.newFixnum(JZlib.Z_FINISH));

        mZlib.defineConstant("NO_COMPRESSION", runtime.newFixnum(JZlib.Z_NO_COMPRESSION));
        mZlib.defineConstant("BEST_SPEED", runtime.newFixnum(JZlib.Z_BEST_SPEED));
        mZlib.defineConstant("DEFAULT_COMPRESSION", runtime.newFixnum(JZlib.Z_DEFAULT_COMPRESSION));
        mZlib.defineConstant("BEST_COMPRESSION", runtime.newFixnum(JZlib.Z_BEST_COMPRESSION));

        mZlib.defineConstant("MAX_WBITS", runtime.newFixnum(JZlib.MAX_WBITS));

        // ZStream actually *isn't* allocatable
        RubyClass cZStream = mZlib.defineOrGetClassUnder("ZStream", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        cZStream.defineAnnotatedMethods(ZStream.class);
        cZStream.undefineMethod("new");

        RubyClass cInflate = mZlib.defineOrGetClassUnder("Inflate", cZStream, JZlibInflate::new);
        cInflate.defineAnnotatedMethods(JZlibInflate.class);

        RubyClass cDeflate = mZlib.defineOrGetClassUnder("Deflate", cZStream, JZlibDeflate::new);
        cDeflate.defineAnnotatedMethods(JZlibDeflate.class);

        runtime.getKernel().callMethod(runtime.getCurrentContext(), "require", runtime.newString("stringio"));

        return mZlib;
    }
/** Create the Zlib module and add it to the Ruby runtime.
     *
     */
Create the Zlib module and add it to the Ruby runtime.
Create the Zlib module and add it to the Ruby runtime .
public static RubyModule createZlibModule(Ruby runtime) {
        RubyModule mZlib = runtime.defineModule("Zlib");
        mZlib.defineAnnotatedMethods(RubyZlib.class);
        RubyClass cStandardError = runtime.getStandardError();
        RubyClass cZlibError = mZlib.defineOrGetClassUnder("Error", cStandardError, cStandardError.getAllocator());
        mZlib.defineOrGetClassUnder("StreamEnd", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("StreamError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("BufError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("NeedDict", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("MemError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("VersionError", cZlibError, cZlibError.getAllocator());
        mZlib.defineOrGetClassUnder("DataError", cZlibError, cZlibError.getAllocator());
        RubyClass cGzFile = mZlib.defineOrGetClassUnder("GzipFile", runtime.getObject(), RubyGzipFile::new);
        cGzFile.defineAnnotatedMethods(RubyGzipFile.class);
        cGzFile.defineOrGetClassUnder("Error", cZlibError, cZlibError.getAllocator());
        RubyClass cGzError = cGzFile.defineOrGetClassUnder("Error", cZlibError, cZlibError.getAllocator());
        cGzError.addReadAttribute(runtime.getCurrentContext(), "input");
        cGzFile.defineOrGetClassUnder("CRCError", cGzError, cGzError.getAllocator());
        cGzFile.defineOrGetClassUnder("NoFooter", cGzError, cGzError.getAllocator());
        cGzFile.defineOrGetClassUnder("LengthError", cGzError, cGzError.getAllocator());
        RubyClass cGzReader = mZlib.defineOrGetClassUnder("GzipReader", cGzFile, JZlibRubyGzipReader::new);
        cGzReader.includeModule(runtime.getEnumerable());
        cGzReader.defineAnnotatedMethods(JZlibRubyGzipReader.class);
        RubyClass cGzWriter = mZlib.defineOrGetClassUnder("GzipWriter", cGzFile, JZlibRubyGzipWriter::new);
        cGzWriter.defineAnnotatedMethods(JZlibRubyGzipWriter.class);
        mZlib.defineConstant("ZLIB_VERSION", runtime.newString(ZLIB_VERSION));
        mZlib.defineConstant("VERSION", runtime.newString(VERSION));
        mZlib.defineConstant("BINARY", runtime.newFixnum(Z_BINARY));
        mZlib.defineConstant("ASCII", runtime.newFixnum(Z_ASCII));
        mZlib.defineConstant("UNKNOWN", runtime.newFixnum(Z_UNKNOWN));
        mZlib.defineConstant("DEF_MEM_LEVEL", runtime.newFixnum(8));
        mZlib.defineConstant("MAX_MEM_LEVEL", runtime.newFixnum(9));
        mZlib.defineConstant("OS_UNIX", runtime.newFixnum(OS_UNIX));
        mZlib.defineConstant("OS_UNKNOWN", runtime.newFixnum(OS_UNKNOWN));
        mZlib.defineConstant("OS_CODE", runtime.newFixnum(OS_CODE));
        mZlib.defineConstant("OS_ZSYSTEM", runtime.newFixnum(OS_ZSYSTEM));
        mZlib.defineConstant("OS_VMCMS", runtime.newFixnum(OS_VMCMS));
        mZlib.defineConstant("OS_VMS", runtime.newFixnum(OS_VMS));
        mZlib.defineConstant("OS_RISCOS", runtime.newFixnum(OS_RISCOS));
        mZlib.defineConstant("OS_MACOS", runtime.newFixnum(OS_MACOS));
        mZlib.defineConstant("OS_OS2", runtime.newFixnum(OS_OS2));
        mZlib.defineConstant("OS_AMIGA", runtime.newFixnum(OS_AMIGA));
        mZlib.defineConstant("OS_QDOS", runtime.newFixnum(OS_QDOS));
        mZlib.defineConstant("OS_WIN32", runtime.newFixnum(OS_WIN32));
        mZlib.defineConstant("OS_ATARI", runtime.newFixnum(OS_ATARI));
        mZlib.defineConstant("OS_MSDOS", runtime.newFixnum(OS_MSDOS));
        mZlib.defineConstant("OS_CPM", runtime.newFixnum(OS_CPM));
        mZlib.defineConstant("OS_TOPS20", runtime.newFixnum(OS_TOPS20));
        mZlib.defineConstant("DEFAULT_STRATEGY", runtime.newFixnum(JZlib.Z_DEFAULT_STRATEGY));
        mZlib.defineConstant("FILTERED", runtime.newFixnum(JZlib.Z_FILTERED));
        mZlib.defineConstant("HUFFMAN_ONLY", runtime.newFixnum(JZlib.Z_HUFFMAN_ONLY));
        mZlib.defineConstant("NO_FLUSH", runtime.newFixnum(JZlib.Z_NO_FLUSH));
        mZlib.defineConstant("SYNC_FLUSH", runtime.newFixnum(JZlib.Z_SYNC_FLUSH));
        mZlib.defineConstant("FULL_FLUSH", runtime.newFixnum(JZlib.Z_FULL_FLUSH));
        mZlib.defineConstant("FINISH", runtime.newFixnum(JZlib.Z_FINISH));
        mZlib.defineConstant("NO_COMPRESSION", runtime.newFixnum(JZlib.Z_NO_COMPRESSION));
        mZlib.defineConstant("BEST_SPEED", runtime.newFixnum(JZlib.Z_BEST_SPEED));
        mZlib.defineConstant("DEFAULT_COMPRESSION", runtime.newFixnum(JZlib.Z_DEFAULT_COMPRESSION));
        mZlib.defineConstant("BEST_COMPRESSION", runtime.newFixnum(JZlib.Z_BEST_COMPRESSION));
        mZlib.defineConstant("MAX_WBITS", runtime.newFixnum(JZlib.MAX_WBITS));
        RubyClass cZStream = mZlib.defineOrGetClassUnder("ZStream", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
        cZStream.defineAnnotatedMethods(ZStream.class);
        cZStream.undefineMethod("new");
        RubyClass cInflate = mZlib.defineOrGetClassUnder("Inflate", cZStream, JZlibInflate::new);
        cInflate.defineAnnotatedMethods(JZlibInflate.class);
        RubyClass cDeflate = mZlib.defineOrGetClassUnder("Deflate", cZStream, JZlibDeflate::new);
        cDeflate.defineAnnotatedMethods(JZlibDeflate.class);
        runtime.getKernel().callMethod(runtime.getCurrentContext(), "require", runtime.newString("stringio"));
        return mZlib;
    }
public static RubyModule createZlibModule ( Ruby runtime ) { RubyModule mZlib = runtime . defineModule ( "Zlib" ) ; mZlib . defineAnnotatedMethods ( RubyZlib . class ) ; RubyClass cStandardError = runtime . getStandardError ( ) ; RubyClass cZlibError = mZlib . defineOrGetClassUnder ( "Error" , cStandardError , cStandardError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "StreamEnd" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "StreamError" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "BufError" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "NeedDict" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "MemError" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "VersionError" , cZlibError , cZlibError . getAllocator ( ) ) ; mZlib . defineOrGetClassUnder ( "DataError" , cZlibError , cZlibError . getAllocator ( ) ) ; RubyClass cGzFile = mZlib . defineOrGetClassUnder ( "GzipFile" , runtime . getObject ( ) , RubyGzipFile :: new ) ; cGzFile . defineAnnotatedMethods ( RubyGzipFile . class ) ; cGzFile . defineOrGetClassUnder ( "Error" , cZlibError , cZlibError . getAllocator ( ) ) ; RubyClass cGzError = cGzFile . defineOrGetClassUnder ( "Error" , cZlibError , cZlibError . getAllocator ( ) ) ; cGzError . addReadAttribute ( runtime . getCurrentContext ( ) , "input" ) ; cGzFile . defineOrGetClassUnder ( "CRCError" , cGzError , cGzError . getAllocator ( ) ) ; cGzFile . defineOrGetClassUnder ( "NoFooter" , cGzError , cGzError . getAllocator ( ) ) ; cGzFile . defineOrGetClassUnder ( "LengthError" , cGzError , cGzError . getAllocator ( ) ) ; RubyClass cGzReader = mZlib . defineOrGetClassUnder ( "GzipReader" , cGzFile , JZlibRubyGzipReader :: new ) ; cGzReader . includeModule ( runtime . getEnumerable ( ) ) ; cGzReader . defineAnnotatedMethods ( JZlibRubyGzipReader . class ) ; RubyClass cGzWriter = mZlib . defineOrGetClassUnder ( "GzipWriter" , cGzFile , JZlibRubyGzipWriter :: new ) ; cGzWriter . defineAnnotatedMethods ( JZlibRubyGzipWriter . class ) ; mZlib . defineConstant ( "ZLIB_VERSION" , runtime . newString ( ZLIB_VERSION ) ) ; mZlib . defineConstant ( "VERSION" , runtime . newString ( VERSION ) ) ; mZlib . defineConstant ( "BINARY" , runtime . newFixnum ( Z_BINARY ) ) ; mZlib . defineConstant ( "ASCII" , runtime . newFixnum ( Z_ASCII ) ) ; mZlib . defineConstant ( "UNKNOWN" , runtime . newFixnum ( Z_UNKNOWN ) ) ; mZlib . defineConstant ( "DEF_MEM_LEVEL" , runtime . newFixnum ( 8 ) ) ; mZlib . defineConstant ( "MAX_MEM_LEVEL" , runtime . newFixnum ( 9 ) ) ; mZlib . defineConstant ( "OS_UNIX" , runtime . newFixnum ( OS_UNIX ) ) ; mZlib . defineConstant ( "OS_UNKNOWN" , runtime . newFixnum ( OS_UNKNOWN ) ) ; mZlib . defineConstant ( "OS_CODE" , runtime . newFixnum ( OS_CODE ) ) ; mZlib . defineConstant ( "OS_ZSYSTEM" , runtime . newFixnum ( OS_ZSYSTEM ) ) ; mZlib . defineConstant ( "OS_VMCMS" , runtime . newFixnum ( OS_VMCMS ) ) ; mZlib . defineConstant ( "OS_VMS" , runtime . newFixnum ( OS_VMS ) ) ; mZlib . defineConstant ( "OS_RISCOS" , runtime . newFixnum ( OS_RISCOS ) ) ; mZlib . defineConstant ( "OS_MACOS" , runtime . newFixnum ( OS_MACOS ) ) ; mZlib . defineConstant ( "OS_OS2" , runtime . newFixnum ( OS_OS2 ) ) ; mZlib . defineConstant ( "OS_AMIGA" , runtime . newFixnum ( OS_AMIGA ) ) ; mZlib . defineConstant ( "OS_QDOS" , runtime . newFixnum ( OS_QDOS ) ) ; mZlib . defineConstant ( "OS_WIN32" , runtime . newFixnum ( OS_WIN32 ) ) ; mZlib . defineConstant ( "OS_ATARI" , runtime . newFixnum ( OS_ATARI ) ) ; mZlib . defineConstant ( "OS_MSDOS" , runtime . newFixnum ( OS_MSDOS ) ) ; mZlib . defineConstant ( "OS_CPM" , runtime . newFixnum ( OS_CPM ) ) ; mZlib . defineConstant ( "OS_TOPS20" , runtime . newFixnum ( OS_TOPS20 ) ) ; mZlib . defineConstant ( "DEFAULT_STRATEGY" , runtime . newFixnum ( JZlib . Z_DEFAULT_STRATEGY ) ) ; mZlib . defineConstant ( "FILTERED" , runtime . newFixnum ( JZlib . Z_FILTERED ) ) ; mZlib . defineConstant ( "HUFFMAN_ONLY" , runtime . newFixnum ( JZlib . Z_HUFFMAN_ONLY ) ) ; mZlib . defineConstant ( "NO_FLUSH" , runtime . newFixnum ( JZlib . Z_NO_FLUSH ) ) ; mZlib . defineConstant ( "SYNC_FLUSH" , runtime . newFixnum ( JZlib . Z_SYNC_FLUSH ) ) ; mZlib . defineConstant ( "FULL_FLUSH" , runtime . newFixnum ( JZlib . Z_FULL_FLUSH ) ) ; mZlib . defineConstant ( "FINISH" , runtime . newFixnum ( JZlib . Z_FINISH ) ) ; mZlib . defineConstant ( "NO_COMPRESSION" , runtime . newFixnum ( JZlib . Z_NO_COMPRESSION ) ) ; mZlib . defineConstant ( "BEST_SPEED" , runtime . newFixnum ( JZlib . Z_BEST_SPEED ) ) ; mZlib . defineConstant ( "DEFAULT_COMPRESSION" , runtime . newFixnum ( JZlib . Z_DEFAULT_COMPRESSION ) ) ; mZlib . defineConstant ( "BEST_COMPRESSION" , runtime . newFixnum ( JZlib . Z_BEST_COMPRESSION ) ) ; mZlib . defineConstant ( "MAX_WBITS" , runtime . newFixnum ( JZlib . MAX_WBITS ) ) ; RubyClass cZStream = mZlib . defineOrGetClassUnder ( "ZStream" , runtime . getObject ( ) , ObjectAllocator . NOT_ALLOCATABLE_ALLOCATOR ) ; cZStream . defineAnnotatedMethods ( ZStream . class ) ; cZStream . undefineMethod ( "new" ) ; RubyClass cInflate = mZlib . defineOrGetClassUnder ( "Inflate" , cZStream , JZlibInflate :: new ) ; cInflate . defineAnnotatedMethods ( JZlibInflate . class ) ; RubyClass cDeflate = mZlib . defineOrGetClassUnder ( "Deflate" , cZStream , JZlibDeflate :: new ) ; cDeflate . defineAnnotatedMethods ( JZlibDeflate . class ) ; runtime . getKernel ( ) . callMethod ( runtime . getCurrentContext ( ) , "require" , runtime . newString ( "stringio" ) ) ; return mZlib ; }
Create the Zlib module and add it to the Ruby runtime.
Create the Zlib module and add it to the Ruby runtime .
// ZStream actually *isn't* allocatable