Skip to content

Commit f7277b5

Browse files
author
Pascal Deneaux
authored
Merge pull request #1 from adafruit/master
test pull
2 parents d2a7cd6 + 07a4cc0 commit f7277b5

File tree

156 files changed

+6420
-2617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+6420
-2617
lines changed

docs/library/builtins.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ Not all of these functions and types are turned on in all CircuitPython ports, f
7878

7979
.. classmethod:: from_bytes(bytes, byteorder)
8080

81-
In CircuitPython, `byteorder` parameter must be positional (this is
81+
In CircuitPython, ``byteorder`` parameter must be positional (this is
8282
compatible with CPython).
8383

8484
.. method:: to_bytes(size, byteorder)
8585

86-
In CircuitPython, `byteorder` parameter must be positional (this is
86+
In CircuitPython, ``byteorder`` parameter must be positional (this is
8787
compatible with CPython).
8888

8989
.. function:: isinstance()

extmod/machine_i2c.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ STATIC void machine_i2c_obj_init_helper(machine_i2c_obj_t *self, size_t n_args,
287287
mp_hal_i2c_init(self, args[ARG_freq].u_int);
288288
}
289289

290-
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
290+
STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
291291
// check the id argument, if given
292292
if (n_args > 0) {
293293
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
294294
#if defined(MICROPY_PY_MACHINE_I2C_MAKE_NEW)
295295
// dispatch to port-specific constructor
296-
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
297-
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, n_kw, args);
296+
extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args);
297+
return MICROPY_PY_MACHINE_I2C_MAKE_NEW(type, n_args, args, kw_args);
298298
#else
299299
mp_raise_ValueError(translate("invalid I2C peripheral"));
300300
#endif
@@ -306,9 +306,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
306306
// create new soft I2C object
307307
machine_i2c_obj_t *self = m_new_obj(machine_i2c_obj_t);
308308
self->base.type = &machine_i2c_type;
309-
mp_map_t kw_args;
310-
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
311-
machine_i2c_obj_init_helper(self, n_args, args, &kw_args);
309+
machine_i2c_obj_init_helper(self, n_args, args, kw_args);
312310
return (mp_obj_t)self;
313311
}
314312

extmod/machine_pinbase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ STATIC const mp_pinbase_t pinbase_singleton = {
4545
.base = { &machine_pinbase_type },
4646
};
4747

48-
STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
48+
STATIC mp_obj_t pinbase_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
4949
(void)type;
5050
(void)n_args;
51-
(void)n_kw;
5251
(void)args;
52+
(void)kw_args;
5353
return MP_OBJ_FROM_PTR(&pinbase_singleton);
5454
}
5555

extmod/machine_signal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct _machine_signal_t {
4242
bool invert;
4343
} machine_signal_t;
4444

45-
STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
45+
STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
4646
mp_obj_t pin = args[0];
4747
bool invert = false;
4848

@@ -96,9 +96,9 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
9696
// Otherwise there should be 1 or 2 args
9797
{
9898
if (n_args == 1) {
99-
if (n_kw == 0) {
100-
} else if (n_kw == 1 && args[1] == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
101-
invert = mp_obj_is_true(args[2]);
99+
if (kw_args == NULL || kw_args->used == 0) {
100+
} else if (kw_args->used == 1 && kw_args->table[0].key == MP_OBJ_NEW_QSTR(MP_QSTR_invert)) {
101+
invert = mp_obj_is_true(kw_args->table[0].value);
102102
} else {
103103
goto error;
104104
}
@@ -133,7 +133,7 @@ STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg
133133

134134
// fast method for getting/setting signal value
135135
STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
136-
mp_arg_check_num(n_args, n_kw, 0, 1, false);
136+
mp_arg_check_num_kw_array(n_args, n_kw, 0, 1, false);
137137
if (n_args == 0) {
138138
// get pin
139139
return MP_OBJ_NEW_SMALL_INT(mp_virtual_pin_read(self_in));

extmod/machine_spi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@
4343
/******************************************************************************/
4444
// MicroPython bindings for generic machine.SPI
4545

46-
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
46+
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
4747

48-
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
48+
mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
4949
// check the id argument, if given
5050
if (n_args > 0) {
5151
if (args[0] != MP_OBJ_NEW_SMALL_INT(-1)) {
5252
#if defined(MICROPY_PY_MACHINE_SPI_MAKE_NEW)
5353
// dispatch to port-specific constructor
54-
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);
55-
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, n_kw, args);
54+
extern mp_obj_t MICROPY_PY_MACHINE_SPI_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
55+
return MICROPY_PY_MACHINE_SPI_MAKE_NEW(type, n_args, args, kw_args);
5656
#else
5757
mp_raise_ValueError(translate("invalid SPI peripheral"));
5858
#endif
@@ -62,7 +62,7 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_
6262
}
6363

6464
// software SPI
65-
return mp_machine_soft_spi_make_new(type, n_args, n_kw, args);
65+
return mp_machine_soft_spi_make_new(type, n_args, args, kw_args);
6666
}
6767

6868
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
@@ -180,7 +180,7 @@ STATIC void mp_machine_soft_spi_print(const mp_print_t *print, mp_obj_t self_in,
180180
mp_hal_pin_name(self->spi.sck), mp_hal_pin_name(self->spi.mosi), mp_hal_pin_name(self->spi.miso));
181181
}
182182

183-
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
183+
STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
184184
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_sck, ARG_mosi, ARG_miso };
185185
static const mp_arg_t allowed_args[] = {
186186
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 500000} },
@@ -193,7 +193,7 @@ STATIC mp_obj_t mp_machine_soft_spi_make_new(const mp_obj_type_t *type, size_t n
193193
{ MP_QSTR_miso, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
194194
};
195195
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
196-
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
196+
mp_arg_parse_all(n_args, all_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
197197

198198
// create new object
199199
mp_machine_soft_spi_obj_t *self = m_new_obj(mp_machine_soft_spi_obj_t);

extmod/modframebuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, u
259259
formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col);
260260
}
261261

262-
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
263-
mp_arg_check_num(n_args, n_kw, 4, 5, false);
262+
STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
263+
mp_arg_check_num(n_args, kw_args, 4, 5, false);
264264

265265
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
266266
o->base.type = type;

extmod/moductypes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ STATIC NORETURN void syntax_error(void) {
122122
mp_raise_TypeError(translate("syntax error in uctypes descriptor"));
123123
}
124124

125-
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
126-
mp_arg_check_num(n_args, n_kw, 2, 3, false);
125+
STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
126+
mp_arg_check_num(n_args, kw_args, 2, 3, false);
127127
mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t);
128128
o->base.type = type;
129129
o->addr = (void*)(uintptr_t)mp_obj_int_get_truncated(args[0]);

extmod/modutimeq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ STATIC bool time_less_than(struct qentry *item, struct qentry *parent) {
7676
return res && res < (MODULO / 2);
7777
}
7878

79-
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
80-
mp_arg_check_num(n_args, n_kw, 1, 1, false);
79+
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
80+
mp_arg_check_num(n_args, kw_args, 1, 1, false);
8181
mp_uint_t alloc = mp_obj_get_int(args[0]);
8282
mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc);
8383
o->base.type = type;

extmod/moduzlib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ STATIC int read_src_stream(TINF_DATA *data) {
6969
return c;
7070
}
7171

72-
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
73-
mp_arg_check_num(n_args, n_kw, 1, 2, false);
72+
STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
73+
mp_arg_check_num(n_args, kw_args, 1, 2, false);
7474
mp_get_stream_raise(args[0], MP_STREAM_OP_READ);
7575
mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t);
7676
o->base.type = type;

extmod/modwebsocket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ typedef struct _mp_obj_websocket_t {
5757

5858
STATIC mp_uint_t websocket_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode);
5959

60-
STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
61-
mp_arg_check_num(n_args, n_kw, 1, 2, false);
60+
STATIC mp_obj_t websocket_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
61+
mp_arg_check_num(n_args, kw_args, 1, 2, false);
6262
mp_get_stream_raise(args[0], MP_STREAM_OP_READ | MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL);
6363
mp_obj_websocket_t *o = m_new_obj(mp_obj_websocket_t);
6464
o->base.type = type;

extmod/vfs_posix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ STATIC mp_import_stat_t mp_vfs_posix_import_stat(void *self_in, const char *path
9090
return MP_IMPORT_STAT_NO_EXIST;
9191
}
9292

93-
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
94-
mp_arg_check_num(n_args, n_kw, 0, 1, false);
93+
STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
94+
mp_arg_check_num(n_args, kw_args, 0, 1, false);
9595

9696
mp_obj_vfs_posix_t *vfs = m_new_obj(mp_obj_vfs_posix_t);
9797
vfs->base.type = type;

extmod/vfs_posix_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_
109109
return MP_OBJ_FROM_PTR(o);
110110
}
111111

112-
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
112+
STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
113113
static const mp_arg_t allowed_args[] = {
114114
{ MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_PTR(&mp_const_none_obj)} },
115115
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} },
116116
};
117117

118118
mp_arg_val_t arg_vals[MP_ARRAY_SIZE(allowed_args)];
119-
mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
119+
mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals);
120120
return mp_vfs_posix_file_open(type, arg_vals[0].u_obj, arg_vals[1].u_obj);
121121
}
122122

0 commit comments

Comments
 (0)