Skip to content

Commit

Permalink
extmod/moddeflate: Add deflate module providing the DeflateIO class.
Browse files Browse the repository at this point in the history
This provides similar functionality to the former zlib.DecompIO and
especially CPython's gzip.GzipFile for both compression and decompression.

This class can be used directly, and also can be used from Python to
implement (via io.BytesIO) zlib.decompress and zlib.compress, as well as
gzip.GzipFile.

Enable/disable this on all ports/boards that zlib was previously configured
for.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
  • Loading branch information
jimmo authored and dpgeorge committed Jul 21, 2023
1 parent e6c290c commit 3533924
Show file tree
Hide file tree
Showing 12 changed files with 434 additions and 10 deletions.
1 change: 1 addition & 0 deletions extmod/extmod.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(MICROPY_SOURCE_EXTMOD
${MICROPY_EXTMOD_DIR}/modbinascii.c
${MICROPY_EXTMOD_DIR}/modcryptolib.c
${MICROPY_EXTMOD_DIR}/moductypes.c
${MICROPY_EXTMOD_DIR}/moddeflate.c
${MICROPY_EXTMOD_DIR}/modhashlib.c
${MICROPY_EXTMOD_DIR}/modheapq.c
${MICROPY_EXTMOD_DIR}/modjson.c
Expand Down
1 change: 1 addition & 0 deletions extmod/extmod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SRC_EXTMOD_C += \
extmod/modbluetooth.c \
extmod/modbtree.c \
extmod/modcryptolib.c \
extmod/moddeflate.c \
extmod/modframebuf.c \
extmod/modhashlib.c \
extmod/modheapq.c \
Expand Down
6 changes: 3 additions & 3 deletions extmod/modbinascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ STATIC mp_obj_t mod_binascii_b2a_base64(size_t n_args, const mp_obj_t *pos_args,
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_binascii_b2a_base64_obj, 1, mod_binascii_b2a_base64);

#if 0 // MICROPY_PY_BINASCII_CRC32
#include "lib/uzlib/crc32.c"
#if MICROPY_PY_BINASCII_CRC32 && MICROPY_PY_DEFLATE
#include "lib/uzlib/uzlib.h"

STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;
Expand All @@ -191,7 +191,7 @@ STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = {
#endif
{ MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) },
{ MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) },
#if 0 // MICROPY_PY_BINASCII_CRC32
#if MICROPY_PY_BINASCII_CRC32 && MICROPY_PY_DEFLATE
{ MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) },
#endif
};
Expand Down
Loading

0 comments on commit 3533924

Please sign in to comment.