mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
Upgrade to MicroPython 1.9.3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@@ -27,9 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "py/nlr.h"
|
||||
#include "py/objtuple.h"
|
||||
#include "py/runtime0.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -101,7 +99,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
|
||||
}
|
||||
|
||||
// Don't pass MP_BINARY_OP_NOT_EQUAL here
|
||||
STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
STATIC mp_obj_t tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in) {
|
||||
// type check is done on getiter method to allow tuple, namedtuple, attrtuple
|
||||
mp_check_self(mp_obj_get_type(self_in)->getiter == mp_obj_tuple_getiter);
|
||||
mp_obj_type_t *another_type = mp_obj_get_type(another_in);
|
||||
@@ -110,15 +108,18 @@ STATIC bool tuple_cmp_helper(mp_uint_t op, mp_obj_t self_in, mp_obj_t another_in
|
||||
// Slow path for user subclasses
|
||||
another_in = mp_instance_cast_to_native_base(another_in, MP_OBJ_FROM_PTR(&mp_type_tuple));
|
||||
if (another_in == MP_OBJ_NULL) {
|
||||
return false;
|
||||
if (op == MP_BINARY_OP_EQUAL) {
|
||||
return mp_const_false;
|
||||
}
|
||||
return MP_OBJ_NULL;
|
||||
}
|
||||
}
|
||||
mp_obj_tuple_t *another = MP_OBJ_TO_PTR(another_in);
|
||||
|
||||
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
|
||||
return mp_obj_new_bool(mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len));
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
||||
mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
switch (op) {
|
||||
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
|
||||
@@ -135,7 +136,7 @@ mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_t mp_obj_tuple_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_obj_tuple_t *o = MP_OBJ_TO_PTR(lhs);
|
||||
switch (op) {
|
||||
case MP_BINARY_OP_ADD:
|
||||
@@ -148,7 +149,8 @@ mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
|
||||
return MP_OBJ_FROM_PTR(s);
|
||||
}
|
||||
case MP_BINARY_OP_MULTIPLY: {
|
||||
case MP_BINARY_OP_MULTIPLY:
|
||||
case MP_BINARY_OP_INPLACE_MULTIPLY: {
|
||||
mp_int_t n;
|
||||
if (!mp_obj_get_int_maybe(rhs, &n)) {
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
@@ -165,7 +167,7 @@ mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||
case MP_BINARY_OP_LESS_EQUAL:
|
||||
case MP_BINARY_OP_MORE:
|
||||
case MP_BINARY_OP_MORE_EQUAL:
|
||||
return mp_obj_new_bool(tuple_cmp_helper(op, lhs, rhs));
|
||||
return tuple_cmp_helper(op, lhs, rhs);
|
||||
|
||||
default:
|
||||
return MP_OBJ_NULL; // op not supported
|
||||
@@ -180,7 +182,7 @@ mp_obj_t mp_obj_tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
||||
mp_bound_slice_t slice;
|
||||
if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
|
||||
mp_not_implemented("only slices with step=1 (aka None) are supported");
|
||||
mp_raise_NotImplementedError("only slices with step=1 (aka None) are supported");
|
||||
}
|
||||
mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice.stop - slice.start, NULL));
|
||||
mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t);
|
||||
|
||||
Reference in New Issue
Block a user