Skip to content

Commit 0f716ac

Browse files
Daniel Camporapfalcon
authored andcommitted
extmod: Expose mod_binascii_hexlify() and mod_binascii_unhexlify().
1 parent a3c96c9 commit 0f716ac

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

extmod/modubinascii.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
#include "py/nlr.h"
3232
#include "py/runtime.h"
3333
#include "py/binary.h"
34+
#include "modubinascii.h"
3435

35-
#if MICROPY_PY_UBINASCII
3636

37-
STATIC mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
37+
mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
3838
// Second argument is for an extension to allow a separator to be used
3939
// between values.
4040
(void)n_args;
@@ -60,7 +60,7 @@ STATIC mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
6060
}
6161
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_hexlify_obj, 1, 2, mod_binascii_hexlify);
6262

63-
STATIC mp_obj_t mod_binascii_unhexlify(mp_obj_t data) {
63+
mp_obj_t mod_binascii_unhexlify(mp_obj_t data) {
6464
mp_buffer_info_t bufinfo;
6565
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
6666

@@ -89,6 +89,8 @@ STATIC mp_obj_t mod_binascii_unhexlify(mp_obj_t data) {
8989
}
9090
MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_unhexlify_obj, mod_binascii_unhexlify);
9191

92+
#if MICROPY_PY_UBINASCII
93+
9294
STATIC const mp_map_elem_t mp_module_binascii_globals_table[] = {
9395
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_ubinascii) },
9496
{ MP_OBJ_NEW_QSTR(MP_QSTR_hexlify), (mp_obj_t)&mod_binascii_hexlify_obj },

extmod/modubinascii.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of the Micro Python project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2014 Paul Sokolovsky
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_EXTMOD_MODUBINASCII
28+
#define MICROPY_EXTMOD_MODUBINASCII
29+
30+
extern mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args);
31+
extern mp_obj_t mod_binascii_unhexlify(mp_obj_t data);
32+
33+
#endif /* MICROPY_EXTMOD_MODUBINASCII */

0 commit comments

Comments
 (0)