diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 4a11d3eada..8d1544b34e 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -30,9 +30,10 @@ #include "py/runtime.h" #include "py/binary.h" -#include "extmod/modubinascii.h" -mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { +#if MICROPY_PY_UBINASCII + +STATIC mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { // Second argument is for an extension to allow a separator to be used // between values. const char *sep = NULL; @@ -71,9 +72,9 @@ mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args) { } return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj, 1, 2, mod_binascii_hexlify); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj, 1, 2, mod_binascii_hexlify); -mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { +STATIC mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); @@ -100,7 +101,7 @@ mp_obj_t mod_binascii_unhexlify(mp_obj_t data) { } return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj, mod_binascii_unhexlify); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj, mod_binascii_unhexlify); // If ch is a character in the base64 alphabet, and is not a pad character, then // the corresponding integer between 0 and 63, inclusively, is returned. @@ -121,7 +122,7 @@ static int mod_binascii_sextet(byte ch) { } } -mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { +STATIC mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); byte *in = bufinfo.buf; @@ -162,9 +163,9 @@ mp_obj_t mod_binascii_a2b_base64(mp_obj_t data) { return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj, mod_binascii_a2b_base64); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj, mod_binascii_a2b_base64); -mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { +STATIC mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); @@ -214,23 +215,21 @@ mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { *out = '\n'; return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); } -MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); #if MICROPY_PY_UBINASCII_CRC32 #include "uzlib/tinf.h" -mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); return mp_obj_new_int_from_uint(crc ^ 0xffffffff); } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); #endif -#if MICROPY_PY_UBINASCII - STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubinascii) }, { MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&mod_binascii_hexlify_obj) }, diff --git a/extmod/modubinascii.h b/extmod/modubinascii.h deleted file mode 100644 index fb31692678..0000000000 --- a/extmod/modubinascii.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Paul Sokolovsky - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H -#define MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H - -extern mp_obj_t mod_binascii_hexlify(size_t n_args, const mp_obj_t *args); -extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data); -extern mp_obj_t mod_binascii_a2b_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_b2a_base64(mp_obj_t data); -extern mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args); - -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_a2b_base64_obj); -MP_DECLARE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj); -MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj); - -#endif // MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H diff --git a/ports/cc3200/application.mk b/ports/cc3200/application.mk index 468fa134f9..c926fda10c 100644 --- a/ports/cc3200/application.mk +++ b/ports/cc3200/application.mk @@ -79,7 +79,6 @@ APP_MISC_SRC_C = $(addprefix misc/,\ APP_MODS_SRC_C = $(addprefix mods/,\ modmachine.c \ modnetwork.c \ - modubinascii.c \ moduos.c \ modusocket.c \ modussl.c \ diff --git a/ports/cc3200/mods/modubinascii.c b/ports/cc3200/mods/modubinascii.c deleted file mode 100644 index 6b020ab393..0000000000 --- a/ports/cc3200/mods/modubinascii.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Paul Sokolovsky - * Copyright (c) 2015 Daniel Campora - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "py/runtime.h" -#include "py/binary.h" -#include "extmod/modubinascii.h" -#include "modubinascii.h" -#include "inc/hw_types.h" -#include "inc/hw_ints.h" -#include "inc/hw_nvic.h" -#include "inc/hw_dthe.h" -#include "hw_memmap.h" -#include "rom_map.h" -#include "prcm.h" -#include "crc.h" -#include "cryptohash.h" -#include "mpexception.h" - - -/******************************************************************************/ -// MicroPython bindings - -STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubinascii) }, - { MP_ROM_QSTR(MP_QSTR_hexlify), MP_ROM_PTR(&mod_binascii_hexlify_obj) }, - { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) }, - { 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) }, -}; - -STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); - -const mp_obj_module_t mp_module_ubinascii = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_binascii_globals, -}; diff --git a/ports/cc3200/mods/modubinascii.h b/ports/cc3200/mods/modubinascii.h deleted file mode 100644 index eb9fc4f219..0000000000 --- a/ports/cc3200/mods/modubinascii.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Paul Sokolovsky - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H -#define MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H - - -#endif // MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H diff --git a/ports/cc3200/mpconfigport.h b/ports/cc3200/mpconfigport.h index 3bb10bf09a..6fdb278d86 100644 --- a/ports/cc3200/mpconfigport.h +++ b/ports/cc3200/mpconfigport.h @@ -110,7 +110,7 @@ #define MICROPY_PY_UERRNO_ERRORCODE (0) #define MICROPY_PY_THREAD (1) #define MICROPY_PY_THREAD_GIL (1) -#define MICROPY_PY_UBINASCII (0) +#define MICROPY_PY_UBINASCII (1) #define MICROPY_PY_UCTYPES (0) #define MICROPY_PY_UZLIB (0) #define MICROPY_PY_UJSON (1)